# Miscellaneous

## Get Token Pairs

<mark style="color:blue;">`GET`</mark> `/api/get_token_pairs`

Get available trading pairs with metadata on available exchanges

| Name         | Type   | Description                                                                                         |
| ------------ | ------ | --------------------------------------------------------------------------------------------------- |
| market\_type | string | \[Optional] [MarketType](/interacting-with-the-api/api-reference/type-reference.md#markettype-enum) |

**Response**

{% tabs %}
{% tab title="200" %}

````json
```json
{
    "pairs": {
        "JFI-USDC": {
            "OKX": "JFI-USDC",
            "MockExchange": "JFI-USDC"
        },
        "SHIBI-USDT": {
            "Bybit": "SHIBIUSDT"
        },
        "ICX-USDC": {
            "OKX": "ICX-USDC",
            "MockExchange": "ICX-USDC"
        },
        ...
    }
}
```
````

{% endtab %}

{% tab title="400" %}

````json
```json
{
    "message": "Error message"
}
```
````

{% endtab %}

{% tab title="500" %}

```
{
    "error": "Internal server error"
}
```

{% endtab %}
{% endtabs %}

## Get Order Book

<mark style="color:blue;">`GET`</mark> `/api/get_order_book`

Get snapshot of order book from exchange

| Name                                             | Type   | Description                                                                                                           |
| ------------------------------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------- |
| pair<mark style="color:red;">\*</mark>           | string | name of [trading pair](/creating-and-submitting-orders/advanced-settings/order-templates/pair-naming.md)              |
| exchange\_name<mark style="color:red;">\*</mark> | string | name of supported [exchange](/account-creation-and-api-key-connection/connecting-to-exchanges.md#supported-exchanges) |

**Response**

{% tabs %}
{% tab title="200" %}

````json
```json
{
    "bids": [
        {
            "price": 100425.3,
            "size": 550.82
        },
        ...
    ],
    "asks": [
        {
            "price": 100425.4,
            "size": 562.54
        },
        ...
    ]
}
```
````

{% endtab %}

{% tab title="400" %}

````json
```json
{
    "message": "Error message"
}
```
````

{% endtab %}

{% tab title="500" %}

```
{
    "error": "Internal server error"
}
```

{% endtab %}
{% endtabs %}

## Get Order Form Data

<mark style="color:blue;">`GET`</mark> `/api/order_form_data`

Data that is likely needed for an order form on the UI

**Response**

{% tabs %}
{% tab title="200" %}

<pre class="language-json"><code class="lang-json">```json
{
    "accounts": [
        {
            "id": "b77d27fc-27d2-43a6-8ffc-ce6717097b11",
            "name": "blockchain_test_bybit",
            "user": 13,
            "username": "integ_test",
            "exchange": "Bybit",
            "hashed_api_key": "71744a6a0f3178224c8b245dac64a0d1ca1dd1dd39b7aa79875488816f9fd5fa",
            "valid": true,
            "authorized_groups": [],
            "margin_mode": "CROSS",
            "created_at": "2024-12-18T08:03:53.399795Z",
            "credential_options": {},
            "api_key": "KAM7Tm2k7LBuqjy8gK",
            "api_secret": "********************",
            "password": "********************"
        },
        ...
    ]
    "exchanges": [
        "Binance",
        "Bybit",
        "Deribit",
        "OKX",
        "Gate",
    ],
    "user_id": 13,
    "pairs": [
        {
            "name": "0DOG-USDT",
            "base": "0DOG",
            "quote": "USDT",
            "market_type": "spot",
            "is_inverse": false,
            "is_contract": false,
            "exchanges": [
                "Gate"
            ]
        },
        ...
    ],    
<strong>    "strategies": [
</strong>        {
            "id": "a1e31843-cb6c-46aa-bca7-6216ef5739d8",
            "name": "VWAP",
            "params": {},
            "engine_passiveness": "0.10000000000000000555",
            "schedule_discretion": "0.08000000000000000167",
            "alpha_tilt": null,
            "strategy_params": {},
            "system": true,
            "schedule": "VWAP",
            "description": "Volume Weighted Average Price",
            "user": "admin"
        },
        ...
    ],
    "super_strategies": [
        {
            "id": "d960c28f-a6bd-4f55-9c5c-fc561cc95640",
            "strategy_id": "a1e31843-cb6c-46aa-bca7-6216ef5739d8",
            "name": "Impact Minimization",
            "presets": {
                "notes": null,
                "duration": 300,
                "discretion": 0.08,
                "limitPrice": null,
                "orderCondition": null
            },
            "is_super_strategy": true
        },
        ...
    ],
   "strategy_params": [
        "passive_only",
        "active_limit",
        "reduce_only",
        "strict_duration",
        "spot_leverage",
        "max_clip_size"
    ],
    "order_templates": [
        {
            "id": "94e5a389-90c2-4edc-9c24-b6a58350b7e9",
            "user_id": 13,
            "name": "pov",
            "values": {
                "pair": {
                    "id": "ETH:PERP-USDT",
                    "base": "ETH",
                    "label": "ETH:PERP-USDT",
                    "quote": "USDT",
                    "exchanges": [
                        "OKX",
                        "Deribit",
                        "Binance",
                        "Bybit",
                        "MockExchange"
                    ],
                    "is_inverse": false,
                    "is_contract": true,
                    "market_type": "perp"
                },
                "side": "buy",
                "accounts": [
                    "test_okx"
                ],
                "strategy": "a1e31843-cb6c-46aa-bca7-6216ef5739d8",
                "pov_target": "5",
                "base_asset_qty": "5",
                "super_strategy": "d960c28f-a6bd-4f55-9c5c-fc561cc95640",
                "strategy_params": {
                    "ool_pause": false
                },
                "engine_passiveness": 0.02,
                "schedule_discretion": 0.08
            },
            "created_at": "2024-06-23T21:37:27.825932Z"
        },
        ...
    ],
    "auto_order_urgencies": [
        {
            "key": "ULTRA_LOW",
            "name": "Very Low"
        },
        {
            "key": "LOW",
            "name": "Low"
        },
        {
            "key": "MEDIUM",
            "name": "Medium"
        },
        {
            "key": "HIGH",
            "name": "High"
        },
        {
            "key": "ULTRA_HIGH",
            "name": "Very High"
        }
    ]
}
```
</code></pre>

{% endtab %}

{% tab title="500" %}

```json
{
    "error": "Internal server error"
}
```

{% endtab %}
{% endtabs %}

## Validate Order Condition

<mark style="color:green;">`POST`</mark> `/api/validate_order_condition/`

Validate the correctness of the order condition syntax

| Name             | Type   | Description                                                                                         |
| ---------------- | ------ | --------------------------------------------------------------------------------------------------- |
| order\_condition | string | Refer to [Conditional Order](/creating-and-submitting-orders/advanced-settings/order-conditions.md) |

**Response**

{% tabs %}
{% tab title="200" %}

````json
```json
{
    "order_condition": "( ETH-USDT@Binance - ETH:PERP-USDT@Binance ) > 1",
    "order_condition_vars": {},
    "postfix_condition": "ETH-USDT@Binance ETH:PERP-USDT@Binance - 1 >",
    "is_valid": true
}
```
````

{% endtab %}

{% tab title="400" %}

````json
```json
{
    "error": "Error message",
    "is_valid": false
}
```
````

{% endtab %}

{% tab title="500" %}

```json
{
    "error": "Internal server error"
}
```

{% endtab %}
{% endtabs %}

## Get Funding Rate

<mark style="color:blue;">`GET`</mark> `/internal/marketdata/get_funding_rates`

Returns current funding rates for perpetual futures contracts across all supported exchanges.

#### Response Body

| Field Name              | Type             | Nullable | Purpose                                                                                                                                                                                                    |
| ----------------------- | ---------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `exchange_pair`         | string           | No       | Unique identifier combining exchange and pair (e.g., "Binance#BTC", "Hyperliquid#ZETA"). Format: "{Exchange}#{BaseToken}"                                                                                  |
| `last_updated`          | string (integer) | Yes      | Timestamp when the funding rate was last updated, in milliseconds since epoch (UTC). This field may be absent for funding rates sourced from perp DEX exchanges (Paradex, Pacifica, Hyperliquid, Extended) |
| `funding_rate_interval` | string (integer) | No       | Funding rate interval in hours (decimal as string). Common values: "1" (hourly), "4" (every 4 hours), "8" (every 8 hours). Indicates how frequently the funding rate is applied                            |
| `exchange`              | string           | No       | Name of the exchange (e.g., "Binance", "Bybit", "OKX", "Bitget", "Hyperliquid", "Paradex", "Pacifica", "Extended")                                                                                         |
| `pair`                  | string           | No       | Base token symbol for the perpetual futures contract (e.g., "BTC", "ETH", "SOL", "ZETA")                                                                                                                   |
| `rate`                  | string (decimal) | No       | Current funding rate as a percentage (decimal as string). Positive values indicate longs pay shorts; negative values indicate shorts pay longs. Example: "0.01" = 1%, "-0.00609876" = -0.609876%           |

{% tabs %}
{% tab title="200" %}

```json
[
  {
    "exchange_pair": "Hyperliquid#ZETA",
    "last_updated": "1769078595325",
    "funding_rate_interval": "1",
    "exchange": "Hyperliquid",
    "pair": "ZETA",
    "rate": "-0.00609876"
  },
  ...
  {
    "exchange_pair": "Extended#TRUMP",
    "rate": "0.000000",
    "funding_rate_interval": "1",
    "pair": "TRUMP",
    "exchange": "Extended"
  }
]
```

{% endtab %}
{% endtabs %}

#### Notes

1. **Rate Format:** The `rate` field is returned as a string (decimal) to preserve precision. The value represents a percentage (e.g., "0.01" = 1%, not 0.01%).
2. **Funding Rate Intervals:** Different exchanges apply funding rates at different intervals:
   * Hourly (interval = "1"): Common for DEX exchanges like Hyperliquid, Paradex, Pacifica, Extended
   * Every 4 hours (interval = "4"): Common for Binance, Bitget, Bybit
   * Every 8 hours (interval = "8"): Common for OKX, Bybit, Bitget for certain pairs
3. **Rate Direction:**
   * Positive rates: Long positions pay funding fees to short positions
   * Negative rates: Short positions pay funding fees to long positions
4. **Caching:** This endpoint is cached for 300 seconds (5 minutes) to reduce load on the funding rate oracle.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tread.fi/interacting-with-the-api/api-reference/miscellaneous.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
