Skip to content

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.

On this page

Get a key

  1. 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.

  2. 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.

  3. 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.

  4. Call the API

    Send the key with each request to the same /v1 routes 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

RouteWith 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/delayedFree; 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

HeaderSentMeaning
X-Request-IdAlways32 hex characters naming this request. A refusal's instance and a charged call's line on your account page carry it.
HodlOdds-Charged-USDCAlwaysWhat this answer cost, such as 0.010000; 0.000000 for every refusal.
HodlOdds-Balance-USDCOnce the key is knownYour balance after this call, without the test credit.
HodlOdds-Test-Credit-USDCOnce the key is knownWhat is left of the test credit after this call.
RateLimit-PolicyOnce the key is knownThe request budget of your account, shared by all its keys: "account";q=60;w=60 is 60 requests in 60 seconds.
RateLimitOnce 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-AfterWith rate_limited and unavailableSeconds to wait before sending the request again.
WWW-AuthenticateWith 401Bearer realm="hodlodds" with error="invalid_token" for invalid_key, or with error="invalid_request" for invalid_request.
HodlOdds-ChargedWith the API call refusals belowno, 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

CodeStatusSent onMeaning
conflicting_credentials400API callsA key came together with an x402 payment or another credential. Send only one of them.
invalid_request401API callsA paid route got an Authorization header with a scheme other than Bearer.
invalid_key401API callsThe key is malformed, unknown, expired or revoked. Many of these from one IP address are answered with rate_limited for a while.
insufficient_balance402API callsYour balance and what is left of the test credit are below the price of this request. Top up and send it again.
key_daily_cap403API callsThis call would pass the key's daily spending cap. The cap counts per UTC day.
invalid_input400Account siteThe body or the query is not what this route takes.
invalid_address400Account siteThat is not a Solana address.
invalid_domain400Account siteThe sign-in message must name the account site as its domain and URI.
invalid_message400Account siteThe message is not a sign-in for this site, or its times are wrong.
invalid_nonce400Account siteThe sign-in nonce is unknown, used or expired. Ask for a new challenge.
invalid_signature400Account siteThe signature does not match the message and the address.
idempotency_key_required400Account siteSend a new Idempotency-Key header with this request.
sign_in_required401Account siteSign in with your wallet first, or again once your sign-in has expired.
key_not_accepted401Account siteThe account routes take the sign-in cookie, never an API key.
forbidden_origin403Account siteAccount changes are accepted from the account site only.
key_limit403Account siteThis account has as many live keys as it may. Revoke one first.
not_found404Account siteNo such key on this account.
idempotency_in_progress409Account siteThe first request with this Idempotency-Key is still running.
json_required415Account siteSend the body as JSON, with Content-Type: application/json.
idempotency_key_reused422Account siteThis Idempotency-Key came with another request.
rate_limited429BothToo many requests: wait as long as Retry-After says. A key's requests count against its account, all its keys together.
not_available501Account siteDeposits are not read on this server right now.
rpc_unavailable503Account siteThe chain could not be read just now. Nothing was missed: try again after Retry-After.
unavailable503BothBriefly 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.