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

curl
curl "https://api.tickerdb.com/v1/summary/AAPL" \ -H "Authorization: Bearer tdb_your_api_key"

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.

  1. 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 has device_code (keep it secret), user_code (for example KX4P-92QD), verification_uri (https://tickerdb.com/activate), verification_uri_complete (the same link with the code filled in), expires_in (900 seconds) and interval (5 seconds).
  2. The user approves. Show the user verification_uri_complete. They open it, sign in, check that the code matches and click Approve.
  3. Poll for the key. POST /v1/auth/device/token with {"device_code": "..."}, waiting interval seconds between polls. When the user approves, you get 200 with api_key, key_name, key_prefix, tier and the account's email (masked).
curl
# 1. Ask for a code (no key needed) curl -s -X POST https://api.tickerdb.com/v1/auth/device \ -H "Content-Type: application/json" -d '{"client_name":"Claude Code"}' # 3. Poll until the user approves curl -s -X POST https://api.tickerdb.com/v1/auth/device/token \ -H "Content-Type: application/json" -d '{"device_code":"<device_code>"}'

Until the user decides, polling returns 400 with one of these in error.type:

error.typeWhat to do
authorization_pendingThe user hasn't decided yet. Poll again after interval seconds.
slow_downYou polled too soon. Use the longer wait in error.interval from now on.
access_deniedThe user declined. Stop polling.
expired_tokenThe 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

Statuserror.typeCauseWhat to do
401authentication_requiredNo Authorization header, or it isn't Bearer <key>.Add the header. No key yet? Use device login.
401invalid_api_keyThe key doesn't start with tdb_.Check that the whole key was copied, with nothing added (quotes, spaces, a second Bearer).
401invalid_api_keyThe key is unknown or was deleted.Get a new key. Retrying the same one won't help.
429auth_rate_limitedToo many failed attempts from one address.Stop and wait 5 minutes, then fix the key before retrying.
Example 401
{ "error": { "type": "authentication_required", "message": "Missing Authorization header. Use: Authorization: Bearer <api_key>. No key yet? See https://tickerdb.com/setup (free key in one click)." } }

A request with a valid key can still be refused for your plan or usage; see Errors & Caching and Rate Limits.