Skip to main content

K-Line API — Introduction

Service overview

Service overview

The K-Line API is a K-line data service. It provides these core capabilities:

  • Query historical OHLCV candlestick data for a pool
  • Dynamically subscribe to real-time K-line updates through WebSocket
  • Query market data, top holders, and token metadata

All HTTP APIs are mounted under the /kline/api/v1 prefix. Public endpoints use the X-API-Key request header for API authentication and billing identification.


Base URL

Use the following production host as the root path for all API requests:

https://api.gelabs.org

Example:

curl -H "X-API-Key: $API_KEY" "https://api.gelabs.org/kline/api/v1/kline/ohlcv?interval=1h&from=1776679200&to=1776765600&chain_type=evm&chain_id=1&pool_address=0xabc123def456"

Unified response shape

Most successful HTTP APIs return:

{
"code": 0,
"message": "ok",
"data": {}
}
FieldTypeAlways returnedDescription
codeintegerYesBusiness status code. 0 means success.
messagestringYesResponse message. Successful responses use ok.
dataobject / array / stringYesBusiness payload. Shape depends on the endpoint.

Failed responses usually look like:

{
"code": 10001,
"message": "Invalid query params",
"error": {
"type": "ValidationError",
"details": {
"formErrors": [],
"fieldErrors": {
"chain_type": ["String must contain at least 1 character(s)"]
}
}
}
}

Error codes

CodeMeaningCommon trigger
0SuccessNormal response
10001Validation failedInvalid query, path, or body fields
10002Invalid argumentValue violates business rules
10003Resource not foundUnknown route or resource
10004Resource conflictCreating a duplicate pool
10005Bad requestWebSocket preflight or malformed request
20001UnauthenticatedReserved, currently not enabled
20002ForbiddenReserved, currently not enabled
60001K-line resource not foundQuerying a missing pool
60002K-line sync failedReserved
60003Invalid symbolReserved
60004Invalid intervalReserved
99001Internal server errorUncaught exception, service error, or rate limit
99002Database errorReserved
99003Cache errorReserved

Common conventions

ItemDescription
Common request headerAll public endpoints require X-API-Key for API authentication and billing identification.
Content-TypePOST bodies use application/json; WebSocket messages use JSON text frames.
TimestampsHTTP query parameters from and to accept Unix seconds or milliseconds. Values greater than 10000000000 are treated as milliseconds.
Chain typechain_type is normalized to lowercase. Common aliases include eth/ethereumevm, sol/solanasvm, trx/trontvm, btc/bitcoinutxo, atomcosmos, and sui/aptos/aptmove.
Token sidetoken supports base and quote; default is base.
K-line intervalsSupported intervals are 1s, 1m, 15m, 1h, 4h, 1d, 1w, 1M, and 1Y. 1w, 1M, and 1Y are aggregated from 1d data.
PaginationRequest fields use page and page_size; response pagination uses page, pageSize, total, and totalPages.
CacheHTTP query APIs do not currently promise a fixed Cache-Control policy. After a WebSocket subscription succeeds, the server may send the latest in-memory snapshot.

Note: 1w, 1M, and 1Y are queried by aggregating persisted 1d candles.


Integration flow

Recommended integration steps:

  1. Call GET /kline/api/v1/kline/ohlcv to query historical K-line data.
  2. Connect to GET /kline/api/v1/kline/ws and subscribe to real-time updates.