HodlOdds API
Pay with an API key
The same routes, answers and prices as pay-per-request, paid from a prepaid USDC balance with an API key instead of an x402 payment on every request.
https://api.hodlodds.comAuthorization: Bearer <key>- Prepaid USDC on Solana
- Same prices as x402
- Refusals are free
On this page
Get a key
Sign in with a Solana wallet
Sign in on hodlodds.com with your wallet. Signing in signs a short text message, not a transaction. Your first sign-in creates your account, with a balance of 0 USDC.
Add USDC from a wallet
Add USDC on Solana from a wallet on the website: it builds the transfer and your wallet signs it, in the browser or on your phone by scanning a QR code. Each transfer carries a payment reference made for your account, which is how it is credited to you, so there is no address to copy: USDC sent by hand carries no reference and is not credited automatically. Only USDC is credited, once the transfer is finalized. Transfers are read about once a minute; Check deposits on your account page (
POST /account/deposits/check) reads them right away, at most once every 15 seconds.Create a key
Create a key on your account page and copy it at once: it is shown only this one time. Only a digest of the key is kept, so a lost key cannot be shown again; create a new one and revoke the old one. You may give a key a label, an expiry date up to 365 days ahead and a daily spending cap in USDC.
Call the API
Send the key with each request to the same
/v1routes as pay-per-request. Paid answers are charged to your balance.
Send the key
The base URL is https://api.hodlodds.com, the same as pay-per-request. Send the key as a bearer token (RFC 6750):
Authorization: Bearer <key>
A request carries either a key or an x402 payment, not both: a key sent together with an x402 payment gets 400 with code conflicting_credentials. With a key, a paid answer is charged to your balance and there is no payment to sign. A paid request with neither gets the x402 payment challenge described on the pay-per-request track. Free routes ignore the Authorization header.
A key that is malformed, unknown, expired or revoked gets 401 with code invalid_key and a WWW-Authenticate header; it never falls back to x402. Any other Authorization scheme on a paid route also gets 401, with code invalid_request. Neither is charged. A request with another scheme that also carries an x402 payment or redeem header or a partner key is the exception: its Authorization header is not read, and the request is handled as one without a key.
Keys are charged only while the paid API is open, that is while /v1/meta shows public_beta: true; its prepaid member lists the prices, the test credit and the rate limit. While it is false, a paid route answers 503 to a key too, and nothing is charged.
Routes and prices
| Route | With a key |
|---|---|
GET /v1/risk/{mint} | $0.01 USDC per answer |
GET /v1/risk/{mint}/last | $0.002 USDC per answer |
GET /v1/board | $0.005 USDC per delivered row; an empty board is free |
GET /v1/status, /v1/meta, /v1/coverage/{mint}, /v1/markets, /v1/board/delayed | Free; no key needed |
These are the pay-per-request prices. Only a delivered answer (HTTP 200) is charged; refusals and an empty board are free. The most a call can cost is held before the call and settled after it, so calls made at the same time cannot spend the same balance. A board call is charged for the rows it delivers.
Parameters, answers and freshness rules do not change with a key: each route above links to its part of the endpoint reference, and How to read a score explains the numbers.
Balance and test credit
Deposits add to your balance and paid answers take from it. Your account page lists every movement: deposits, the test credit and each paid call with its request id.
Your account's first key brings a one-time test credit of $0.10, which is 10 fresh odds at today's price. It is spent before your balance. The number of test credits granted each UTC day is capped. An account whose first key comes after that day's test credits have run out does not get one later.
All keys of an account share one balance and one rate limit: together they may send 60 requests a minute to the paid routes, in bursts of up to 20. An account can have up to 20 live keys; revoked and expired keys do not count.
Keep keys on a server
A key spends your balance. Keep it on your server, in an environment variable or a secret store, and keep it out of browsers, apps you ship to users, repositories and logs. The paid routes send no CORS headers, so a page on another site cannot read an answer made with your key. If a key leaks, revoke it and create a new one.
Headers and errors
Refusals are free: only a delivered answer is charged. Answers to a key are never cached: they carry Cache-Control: private, no-store and Vary: Authorization.
With a key, a 402 (code insufficient_balance) means your prepaid balance, with what is left of the test credit, is below the price of this request. It is not an x402 payment request: there is nothing to sign, and it carries no PAYMENT-REQUIRED header and no accepts or x402Version fields. Top up your balance and send the request again.
Header reference
| Header | Sent | Meaning |
|---|---|---|
X-Request-Id | Always | 32 hex characters naming this request. A refusal's instance and a charged call's line on your account page carry it. |
HodlOdds-Charged-USDC | Always | What this answer cost, such as 0.010000; 0.000000 for every refusal. |
HodlOdds-Balance-USDC | Once the key is known | Your balance after this call, without the test credit. |
HodlOdds-Test-Credit-USDC | Once the key is known | What is left of the test credit after this call. |
RateLimit-Policy | Once the key is known | The request budget of your account, shared by all its keys: "account";q=60;w=60 is 60 requests in 60 seconds. |
RateLimit | Once the key is known | "account";r=<left>;t=<seconds>: the requests left, and the seconds until the budget is full again. r can read lower than what is left, never higher. |
Retry-After | With rate_limited and unavailable | Seconds to wait before sending the request again. |
WWW-Authenticate | With 401 | Bearer realm="hodlodds" with error="invalid_token" for invalid_key, or with error="invalid_request" for invalid_request. |
HodlOdds-Charged | With the API call refusals below | no, as on the pay-per-request track. |
The refusals in the table below are application/problem+json (RFC 9457) with these members: type, a link to the code's row here, such as https://api.hodlodds.com/docs/api-key#invalid_key; code, the same name; title, status and detail; and instance, the request id as a urn:uuid. A refusal of an API call also carries "charged": false, and a 402 or 403 adds price_usdc, the price of this request, and balance_usdc, what your balance and test credit together allow now. Match on code, not on the wording.
A route's own refusals, such as a mint that is not covered, a bad board query or a feed that is not fresh, keep the bodies of the pay-per-request track, with the headers above and nothing charged.
Error codes
| Code | Status | Sent on | Meaning |
|---|---|---|---|
conflicting_credentials | 400 | API calls | A key came together with an x402 payment or another credential. Send only one of them. |
invalid_request | 401 | API calls | A paid route got an Authorization header with a scheme other than Bearer. |
invalid_key | 401 | API calls | The key is malformed, unknown, expired or revoked. Many of these from one IP address are answered with rate_limited for a while. |
insufficient_balance | 402 | API calls | Your balance and what is left of the test credit are below the price of this request. Top up and send it again. |
key_daily_cap | 403 | API calls | This call would pass the key's daily spending cap. The cap counts per UTC day. |
invalid_input | 400 | Account site | The body or the query is not what this route takes. |
invalid_address | 400 | Account site | That is not a Solana address. |
invalid_domain | 400 | Account site | The sign-in message must name the account site as its domain and URI. |
invalid_message | 400 | Account site | The message is not a sign-in for this site, or its times are wrong. |
invalid_nonce | 400 | Account site | The sign-in nonce is unknown, used or expired. Ask for a new challenge. |
invalid_signature | 400 | Account site | The signature does not match the message and the address. |
idempotency_key_required | 400 | Account site | Send a new Idempotency-Key header with this request. |
sign_in_required | 401 | Account site | Sign in with your wallet first, or again once your sign-in has expired. |
key_not_accepted | 401 | Account site | The account routes take the sign-in cookie, never an API key. |
forbidden_origin | 403 | Account site | Account changes are accepted from the account site only. |
key_limit | 403 | Account site | This account has as many live keys as it may. Revoke one first. |
not_found | 404 | Account site | No such key on this account. |
idempotency_in_progress | 409 | Account site | The first request with this Idempotency-Key is still running. |
json_required | 415 | Account site | Send the body as JSON, with Content-Type: application/json. |
idempotency_key_reused | 422 | Account site | This Idempotency-Key came with another request. |
rate_limited | 429 | Both | Too many requests: wait as long as Retry-After says. A key's requests count against its account, all its keys together. |
not_available | 501 | Account site | Deposits are not read on this server right now. |
rpc_unavailable | 503 | Account site | The chain could not be read just now. Nothing was missed: try again after Retry-After. |
unavailable | 503 | Both | Briefly unavailable. Nothing was charged or changed: try again after Retry-After. |
Examples
curl
# Keep the key in an environment variable, not in scripts you share.
curl -i https://api.hodlodds.com/v1/risk/REPLACE_WITH_MINT \
-H "Authorization: Bearer $HODLODDS_API_KEY"
Python
# Python >=3.10; python -m pip install httpx
# Set HODLODDS_API_KEY and TOKEN_MINT in your environment.
import os
import httpx
headers = {"Authorization": "Bearer " + os.environ["HODLODDS_API_KEY"]}
with httpx.Client(base_url="https://api.hodlodds.com", headers=headers,
timeout=30, follow_redirects=False) as http:
response = http.get("/v1/risk/" + os.environ["TOKEN_MINT"])
print("HTTP", response.status_code)
if response.status_code == 200:
answer = response.json()
print(answer["row"]["p_crash_60m"], answer["expires_at"])
else:
print(response.text) # A refusal is not charged.
The answer body is the same as on the pay-per-request track.