{"slug":"api-and-mcp","title":"API and MCP integration","content":"# API and MCP integration\n\nAutomate DejaBars from your own code or from an AI agent.\n\n## Create an API key\n\n1. Sign in and open your account page.\n2. Create a key and give it a label so you can recognise it later.\n3. Copy the key immediately — it is shown **once**; we store only a hash of it.\n4. Send it on every request in the `X-API-Key` header.\n\nYou can list your keys (labels and last use) and revoke any of them at any time. Revoking is\nimmediate.\n\n## Base URL and versioning\n\nThe API is available at `https://dejabars.com/v1`. Every route is also served without the prefix, but new\nintegrations should pin `/v1`.\n\n```\ncurl -H \"X-API-Key: $DEJABARS_KEY\" https://dejabars.com/v1/coins\n```\n\n## Useful endpoints\n\n| Method | Route | Purpose |\n|---|---|---|\n| `GET` | `/v1/coins` | The tracked coins and their stats |\n| `GET` | `/v1/klines` | OHLC candles for a symbol and timeframe |\n| `POST` | `/v1/search-task` | Start a pattern search |\n| `GET` | `/v1/task-stream/{task_id}` | Server-sent progress until the search completes |\n| `GET` | `/v1/task-result/{task_id}` | The stored summary of a finished search |\n| `GET` | `/v1/task-result/{task_id}/symbol/{symbol}` | Every match for one coin |\n| `GET` | `/v1/auth/api-keys` | List your keys |\n\nInteractive documentation, generated from the running service, is served by the API itself at\n`/docs` on the API host.\n\n## The search flow\n\n1. `POST /v1/search-task` with your pattern points, timeframe, algorithm and filters. The response\n   contains a `task_id` and a queue position.\n2. Follow `GET /v1/task-stream/{task_id}` for progress, or poll `GET /v1/task-result/{task_id}`.\n3. Read a single coin's matches with the symbol route when you only need one.\n\nSearches are queued and run one at a time per account, so a burst of submissions waits its turn\ninstead of running in parallel. Only the searches you actually start are charged.\n\n## MCP (Model Context Protocol)\n\n`backend/mcp_server.py` exposes the same API over MCP so an agent can drive searches directly. Set\n`MCP_API_URL` to your API base and `MCP_API_KEY` to a key you created above; the server sends it as\n`X-API-Key`.\n\n## Rules\n\n- Stay inside the documented rate limits; do not build a bulk downloader or mirror the dataset.\n- One key per integration, and revoke keys you no longer use.\n- Everything in the [Acceptable Use Policy](/docs/acceptable-use-policy) applies to programmatic\n  access.\n","category":"product","version":"13529e1a07ad","updated_at":"2026-09-16T21:05:35.436811+02:00","is_published":true}