Authentication
Send your API key as a Bearer token on every request
Every API request carries your key in the Authorization header. Keys start with tdb_.
The scheme is not case-sensitive: bearer tdb_... works too.
Get a key
- For agents: use device login. The agent asks for a code, the user approves it in the browser, and the agent receives the key, so nobody has to copy it. Step-by-step instructions: /setup (markdown at /setup.md).
- For people: sign in and create one under Dashboard → API keys.
- Through MCP: no key needed. MCP clients sign in with OAuth when the server is added. See MCP Integration.
Signing in with Google or GitHub creates a free account if you don't have one.
Device login (for agents)
Device login follows the OAuth 2.0 Device Authorization Grant (RFC 8628), the same flow as gh auth login.
- Ask for a code.
POST /v1/auth/device, with no key. The JSON body is optional:{"client_name": "Claude Code"}names the key. The response hasdevice_code(keep it secret),user_code(for exampleKX4P-92QD),verification_uri(https://tickerdb.com/activate),verification_uri_complete(the same link with the code filled in),expires_in(900 seconds) andinterval(5 seconds). - The user approves. Show the user
verification_uri_complete. They open it, sign in, check that the code matches and click Approve. - Poll for the key.
POST /v1/auth/device/tokenwith{"device_code": "..."}, waitingintervalseconds between polls. When the user approves, you get200withapi_key,key_name,key_prefix,tierand the account'semail(masked).
Until the user decides, polling returns 400 with one of these in error.type:
| error.type | What to do |
|---|---|
authorization_pending | The user hasn't decided yet. Poll again after interval seconds. |
slow_down | You polled too soon. Use the longer wait in error.interval from now on. |
access_denied | The user declined. Stop polling. |
expired_token | The code expired (after 15 minutes) or was already used. Start again from step 1. |
Save the key straight away: it is shown only once. Store it in ~/.config/tickerdb/config.json (Windows: %APPDATA%\tickerdb\config.json) as {"api_key": "tdb_..."}, or in the TICKERDB_API_KEY environment variable.
Each approval creates a new key on the same account, named device: <client_name> <date>. Running the flow again only adds another key to the same account. An account can have at most 10 device-login keys; at 10, approval fails until you delete one under Dashboard → API keys.
Managing keys
- You can create as many keys as you like on any plan, for example one per project, or separate keys for development and production. They all share the account's plan and credits.
- Delete a key under Dashboard → API keys. It stops working within 10 minutes.
- Keep keys out of URLs, logs, and code you commit. If one leaks, delete it and create another.
Errors
| Status | error.type | Cause | What to do |
|---|---|---|---|
401 | authentication_required | No Authorization header, or it isn't Bearer <key>. | Add the header. No key yet? Use device login. |
401 | invalid_api_key | The key doesn't start with tdb_. | Check that the whole key was copied, with nothing added (quotes, spaces, a second Bearer). |
401 | invalid_api_key | The key is unknown or was deleted. | Get a new key. Retrying the same one won't help. |
429 | auth_rate_limited | Too many failed attempts from one address. | Stop and wait 5 minutes, then fix the key before retrying. |
A request with a valid key can still be refused for your plan or usage; see Errors & Caching and Rate Limits.