Skip to main content
Practical patterns for building reliable clients against the Crustdata API. Each section explains the signal the API sends, then shows the code you need to react to it.

Handle rate limits

Crustdata returns rate limit headers on every response. Read them after each call and pace your client accordingly — this is more reliable than guessing limits up front, and it gives you visibility before you hit the cap.
Rate limits are enforced on a sliding window. The window does not reset at fixed clock intervals — instead, each request counts against the limit for the duration of the window, and x-ratelimit-reset tells you how many seconds until the oldest request ages out and capacity frees up. Spreading traffic evenly is safer than bursting and waiting for a “reset.”

Rate limit headers

Example values on a response:

Read the headers and pace requests

After each request, inspect x-ratelimit-remaining. When it gets close to zero, wait x-ratelimit-reset seconds before sending the next call.

Retry on 429 with backoff and jitter

If you do receive a 429 Too Many Requests, wait x-ratelimit-reset seconds and retry. Add jitter so concurrent workers do not all retry at the same instant.
See Rate limits for default per-endpoint limits and how to request higher throughput.

Handle insufficient credits

When your account has no remaining credits, the API returns 402 Payment Required with a structured error body. Treat this as terminal — retrying will not succeed until credits are added. An API key that has its own monthly cap returns the same status and error.type once that cap is exhausted, with a message naming the key’s limit and its reset date. Handle both with the same branch — see Per-key monthly limit.

Response shape

Detect and stop

Catch 402 early, pause the workflow, and alert the operator. Do not feed the same request back into a retry loop.
Do not retry 402 responses. Repeated calls without adding credits will return the same error and obscure the real problem in your logs.

Get more credits

Reach out to support@crustdata.co to discuss your usage, upgrade your plan, or add credits to your account.

Handle denied endpoint access

A 403 Forbidden means the API key you used is not allowed to call that endpoint. A workspace admin can restrict an individual key to a subset of the endpoints the account has enabled, so a key that works for one endpoint can be refused on another.

Response shape

Detect and stop

When the endpoint itself is refused, treat 403 the way you treat 402: terminal, not worth retrying. No change to the body will alter the outcome. Route it to the operator, who can widen the key’s endpoint access in the dashboard. A 403 naming specific fields is the other case, below.

Denied fields

The same status and error.type come back when the endpoint is allowed but a value in fields is not enabled on the account. The message names the refused fields and links to a call for enabling them. metadata carries the same split:
Batch endpoints put the permitted list in the message and leave metadata empty, so on a wide grant that message runs to tens of kilobytes. Size any log line or error column accordingly. Resending the same body gets the same 403. Sending a narrower fields list returns the rest of the record. See Permissions.
See Permissions for the endpoint that lists what the account has enabled, and Per-key endpoint access for how a single key can be narrowed below that.