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

# Crypto Token Kline data from Binance, all price quote is in USDT

> **Feature Overview**

[OpenAPI JSON Spec](/docs/output/v1_crypto_kline_get.json)
Retrieve K-line (candlestick) chart data for a specified trading pair

**Performance Optimization Features**

This API uses a multi-layer optimization architecture to ensure high performance:

**1. TimescaleDB Materialized Views**
- **Continuous Aggregation**: Automatically pre-compute aggregated data, improving query speed by 10-100x
- **Auto Refresh**: Materialized views are automatically updated to ensure data timeliness

**2. Intelligent Data Source Selection**
- The system automatically selects the optimal data source based on the query time range
- Short-term queries use the raw table, long-term queries use materialized views
- Balances data accuracy and query performance

**Supported Time Intervals**

| Interval | Description | Use Case | Data Source |
|----------|-------------|----------|------------|
| `1min`   | 1-minute K-line | Short-term trading, real-time monitoring | Raw table + real-time calculation |
| `5min`   | 5-minute K-line | Short-term analysis, intraday trading | Materialized view |
| `15min`  | 15-minute K-line | Medium-short-term analysis | Materialized view |
| `1h`     | 1-hour K-line | Intraday swing analysis | Materialized view |
| `1d`     | Daily K-line | Long-term trend, fundamental analysis | Materialized view |

**Parameter Configuration Details**

**Required Parameters:**
- `symbol`: binance supported token symbol, ex: BTC, ETH, SOL.
- `start_time`: Start timestamp (seconds), must be > 0
- `end_time`: End timestamp (seconds), must be > start_time
- `interval`: Time interval, must be one of the supported values

**Time Range Calculation**

```bash
# Get last 24 hours of 1-hour K-line
end_time=$(date +%s)
start_time=$((end_time - 24*3600))

# Get last 7 days of daily K-line
end_time=$(date +%s)
start_time=$((end_time - 7*24*3600))
```

**Response Data Structure**

| Field        | Type    | Description                  | Example                  |
|-------------|---------|------------------------------|--------------------------|
| count        | integer | Number of K-lines returned   | 24                       |
| symbol      | string | token symbol        | "BTC"                        |
| interval     | string  | Time interval                | "1h"                     |
| start_time   | integer | Actual start timestamp       | 1752112043               |
| end_time     | integer | Actual end timestamp         | 1752742043               |
| data         | array   | Array of K-line data         | [KlineData, ...]         |

**Each K-line data item includes:**
- `time`: K-line timestamp
- `open_price`: Opening price
- `high_price`: Highest price
- `low_price`: Lowest price
- `close_price`: Closing price
- `volume`: Trading volume
- `quote_volume`: Quote currency trading volume
- `trades`: Number of trades
- `buy_base_volume`: Active buy trading volume
- `buy_quote_volume`: Active buy quote currency volume

**Common Query Examples**

1. **Real-time 1-hour chart** (last 24 hours):
`?symbol=BTC&start_time=1752112043&end_time=1752742043&interval=1h&limit=24`

2. **Daily K-line chart** (last 30 days):
`?symbol=BTC&start_time=1752112043&end_time=1643587200&interval=1d&limit=30`

3. **Short-term 5-minute chart** (last 4 hours):
`?symbol=BTC&start_time=1641067200&end_time=1752742043&interval=5min&limit=48`

4. **High-frequency 1-minute data** (last 1 hour):
`?symbol=BTC&start_time=1641078000&end_time=1752742043&interval=1min&limit=60`

**Mobile Optimization Suggestions**

- Use a smaller limit value (100-300) to reduce data transfer
- Prefer intervals of 5min or above to reduce data volume
- Implement paginated loading to fetch historical data as needed
- Use WebSocket for real-time updates instead of frequent polling

**Important Notes**

- **Timestamp Format**: Use Unix timestamp (seconds), not milliseconds
- **Price Precision**: Price data is returned as string for precision, convert to numeric type when using
- **Rate Limiting**: Please control request frequency to avoid excessive queries



## OpenAPI

````yaml /api-reference/openapi.json get /v1/crypto/kline
openapi: 3.0.0
info:
  contact: {}
  description: >-
    Welcome to Arrays!


    Arrays is a unified financial data layer for both financial institutions and
    retail users, delivering comprehensive market data across crypto and equity
    markets. Our datasets cover fundamentals, ETFs, options, crypto, and more.


    Visit [arrays.org](https://arrays.org) to request an API key and start your
    free trial. You can explore our full API offerings in the documentation
    below.


    For any questions regarding APIs or pricing, please contact
    support@arrays.org.
  title: Arrays API
  version: '1.0'
servers:
  - url: https://data-tools.prd.arrays.org/api
security: []
paths:
  /v1/crypto/kline:
    get:
      tags:
        - Crypto
      summary: Crypto Token Kline data from Binance, all price quote is in USDT
      description: >-
        **Feature Overview**


        [OpenAPI JSON Spec](/docs/output/v1_crypto_kline_get.json)

        Retrieve K-line (candlestick) chart data for a specified trading pair


        **Performance Optimization Features**


        This API uses a multi-layer optimization architecture to ensure high
        performance:


        **1. TimescaleDB Materialized Views**

        - **Continuous Aggregation**: Automatically pre-compute aggregated data,
        improving query speed by 10-100x

        - **Auto Refresh**: Materialized views are automatically updated to
        ensure data timeliness


        **2. Intelligent Data Source Selection**

        - The system automatically selects the optimal data source based on the
        query time range

        - Short-term queries use the raw table, long-term queries use
        materialized views

        - Balances data accuracy and query performance


        **Supported Time Intervals**


        | Interval | Description | Use Case | Data Source |

        |----------|-------------|----------|------------|

        | `1min`   | 1-minute K-line | Short-term trading, real-time monitoring
        | Raw table + real-time calculation |

        | `5min`   | 5-minute K-line | Short-term analysis, intraday trading |
        Materialized view |

        | `15min`  | 15-minute K-line | Medium-short-term analysis |
        Materialized view |

        | `1h`     | 1-hour K-line | Intraday swing analysis | Materialized view
        |

        | `1d`     | Daily K-line | Long-term trend, fundamental analysis |
        Materialized view |


        **Parameter Configuration Details**


        **Required Parameters:**

        - `symbol`: binance supported token symbol, ex: BTC, ETH, SOL.

        - `start_time`: Start timestamp (seconds), must be > 0

        - `end_time`: End timestamp (seconds), must be > start_time

        - `interval`: Time interval, must be one of the supported values


        **Time Range Calculation**


        ```bash

        # Get last 24 hours of 1-hour K-line

        end_time=$(date +%s)

        start_time=$((end_time - 24*3600))


        # Get last 7 days of daily K-line

        end_time=$(date +%s)

        start_time=$((end_time - 7*24*3600))

        ```


        **Response Data Structure**


        | Field        | Type    | Description                  |
        Example                  |

        |-------------|---------|------------------------------|--------------------------|

        | count        | integer | Number of K-lines returned   |
        24                       |

        | symbol      | string | token symbol        |
        "BTC"                        |

        | interval     | string  | Time interval                |
        "1h"                     |

        | start_time   | integer | Actual start timestamp       |
        1752112043               |

        | end_time     | integer | Actual end timestamp         |
        1752742043               |

        | data         | array   | Array of K-line data         | [KlineData,
        ...]         |


        **Each K-line data item includes:**

        - `time`: K-line timestamp

        - `open_price`: Opening price

        - `high_price`: Highest price

        - `low_price`: Lowest price

        - `close_price`: Closing price

        - `volume`: Trading volume

        - `quote_volume`: Quote currency trading volume

        - `trades`: Number of trades

        - `buy_base_volume`: Active buy trading volume

        - `buy_quote_volume`: Active buy quote currency volume


        **Common Query Examples**


        1. **Real-time 1-hour chart** (last 24 hours):

        `?symbol=BTC&start_time=1752112043&end_time=1752742043&interval=1h&limit=24`


        2. **Daily K-line chart** (last 30 days):

        `?symbol=BTC&start_time=1752112043&end_time=1643587200&interval=1d&limit=30`


        3. **Short-term 5-minute chart** (last 4 hours):

        `?symbol=BTC&start_time=1641067200&end_time=1752742043&interval=5min&limit=48`


        4. **High-frequency 1-minute data** (last 1 hour):

        `?symbol=BTC&start_time=1641078000&end_time=1752742043&interval=1min&limit=60`


        **Mobile Optimization Suggestions**


        - Use a smaller limit value (100-300) to reduce data transfer

        - Prefer intervals of 5min or above to reduce data volume

        - Implement paginated loading to fetch historical data as needed

        - Use WebSocket for real-time updates instead of frequent polling


        **Important Notes**


        - **Timestamp Format**: Use Unix timestamp (seconds), not milliseconds

        - **Price Precision**: Price data is returned as string for precision,
        convert to numeric type when using

        - **Rate Limiting**: Please control request frequency to avoid excessive
        queries
      parameters:
        - description: 'Crypto token symbol, ex: BTC, ETH, SOL'
          in: query
          name: symbol
          required: true
          schema:
            type: string
        - description: Start time (Unix timestamp in seconds, must be > 0)
          in: query
          name: start_time
          required: true
          schema:
            type: integer
        - description: End time (Unix timestamp in seconds, must be > start_time)
          in: query
          name: end_time
          required: true
          schema:
            type: integer
        - description: Time interval for K-line data
          in: query
          name: interval
          required: true
          schema:
            type: string
            enum:
              - 1min
              - 2min
              - 3min
              - 5min
              - 10min
              - 15min
              - 30min
              - 45min
              - 1h
              - 2h
              - 4h
              - 6h
              - 8h
              - 12h
              - 1d
              - 3d
              - 1w
              - 1m
              - 3m
              - 6m
        - description: Cursor for pagination
          in: query
          name: cursor
          schema:
            type: string
        - description: Maximum number of data points to return (default 500, max 10000)
          in: query
          name: limit
          schema:
            type: integer
      responses:
        '200':
          description: Successfully retrieved K-line data
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/model.APIResponse'
                  - properties:
                      data:
                        $ref: '#/components/schemas/model.GetKlineDataResponse'
                    type: object
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/model.APIResponse'
                  - properties:
                      data:
                        $ref: '#/components/schemas/model.APIError'
                    type: object
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/model.APIResponse'
                  - properties:
                      data:
                        $ref: '#/components/schemas/model.APIError'
                    type: object
      security:
        - ApiKeyAuth: []
components:
  schemas:
    model.APIResponse:
      properties:
        data: {}
        error:
          $ref: '#/components/schemas/model.APIError'
        metadata: {}
        pagination: {}
        request_id:
          type: string
        success:
          type: boolean
      type: object
    model.GetKlineDataResponse:
      properties:
        count:
          description: The number of data points returned in this response
          type: integer
        cursor:
          type: string
        data:
          items:
            $ref: '#/components/schemas/model.KlineData'
          type: array
      type: object
    model.APIError:
      properties:
        code:
          example: RESOURCE_NOT_FOUND
          type: string
        details:
          items:
            $ref: '#/components/schemas/model.APIErrorDetail'
          type: array
        docs_url:
          type: string
        examples:
          items:
            type: string
          type: array
        hint:
          type: string
        message:
          example: The requested resource was not found.
          type: string
        suggestions:
          items:
            type: string
          type: array
      type: object
    model.KlineData:
      properties:
        price_close:
          type: number
        price_high:
          type: number
        price_low:
          type: number
        price_open:
          type: number
        time_close:
          type: integer
        time_open:
          type: integer
        time_period_end:
          type: string
        time_period_start:
          type: string
        trades_count:
          type: integer
        volume_traded:
          type: number
      type: object
    model.APIErrorDetail:
      properties:
        field:
          type: string
        got:
          type: string
        reason:
          type: string
      type: object
  securitySchemes:
    ApiKeyAuth:
      description: 'API Key authentication. Example: "your-api-key-here"'
      in: header
      name: X-API-Key
      type: apiKey

````