> ## Documentation Index
> Fetch the complete documentation index at: https://docs.amberdata.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Query Parameters and Optimization

## Performance Optimization with Compression

To improve the efficiency and performance of data transfer, we enforce compression when interacting with our **Market Data APIs**. Using compression reduces the size of the data payload, allowing for faster fetch times and better bandwidth utilization.

### Supported Compression Methods

Our API supports the following compression methods via the `Accept-Encoding` header:

* **gzip** (default and recommended)
* **deflate**
* **br** (Brotli)

### Benefits of Compression

1. **Faster Data Transfers:** Smaller payloads reduce the time needed to fetch data, especially for endpoints returning large datasets
2. **Efficient Bandwidth Usage:** Compression minimizes data transfer costs by reducing the volume of data sent over the network
3. **Broad Compatibility:** Widely supported compression methods like gzip ensure compatibility across most HTTP clients
4. **Future-Ready:** Prepares you for upcoming mandatory compression requirements

### Implementation Examples

#### cURL

```bash theme={null}
curl -H "Accept-Encoding: gzip" "https://api.amberdata.com/markets/spot/tickers"
```

#### Python (Requests Library)

```python theme={null}
import requests

url = "https://api.amberdata.com/markets/spot/tickers"
headers = {"Accept-Encoding": "gzip"}
response = requests.get(url, headers=headers)

print(response.content)  # Decompressed content
```

#### JavaScript (Fetch API)

```javascript theme={null}
fetch("https://api.amberdata.com/markets/spot/tickers", {
  headers: { "Accept-Encoding": "gzip" }
})
  .then(response => response.json())
  .then(data => console.log(data));
```

#### Postman

1. Go to the **Headers** tab in your request
2. Add `Accept-Encoding` as the header key and `gzip` as the value
3. Send the request and observe the compressed data being returned

## Query Parameters

Some endpoints have optional query parameters which attach additional data in the response. Below is a comprehensive list of those parameters and their respective responses.

### Validation Method

**Query parameter:** `validationMethod`

All blockchain related endpoints have the option to return the necessary data used to prove the validity of the associated data returned with the response.

| Value  | Description                                                                                                                                                                                            |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| none   | Default. No validation data is returned in the response                                                                                                                                                |
| basic  | Returns validation information about the principal components of a block                                                                                                                               |
| full\* | Returns all of the validation information about the components of a block, and each of its sub-components (transactions and uncles). This allows one to fully verify a block and each of its component |

*Note: Only applies to endpoints that return block data*

#### Example Response: Block Validation

```json theme={null}
{
  "validation": {
    "hash": {
      "data": {
        "difficulty": "2957101900364072",
        "extraData": "0x76697231",
        "gasLimit": "8000029",
        "gasUsed": "7992790",
        "logsBloom": "0x007412...",
        "miner": "0xb2930b35844a230f00e51431acae96fe543a0347",
        "mixHash": "0x1f7cf0...",
        "nonce": "3191105210499409716",
        "number": "7280000",
        "parentHash": "0x215060...",
        "receiptsRoot": "0xbea5cd...",
        "sha3Uncles": "0x1dcc4d...",
        "stateRoot": "0x1e3022...",
        "timestamp": "2019-02-28T19:52:04.000Z",
        "transactionsRoot": "0x4eb851..."
      },
      "value": "0xeddb0590e1095fbe51205a51a297daef7259e229af0432214ae6cb2c1f750750"
    },
    "receiptsRoot": {
      "value": "0xbea5cd80cb9a2264ea6d48320cae033f863592771513ee1addcabb40327db129"
    },
    "sha3Uncles": {
      "value": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
    },
    "stateRoot": {
      "value": "0x1e302241298f913b30f7a0df60272c9983d8d8726932f66582f182bd99ef42bc"
    },
    "transactionsRoot": {
      "value": "0x4eb851a13c63ad37eb8e7ca618cc23987469fc347539689a28484c5d1ccd31d7"
    }
  }
}
```

#### Example Response: Transaction Validation

```json theme={null}
{
  "validation": {
    "hash": {
      "data": {
        "gas": "4436670",
        "gasPrice": "1400000000",
        "input": "0x724ef9...",
        "nonce": "6",
        "to": "0x4459b42d034330ecc1e4d604c0a5c855b857df2c",
        "value": "0",
        "r": "0x1c3cb405d96057e71706761611512d89508e9316fa9999c9d214f0240ac14ba5",
        "s": "0x418f42217acf527bee526c626bd144d0cd4de2529148c165fbbd0ab44d992087",
        "v": "38"
      },
      "value": "0x5c0eac44212b783822d0b725319304b7bc43e81ff0cf7db648a11d096b47598e"
    }
  }
}
```

### Include Price

**Query parameter:** `includePrice`

| Value | Description                       |
| ----- | --------------------------------- |
| true  | Include price data                |
| false | Default. Don't include price data |

Blockchain data endpoints have the option to include price data in the response.

#### Example Response

```json theme={null}
{
  "price": {
    "value": {
      "currency": "usd",
      "quote": "174.623263251",
      "total": "91.24846943967798225000000000000"
    }
  }
}
```

### Currency

*(To be used in conjunction with `includePrice`)*

**Query parameter:** `currency`
**Options:** `usd` `btc` `eth` *(These vary by endpoint)*

| Value | Description           |
| ----- | --------------------- |
| usd   | United States Dollar  |
| btc   | Bitcoin (coming soon) |
| eth   | Ether (coming soon)   |

This option selects the currency type to be returned with the `includePrice` parameter.

#### Example Response

```json theme={null}
{
  "price": {
    "value": {
      "currency": "eth",
      "quote": "174.623263251",
      "total": "91.24846943967798225000000000000"
    }
  }
}
```

### Page Parameter

**Query parameter:** `page`
**Options:** `0 - ∞`

Some endpoints contain the column names in the metadata instead of a `next` field to retrieve the URL of the next page of data. Therefore, you will need to use the `page` parameter to loop through all pages of data returned, which begins at page `0` for all endpoints where this query parameter is available.

## Compression FAQ

### What is the recommended compression method?

We recommend using **gzip**, as it is widely supported and balances speed and compression ratio effectively.

### Will compression impact my API usage limits?

No, enabling compression does not affect your API usage limits. It simply optimizes the data transfer process.

If you encounter any issues while setting up compression, please contact our support team at [support@amberdata.io](mailto:support@amberdata.io).
