Skip to content

coins: mark decimals optional and document confidence#15

Merged
waynebruce0x merged 1 commit into
mainfrom
waynebruce0x/coins-spec-decimals-confidence
Apr 23, 2026
Merged

coins: mark decimals optional and document confidence#15
waynebruce0x merged 1 commit into
mainfrom
waynebruce0x/coins-spec-decimals-confidence

Conversation

@waynebruce0x

Copy link
Copy Markdown

Summary

Bring the spec in line with what the coins API actually returns today.

  • Mark decimals optional on /prices/current, /prices/historical, and /chart responses (coingecko-native assets like coingecko:ethereum legitimately omit it).
  • Add confidence (number, 0–1) to /prices/current and /prices/historical response schemas — prod has returned this for a long time but it wasn't documented.
  • /chart already had confidence — added matching description for parity.
  • Mirrored all three changes in the pro spec under /coins/*.

Diff shape

+34 insertions, 0 deletions across both files. No reformatting — only the new required arrays, the new confidence property, and descriptions. JSON validates.

Why now

While building a live spec-compliance test suite against coins.llama.fi I found two systematic mismatches that caused test failures:

  • Test for typeof decimals === "number" failed on coingecko-native batches
  • Test for the presence of confidence had no schema to compare against

Both are code-behaves-correctly-but-spec-is-wrong cases. This PR fixes the spec side only. Undocumented endpoints in coins/serverless.yml (/mcaps, /chains, POST /prices, etc.) are intentionally not covered here.

Test plan

  • Render in Scalar and eyeball the three endpoints' response panels
  • Confirm examples still display as expected
  • Downstream consumer: regenerate TS types from the spec and confirm confidence shows up on the right shapes

🤖 Generated with Claude Code

Live responses on api.llama.fi and coins.llama.fi return `confidence` on
price entries today, and coingecko-native assets (e.g. coingecko:ethereum)
legitimately omit `decimals`. The schema did not reflect either, so clients
generating types from the spec were either missing `confidence` or
erroneously treating coingecko coins as malformed.

- `/prices/current/{coins}`, `/prices/historical/{timestamp}/{coins}`,
  `/chart/{coins}`: add explicit `required` arrays marking decimals optional
- `/prices/current` and `/prices/historical`: add `confidence` property
- `/chart`: already had `confidence` — add matching description
- Mirror the same three changes in the pro spec under /coins/*

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying api-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: d29435c
Status: ✅  Deploy successful!
Preview URL: https://63be42af.api-docs-59g.pages.dev
Branch Preview URL: https://waynebruce0x-coins-spec-deci.api-docs-59g.pages.dev

View logs

@waynebruce0x waynebruce0x marked this pull request as ready for review April 23, 2026 11:09
@waynebruce0x waynebruce0x merged commit 0bf9c31 into main Apr 23, 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