Keys and limits
Rate limits with and without a free DFO API key, how to create and send one, and how to handle a refused call.
You can call the DFO API without a key. Without one, a script gets 20 calls a minute on the API and 1,000 a day, counted by its IP address. A free API key raises that to 600 calls a minute and 10,000 a day, counted for your account.
Limits
| Caller | Calls a minute | Calls a day (UTC) |
|---|---|---|
| Script without a key | 20 on the API, 300 on dataset routes, per IP address | 1,000 on the API and 1,000 on dataset routes, per IP address |
| API key | 600 on the API, 600 on dataset routes, per account | 10,000 per account across the API and dataset routes |
| Browser visitor | 120 on the API, 300 on dataset routes, per visitor | 1,000 on the API and 1,000 on dataset routes, per visitor |
| All callers without a key at one IP address | 240 on the API, 500 on dataset routes | 5,000 on the API and 5,000 on dataset routes |
Dataset routes are the paths below /api/v1/datasets/, which read and analyse datasets. Calls to /api/v1/datasets itself build a dataset and count against the API limit. A browser counts as a visitor once it loads a page on developmentfinance.org and receives a cookie. Scripts call the API directly and use the unkeyed script limit.
An account can have up to five keys. All keys on an account share the account's limits, and replacing a key does not reset them. To ask for higher limits or more keys, write to [email protected].
The API also sets three daily write limits (UTC): 100 pins, 250 shares, and 500 card writes. Without a key they count per IP address, and with a key per account.
The MCP server at https://developmentfinance.org/mcp allows 300 requests a minute per IP address, and an API key does not change that limit.
Create a key
- Sign in at developmentfinance.org.
- Open the account menu and select API keys.
- Select Create API key, give the key a name, such as
Data pipeline, and select Create. - Copy the key, then select Close. The panel shows the whole key once, and the DFO keeps only a hash of it. A key starts with
dfo_k_and is 52 characters long.
The panel shows how many calls your account has made today against its daily limit. To revoke a key, select Delete on its card. To replace one, create the new key, move your code to it, then delete the old one.
Send the key
Store the key once and every client on the machine sends it.
dfo auth loginThe client checks three places in order and uses the first key it finds: dfo.Client(api_key=...), the DFO_API_KEY environment variable, and the stored key. dfo auth status shows which key the client sends.
Keep the key out of web pages, shared notebooks, and public repositories. If a key leaks, delete it.
When a call is refused
Every response on a limited route has three headers: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset (the seconds until the window resets). A refused call returns an error response whose code gives the cause.
| Status | code | What to do |
|---|---|---|
| 429 | rate_limited | Wait the seconds in Retry-After, then retry the call. |
| 429 | allowance_exhausted | A daily limit is reached. It resets at 00:00 UTC, and Retry-After gives the seconds until then. Sending a key replaces the unkeyed daily call limit with the account's 10,000 a day. The write limits do not change. |
| 401 | invalid_api_key | The key is unknown, deleted, or truncated. Fix the key, or omit it. |
| 400 | request_invalid | The two key headers contain different keys. Send one. |
When a call returns rate_limited, the Python and TypeScript clients wait and retry if Retry-After is 60 seconds or less and the call's deadline allows. Otherwise they raise RateLimitError. They raise QuotaExceededError for allowance_exhausted and AuthenticationError for invalid_api_key.