Skip to content

docs: lead with the Trading cube, and add a one-page API reference for AI assistants - #251

Merged
buddies2705 merged 3 commits into
mainfrom
docs/starter-panel-trading-cube
Aug 27, 2026
Merged

docs: lead with the Trading cube, and add a one-page API reference for AI assistants#251
buddies2705 merged 3 commits into
mainfrom
docs/starter-panel-trading-cube

Conversation

@buddies2705

Copy link
Copy Markdown
Contributor

Follow-on to #250. The Trading-cube commit missed that merge by minutes#250 merged at 06:29:55Z and 6ff5aa87 was pushed after, so it is on the old branch but not in main. It is cherry-picked here as the first commit.

1. Lead with the Trading cube (cherry-picked, was not in #250)

The docs already say Trading.Pairs / Tokens / Currencies are the primary source for real time and the last ~30 days, with DEXTrades and DEXTradeByTokens for history beyond that. The panel did the opposite:

  • 225 of 367 trade and price entries led with a DEX cube.
  • On Ethereum, Base, Arbitrum, BSC and TRON, a DEX-cube query was the first thing under Price & OHLC.
  • 0 of 31 shipped Pairs queries used Ranking: {Position: {eq: 1}} — none of the pattern the docs recommend for pricing one token, since the Tokens price is volume-blended across every pool.

Now: Trading entries sort first, 92 DEX entries are relabelled — historical (beyond 30 days), 195 tooltips say which side they are on, and rank-1 price queries lead Price & OHLC on Ethereum, Base, BSC, Arbitrum, Optimism and Solana.

Two traps found while authoring those, now written into the query comments:

  • Trading token addresses are stored lowercase and the filter is case-sensitive. A checksummed EVM address returns zero rows and no error. WETH, WBNB and Arbitrum WETH all silently returned nothing until lowercased.
  • Choosing the example token by "top volume" surfaced obscure tokens and, on Solana, a homoglyph spoof of SOL (SoJh2C73…, Cyrillic О). The examples use canonical addresses.

Balances: 16 chains lacked a current or historical balance query. Authored and verified 11 — gap down to 7.

Ordering: groups now lead with Bitcoin, Solana, Robinhood, Polymarket, Perpetuals, TRON, Cross-Chain, Ethereum, BSC. Perpetuals is split by venue.

2. New page — Bitquery in One Page

docs/start/bitquery-for-ai.md. We publish llms.txt (an index of links) and llms-full.txt (5 MB, the whole corpus). Neither lets you hand an AI one thing and get correct queries out. This page is self-contained: no links to follow, every query written out.

Endpoints and auth for V2 HTTP / V2 WebSocket / V1 · exactly which chains are on V2 versus V1-only · the cube list per root from schema introspection · datasets and retention · nine worked queries · an error table.

Section 6 is the important part for a model — the mistakes that produce a plausible wrong answer instead of an error: lowercase address filters, balances being cumulative, bare EVM meaning Ethereum, unbounded V1 queries hitting Code: 241, realtime silently truncating rather than erroring, and Pairs + rank 1 over Tokens.

All nine example queries were executed against the live API before publishing.

Third in the Start sidebar, first link in llms.txt. The artefact to paste into a model is the raw twin at /docs/start/bitquery-for-ai/index.md.

Verification

gate result
play-link slug + tooltip on every entry pass
slug resolves, not deleted, not unpublished pass
zero BalanceUpdates pass
entry on the chain its group claims pass
stored endpoint matches query dialect pass
no duplicate titles in a group + tab pass
every entry executed live pass
no unexplained drops vs the original 298 pass
trading-policy audit (1,046 entries) 0 problems
Docusaurus production build success

All 65 queries authored across this work were re-executed read back out of the database, not from the pre-insert test: 59 run, 6 retired (Bitcoin SV, index stopped 2026-02-02), 0 failing.

Known gaps

  • 7 chains still lack a current or historical balance query; five templates need schema fixes (Ripple balances argument, Algorand selections, Cardano 500) or a representative address (Robinhood, Avalanche).
  • Solana's historical balance query exists but is filed under Transfers, so the audit reads Solana as missing one.
  • 98 of 137 DEX-cube price entries belong to other people's accounts, so the "use the Trading cube for recent data" note is in their tooltips rather than their query text.

🤖 Generated with Claude Code

Gaurav Agarwal and others added 3 commits August 27, 2026 13:04
Trading cube first. The docs already say Trading.Pairs / Tokens / Currencies
are the primary source for real-time and the last ~30 days, with DEXTrades and
DEXTradeByTokens for history beyond that -- but the panel did the opposite:
225 of 367 trade and price entries led with a DEX cube, and on Ethereum, Base,
Arbitrum, BSC and TRON a DEX-cube query was the first thing under Price & OHLC.
Trading-cube entries now sort first, 92 DEX-cube entries are relabelled
"historical (beyond 30 days)", and 195 tooltips say which side they are on.

Pairs + rank 1. Zero of the 31 shipped Pairs queries used
`Ranking: {Position: {eq: 1}}`, so we shipped none of the pattern the docs
recommend for pricing one token -- the Tokens price is volume-blended across
every pool. Added the three documented rank-1 queries and authored one per
chain for Ethereum, Base, BSC, Arbitrum, Optimism and Solana, each now the
first entry in its Price & OHLC section.

Two traps found while authoring these, both now in the query comments:
Trading.Token.Address is stored lowercase and the filter is case-sensitive, so
a checksummed address returns zero rows and no error; and picking the example
token by "top volume" surfaced obscure tokens and, on Solana, a homoglyph spoof
of SOL -- the examples are canonical addresses instead.

Balances. Balance is the question every chain gets asked, current and
historical. 16 chains were missing one or both; authored and verified 11 new
queries (current balance on Base, Arbitrum, Optimism, Polygon; balance at a
past date on Bitcoin, Dogecoin, Litecoin, Bitcoin Cash, Dash, Zcash, Celo),
taking the gap from 16 chains to 7.

Group order now leads with Bitcoin, Solana, Robinhood, Polymarket, Perpetuals,
TRON, Cross-Chain, Ethereum, BSC. Perpetuals is split by venue -- Hyperliquid
and Phoenix -- since that is how people browse it.

663 query entries across 28 groups, 383 stream entries across 17. All audit
gates pass and the site builds with no warnings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
New page: docs/start/bitquery-for-ai.md, "Bitquery in One Page".

We already publish llms.txt (a curated index of links) and llms-full.txt (the
whole corpus, 5 MB). Neither answers "give an AI one thing and let it write
correct queries": the index makes it fetch twenty pages, and the corpus is too
big and mostly navigation. This page is self-contained instead -- no links to
follow, every query written out in full.

Covers the endpoints and auth for V2 HTTP, V2 WebSocket and V1; exactly which
chains are on V2 (eth, bsc, base, arbitrum, optimism, matic, robinhood, plus
Solana, Tron and Hyperliquid) versus V1-only; the cube list per root, taken
from schema introspection; datasets and retention; and nine worked queries.

Section 6 is the part that matters most for a model, because these are the
mistakes that yield a plausible wrong answer rather than an error:

- Trading cube token addresses are stored lowercase and the filter is
  case-sensitive, so a checksummed address returns zero rows and no error.
- Balances are cumulative, so a realtime balance is a few hours of delta.
- A bare EVM root means Ethereum.
- V1 list queries without a date bound die on ClickHouse Code 241.
- realtime does not error past its retention window, it just returns less.
- Price one token with Pairs + rank 1, not with Tokens.

All nine example queries were executed against the live API before publishing.

Placed third in the Start sidebar and linked first in llms.txt, so the raw
markdown twin at /docs/start/bitquery-for-ai/index.md is the thing to paste
into a model.

Also splits Perpetuals cleanly by venue: two "Solana perps" queries were
sitting in an "Other venues" bucket, but Phoenix is the only Solana perp DEX
we index, so they are Phoenix queries that never say the word.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Auditing the page I had just written turned up a claim I got wrong. It said
"V1 has no subscriptions". Introspecting the V1 schema shows a subscription
root does exist -- ethereum(network: EthereumNetwork) -- so the blanket
statement is false. What is actually true, and now what the page says: there is
no documented V1 WebSocket endpoint, so V2 is the answer for anything live, and
the chains outside the V1 EVM family (Bitcoin and relatives, Cardano, Ripple,
Stellar, Algorand) genuinely have no GraphQL stream.

Adds two facts a model needs and cannot infer:

- Ethereum, BSC, Tron and Polygon are migrating off V1, so they should always
  be queried on V2 even though the V1 schema still accepts them.
- Root capitalisation carries the version. V1 roots are lowercase --
  ethereum(, tron(, solana(, bitcoin( -- and V2 roots are capitalised --
  EVM(, Tron(, Solana(, Trading. A lowercase root means a V1 document.

That last one is not cosmetic: an audit script of mine matched roots
case-insensitively and reported 20 false V1 violations on Tron, all of which
were ordinary V2 Tron( queries.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@buddies2705
buddies2705 merged commit 11363d5 into main Aug 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant