# Sample requests

Different variables can be queried using:

```
https://api.lacertalabs.xyz/data/[variable]
```

where **`[variable]`** is replaced with the specific variable you want to query. For example, to query the gas fee collection:

```
https://api.lacertalabs.xyz/data/gasfeecollection
```

The responses from the API are in JSON format

```json
{
  "0": {
    "day": "2023-10-26T00:00:00.000Z",
    "average": "501377204.81145328"
  },
  "latestTen": {
    "info": [
      {"circulationsupply": "501378716.82265", "height": 12261375},
      {"circulationsupply": "501378716.82265", "height": 12261374},
      {"circulationsupply": "501378716.82265", "height": 12261373},
      {"circulationsupply": "501378716.22173315", "height": 12261372},
      {"circulationsupply": "501378714.44391423", "height": 12261371},
      {"circulationsupply": "501378714.44391423", "height": 12261370},
      {"circulationsupply": "501378714.44391423", "height": 12261369},
      {"circulationsupply": "501378713.83916193", "height": 12261368},
      {"circulationsupply": "501378711.8043553", "height": 12261367},
      {"circulationsupply": "501378711.8043553", "height": 12261366}
    ]
  }
}
```

#### **Daily Averages and Sums**

* **Keys**: Daily averages or sums are indexed by keys starting from **`0`**.
* **Genesis Date**: The date of the genesis block is represented by the key **`0`**, which corresponds to October 26th, 2023.
* **Subsequent Days**: Keys **`1`**, **`2`**, **`3`**, etc., represent the daily averages or sums for each subsequent day since the genesis block.

#### **Latest 10 Values**

* **Key**: The latest 10 values for a variable can be found under the key **`latestTen`**.
* **Format**: Each entry includes the value of the variable and its associated block height, formatted as shown above.

### **Request Headers**

To query a specific block height, add the block height to the request header. For example:

```bash
curl --header "height: 12261374" https://api.lacertalabs.xyz/data/gasfeecollection
```

### **API Endpoints for Different Variables**

* **Circulating Supply**:

  ```url
  https://api.lacertalabs.xyz/data/circulationsupply
  ```
* **Trading Fee Collection**:

  ```url
  https://api.lacertalabs.xyz/data/tradingfeecollection
  ```
* **Gas Fee Collection**:

  ```url
  https://api.lacertalabs.xyz/data/gasfeecollection
  ```
* **Staking APR**:

  ```url
  https://api.lacertalabs.xyz/data/stakingapr
  ```
* **Trading Rewards Distribution**:

  ```url
  https://api.lacertalabs.xyz/data/tradingrewardsdistribution
  ```

### **Example Requests**

#### **Example 1: Querying Circulating Supply**

To get the latest data on circulating supply, use:

```bash
curl https://api.lacertalabs.xyz/data/circulationsupply
```

**Response:**

```json
{
  "0": {
    "day": "2023-10-26T00:00:00.000Z",
    "average": "501377204.81145328"
  },
  "latestTen": {
    "info": [
      {"circulationsupply": "501378716.82265", "height": 12261375},
      {"circulationsupply": "501378716.82265", "height": 12261374},
      {"circulationsupply": "501378716.82265", "height": 12261373},
      {"circulationsupply": "501378716.22173315", "height": 12261372},
      {"circulationsupply": "501378714.44391423", "height": 12261371},
      {"circulationsupply": "501378714.44391423", "height": 12261370},
      {"circulationsupply": "501378714.44391423", "height": 12261369},
      {"circulationsupply": "501378713.83916193", "height": 12261368},
      {"circulationsupply": "501378711.8043553", "height": 12261367},
      {"circulationsupply": "501378711.8043553", "height": 12261366}
    ]
  }
}
```

#### **Example 2: Querying Trading Fee Collection**

To get the latest data on trading fee collection, use:

```bash
curl https://api.lacertalabs.xyz/data/tradingfeecollection
```

**Response:**

```json
{
  "0": {
    "day": "2023-10-26T00:00:00.000Z",
    "average": "100245.12345678"
  },
  "latestTen": {
    "info": [
      {"tradingfeecollection": "100255.1234", "height": 12261375},
      {"tradingfeecollection": "100255.1234", "height": 12261374},
      {"tradingfeecollection": "100255.1234", "height": 12261373},
      {"tradingfeecollection": "100255.1234", "height": 12261372},
      {"tradingfeecollection": "100255.1234", "height": 12261371},
      {"tradingfeecollection": "100255.1234", "height": 12261370},
      {"tradingfeecollection": "100255.1234", "height": 12261369},
      {"tradingfeecollection": "100255.1234", "height": 12261368},
      {"tradingfeecollection": "100255.1234", "height": 12261367},
      {"tradingfeecollection": "100255.1234", "height": 12261366}
    ]
  }
}
```

#### **Example 3: Querying a Specific Block Height for Gas Fee Collection**

To get the gas fee collection for a specific block height (e.g., 12261374), use:

```bash
curl --header "height: 12261374" https://api.lacertalabs.xyz/data/gasfeecollection
```

**Response:**

```json
{
  "gasfeecollection": "4532.1234",
  "height": 12261374
}
```

#### **Example 4: Querying Staking APR**

To get the latest data on staking APR, use:

```bash
curl https://api.lacertalabs.xyz/data/stakingapr
```

**Response:**

```json
{
  "0": {
    "day": "2023-10-26T00:00:00.000Z",
    "average": "5.6789"
  },
  "latestTen": {
    "info": [
      {"stakingapr": "5.6890", "height": 12261375},
      {"stakingapr": "5.6890", "height": 12261374},
      {"stakingapr": "5.6890", "height": 12261373},
      {"stakingapr": "5.6890", "height": 12261372},
      {"stakingapr": "5.6890", "height": 12261371},
      {"stakingapr": "5.6890", "height": 12261370},
      {"stakingapr": "5.6890", "height": 12261369},
      {"stakingapr": "5.6890", "height": 12261368},
      {"stakingapr": "5.6890", "height": 12261367},
      {"stakingapr": "5.6890", "height": 12261366}
    ]
  }
}

```

#### **Example 5: Querying Trading Rewards Distribution**

To get the latest data on trading rewards distribution, use:

```bash
curl https://api.lacertalabs.xyz/data/tradingrewardsdistribution
```

**Response:**

```json
{
  "0": {
    "day": "2023-10-26T00:00:00.000Z",
    "average": "789456.1234"
  },
  "latestTen": {
    "info": [
      {"tradingrewardsdistribution": "789456.1234", "height": 12261375},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261374},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261373},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261372},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261371},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261370},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261369},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261368},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261367},
      {"tradingrewardsdistribution": "789456.1234", "height": 12261366}
    ]
  }
}
```

***

#### **Example 6: Querying Data for a Specific Date Range**

To get data for a specific range of dates, you will need to filter the results client-side as the API currently returns a full dataset. Here’s an example in Python:

```python
import requests
import json
from datetime import datetime

# Define the endpoint and the variable
endpoint = "https://api.lacertalabs.xyz/data/circulationsupply"

# Make the request to the API
response = requests.get(endpoint)
data = response.json()

# Define the date range
start_date = datetime.strptime("2023-10-26", "%Y-%m-%d")
end_date = datetime.strptime("2023-11-05", "%Y-%m-%d")

# Filter the data based on the date range
filtered_data = {k: v for k, v in data.items() if k.isdigit() and start_date <= datetime.strptime(v['day'], "%Y-%m-%dT%H:%M:%S.%fZ") <= end_date}

# Print the filtered data
print(json.dumps(filtered_data, indent=2))
```
