Skip to content

TOKEN_API_OHLC_LIMIT_CAP_100 and TOKEN_API_OHLC_DUPES: combined OHLC pain #522

@chillsauce

Description

@chillsauce
  • /v1/evm/pools/ohlc?limit=N is hard-capped at 100. limit=540 returns 403 forbidden. The cap is undocumented in the OpenAPI schema, which advertises integer with no maximum.
  • The endpoint returns up to 4-8x duplicate rows per datetime. Routinely observed: “100 rows returned, only 13-25 distinct datetimes.”

Combined effect. A request for 100 daily bars can yield as few as 13 unique days. Not enough for a 1M chart, let alone 3M.

Workaround applied. Discovered (via experimentation, since it is undocumented) that ?page=N is supported. The build now fans out 4 parallel page fetches and dedupes across pages by datetime, spanning approximately 100 unique days. Functional, but 4x the request count for the same logical query.

Reproduction.

curl "https://token-api.thegraph.com/v1/evm/pools/ohlc?network=mainnet&pool=0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640&interval=1d&limit=100" \
  -H "Authorization: Bearer$TOKEN" | jq '.data | length, ([.[].datetime] | unique | length)'
# 100, 25

Proposed changes.

  1. Server-side dedup: pick the canonical bar per (pool, datetime) tuple, return one row per datetime. Cuts request count by 4x.
  2. Raise the limit cap to 1000 for chart-friendly windows. Document it in OpenAPI.
  3. Document ?page=N in OpenAPI and the API reference.
  4. Hourly OHLC currently caches the latest incomplete bar’s close so it does not update between hour boundaries even when swaps happen. This forced the Lodestar build to skip Token API for live spot pricing entirely (Uniswap V3 subgraph’s derivedETH is used instead). Either reduce the cache TTL on the current incomplete bar, or expose an explicit latest_swap_price field.

Effort estimate. Small for dedup, cap, and documentation. The cache TTL is a config change.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions