API and MCP integration

Register an app, connect an MCP client, and keep the scope list narrow. The same guide is published at /docs/api-and-mcp.

Last updated: November 12, 2026

Automate DejaBars from your own code, from a scheduled job, or from an AI host that

speaks the Model Context Protocol. The same pattern engine, market data and saved

catalog are available on every path; only the way you prove who you are changes.

The interactive reference lives at https://dejabars.com/developers.

This page is the written guide: what an API key can call, how to register an app,

how to approve an agent, and what a working integration looks like.

What the API is for

The API exposes four product areas:

  • Search — submit a drawn pattern and read the matches across every tracked market.
  • Market data — the coin universe, OHLC candles and stored series.
  • Pattern library — the signed-in user's saved patterns and their share links.
  • Analytics — the Outcome Lab: schema, quote, run, configs and exports.

MCP wraps search, market data, the catalog and analytics as tools so an agent can call

them without writing HTTP code. A read-only content endpoint serves published articles

and documentation to any host, without a key.

Get an API key

  1. Sign in and open your account page.
  2. Create a key and give it a label you will recognise later.
  3. Copy it immediately — it is shown once. The server stores only a hash.
  4. Send it on every request in the X-API-Key header.
export DEJABARS_KEY="tc_live_…"
curl -s -H "X-API-Key: $DEJABARS_KEY" https://dejabars.com/api/v1/app/search/algorithms

List your keys and their last use, or revoke one, on the same page. Revoking is immediate.

The list endpoint never returns the key itself, and it is not part of the app API.

A key belongs to the account that created it. Treat it like a password: one key per

integration, and revoke it when the integration is retired.

Base URL and versioning

https://dejabars.com/api/v1/app       → the public app API (pin this)
https://dejabars.com/api              → the service root

New integrations call /api/v1/app. The website and the MCP transport have their own

paths; the app namespace deliberately contains only the operations in this page. The

interactive reference and the OpenAPI document use the same /api/v1/app base.

What an API key can call

The public API covers three jobs: the search flow, alerts delivered to a webhook, and

Outcome Lab analyses. The developer handbook explains

each job step by step; this page is the integration reference.

Every app operation is served under /v1/app; the website's internal routes and the

unversioned copies are not part of the public contract.

MethodRoutePurpose
GET/v1/app/search/algorithmsEvery matcher, its description and its cost multiplier
POST/v1/app/search-offerPrice a search before running it
POST/v1/app/search-taskSubmit a pattern; returns a task_id
GET/v1/app/task-status/{task_id}Current status and progress
GET/v1/app/task-result/{task_id}The stored summary of a finished search
GET/v1/app/task-result/{task_id}/symbol/{symbol}Every match for one coin

A search body carries the pattern points and the same controls the editor sends:

{
  "pattern": [0.42, 0.51, 0.47, 0.63, 0.58],
  "xs": [0.0, 0.2, 0.4, 0.6, 0.8],
  "timeframe": "1h",
  "period_days": 30,
  "search_mode": "geo",
  "max_distance": 0.35,
  "check_dirs": true,
  "check_angles": true,
  "check_ratios": true,
  "check_turns": true,
  "check_peaks": true
}

Searches run one at a time per account. A burst queues behind the running search instead

of competing with it, and only the searches you start are charged. Send an

Idempotency-Key header when a retry must not start a second search.

Alerts and webhooks

MethodRoutePurpose
POST/v1/app/watches/pricePrice a watch before creating it
GET / POST/v1/app/watchesList or create watches
GET / PATCH / DELETE/v1/app/watches/{watch_id}Read, update or remove one
POST/v1/app/watches/{watch_id}/pauseStop evaluating a watch
POST/v1/app/watches/{watch_id}/resumeResume it
GET / POST/v1/app/notifications/destinationsList or connect a webhook
POST/v1/app/notifications/destinations/{id}/testSend a real test delivery
DELETE/v1/app/notifications/destinations/{id}Remove the destination
GET/v1/app/notifications/deliveriesDelivery state, attempts and last error

A watch evaluates one or more lanes on every closed candle. API integrations deliver alerts

to webhooks only; the site also supports chat and email. Every delivery is signed with the

destination secret — see Receive webhooks.

Analytics

MethodRoutePurpose
GET/v1/app/analytics/schemaEvents, fields, rules and defaults
GET/v1/app/analytics/questionsReady-made, report-aware analysis specs
POST/v1/app/analytics/offerQuote an analysis
POST/v1/app/analyticsRun it
GET/v1/app/analytics/{analysis_id}Read the stored result
GET/v1/app/analytics/{analysis_id}/exportDownload the result

Analytics is available on every plan. The steps are in

Run an analysis.

What is not in the public API

These stay on the website and are not offered to apps, even to an authenticated key:

  • Market data. OHLC candles, stored series, segments, the coin universe and signal

statistics. A chart is something the site draws for a visitor; it is not sold as a data

feed. An API key is refused on these routes. MCP sessions can still read coins and

klines as a tool.

  • The pattern library. Saving, editing, sharing and team visibility. A single pattern

can still be hashed and reused across calls.

  • Teams, billing, support and notification internals. These are account surfaces, not

integration surfaces.

  • The MCP transport. It is documented in its own page and uses its own OAuth

session, not an API key.

If an integration needs one of these, talk to us first; do not assume an undocumented

route is stable or permitted.

MCP

The MCP endpoint, its manifest, its tools and its approval flow are documented on the

MCP documentation page. An MCP session is separate from an

API key: it is scoped, revocable and auditable per agent.

Prices, quota and the free windows

  • Every agent tool returns the cost it charged and the account's quota_remaining.
  • Quote before you run: search-offer and analytics_quote return the price with no charge.
  • The free window — timeframes 1h, 4h, 1d and 1w, the geo matcher, and periods up

to 30 days — costs 0 tokens. Daily and weekly geo searches are free across the full year.

  • Minute timeframes cost more than hourly ones; the selector shows the multiplier for each

matcher.

  • If the account cannot afford a search, the call returns quota_exceeded and nothing is

charged. The message states the cost and the missing amount.

  • Each agent session also has its own spend ceiling. When it is reached the tool returns

spend_cap_exceeded; revoke the session and approve a new one to continue.

MCP: one protocol, three ways to connect

https://dejabars.com/api/v1/mcp is a streamable HTTP MCP endpoint. The manifest at

https://dejabars.com/.well-known/mcp.json describes the

transport, the tools, the scopes and the authorization servers, so a host can discover

everything without a conversation.

There are three ways in:

  1. Personal API key — a script or a single-user tool. Send X-API-Key.
  2. Registered OAuth app — a hosted chat or a product with many users. Register once,

then use authorization code with PKCE.

  1. Device flow — a local CLI with no browser callback. The human approves a short code.

Register an app (multi-user integrations)

Register the client once. The endpoint returns a client_id; this is a public client, so

there is no secret and PKCE S256 is mandatory.

curl -s -X POST https://dejabars.com/api/v1/oauth/register \
  -H 'Content-Type: application/json' \
  -d '{
    "client_name": "My integration",
    "redirect_uris": ["https://app.example.com/oauth/callback"],
    "grant_types": ["authorization_code", "refresh_token"],
    "response_types": ["code"],
    "token_endpoint_auth_method": "none"
  }'

Signed-in registrations may use any redirect URI. Anonymous registrations are accepted

only for hosts on the allowlist, so a bot cannot register an arbitrary callback. Register

from a signed-in browser session when you are building something new.

Then walk the authorization-code flow:

  1. Send the human to /api/v1/oauth/authorize with response_type=code, your client_id,

the exact redirect_uri, the scopes, a state, and a PKCE code_challenge using

S256.

  1. The human signs in and approves the requested scopes on

https://dejabars.com/agents/approve.

  1. Exchange the code at /api/v1/oauth/token with grant_type=authorization_code, the

code, the redirect_uri and the code_verifier.

  1. Refresh with grant_type=refresh_token before the access token expires.

Never ask a person to paste a token into a chat, and never echo one back.

Device flow (local tools)

curl -s -X POST https://dejabars.com/api/v1/oauth/device_authorization \
  -H 'Content-Type: application/json' \
  -d '{"client_name":"My CLI","scopes":["search:run","market:read"]}'

The response carries a short user_code, a verification_uri, a

verification_uri_complete, an expires_in and a polling interval. Show the code, let

the human approve it, then poll:

curl -s -X POST https://dejabars.com/api/v1/oauth/token \
  -H 'Content-Type: application/json' \
  -d '{"grant_type":"urn:ietf:params:oauth:grant-type:device_code","device_code":"<device_code>"}'

Until the human approves you receive authorization_pending; afterwards the response

carries an access_token and a refresh_token.

Call the MCP endpoint with the token:

curl -s -X POST https://dejabars.com/api/v1/mcp \
  -H "Authorization: Bearer <access_token>" \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Keep the Mcp-Session-Id returned by initialize and send it on every later call.

Scopes

ScopeWhat it allows
search:runSubmit and read pattern searches
market:readRead coins and klines
catalog:readList the user's saved patterns
catalog:writeSave patterns on the user's behalf (opt-in)
analytics:readRead the analytics schema, defaults and config drafts
analytics:writeSave configs and run paid analyses (opt-in)

Approval defaults to the read-only set. A tool outside the granted scopes returns

insufficient_scope. Revoke a session on the agents page and

approve a new one when the scope needs change.

The tools

ToolPurpose
agent_capabilitiesWhat this session may call, and its limits
search_submitStart a search; returns a task id
search_statusProgress and status for a task
search_resultMatches, with optional per-candle series
quota_statusRemaining balance and the next reset
list_coinsThe tracked universe
market_klinesOHLC candles for one symbol and timeframe
catalog_listThe user's saved patterns
catalog_saveSave a pattern
analytics_schemaFields, events and defaults
analytics_reportDefaults for one report token
analytics_quotePrice an analysis
analytics_fast_verifyCheap sanity check before a paid run
analytics_config_listSaved analysis configs
analytics_config_saveSave a config
analytics_config_deleteDelete a config
analytics_runRun a paid analysis

Every tool returns the same envelope: status, data, cost, quota_remaining,

errors[], request_id and next_cursor. search_status and search_result also

return a report_url — a link to the full, human-readable report on the site. Share that

link when a person should review the matches.

Connect a third-party host

The host only needs the MCP endpoint. It discovers the authorization servers and the

scopes from the manifest and the two well-known documents on the site origin.

ChatGPT

  1. Open Settings → Connectors → Advanced and enable developer mode if it is not

already visible.

  1. Create a connector with the URL https://dejabars.com/api/v1/mcp.
  2. Approve the scopes on the consent page when ChatGPT opens it.

ChatGPT registers itself with the registration endpoint and uses PKCE, so no client

secret is involved. Connector availability depends on the plan and region.

Claude

On claude.ai, open Settings → Connectors → Add custom connector, name it, and paste

https://dejabars.com/api/v1/mcp. Approve the scopes on the consent page.

For Claude Desktop builds without remote connectors, bridge the endpoint over stdio:

{
  "mcpServers": {
    "dejabars": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://dejabars.com/api/v1/mcp"]
    }
  }
}

Cursor

Add a remote server to .cursor/mcp.json:

{
  "mcpServers": {
    "dejabars": {
      "url": "https://dejabars.com/api/v1/mcp"
    }
  }
}

If the client asks for a header instead of running the OAuth flow, send

Authorization: Bearer <access_token> with a token obtained through the device flow.

Any other streamable HTTP client

Point it at https://dejabars.com/api/v1/mcp, send Content-Type: application/json, keep the

Mcp-Session-Id returned by initialize, and authorize with a bearer token or an API

key. For read-only content, use https://dejabars.com/api/v1/mcp/content with no authentication.

Use cases

1. Scan a watchlist after a rough sketch

Input: five to twenty points drawn on the editor, the 1h timeframe, the geo

matcher, a 30-day period.

Calls: search_submit → search_status until completed → search_result for the

ranked list and report_url.

Result: a ranked set of matches, each with its symbol, distance and window. The agent

summarises the ten best and links the report for review.

Why it works: the search is queued and charged once, so a chat can start it and come

back later without holding a connection open.

2. Compare two reads of the same pattern

Input: a saved pattern, the same timeframe, two runs a week apart.

Calls: search_submit → search_result for the first run; repeat later; compare the

ranked symbols and their distances.

Result: a short message that names the symbols that entered the match list, the ones

that left it, and the ones that moved closer. Each run links its report_url.

Why it works: the result is the product. No price feed is needed to say what changed;

the two runs already describe it.

3. Keep a pattern library in sync

Input: a pattern the person saved in the editor, plus the name they use for it.

Calls: catalog_list to find it, catalog_save with the new points when the sketch

changed.

Result: the same pattern is available in the editor, in the alerts tool and in the

next agent session, because all three read the same catalog row.

Success stories

These are authored walkthroughs of the flows above. They describe what the tool calls

return, not a customer quote or a measured return.

"One sketch, three matchers, one afternoon"

A researcher wants to know whether a shape repeats. They draw it once, quote the search

with search-offer, and run geo first because it is free on their timeframe. When the

free run returns too many weak matches, they quote dtw, see the price, and run it once.

The second run is smaller and better ranked. The takeaway: quote before you run, and use

the free matcher to decide whether the paid one is worth it.

"The agent remembers the pattern, the person remembers the idea"

A person saves a pattern in the editor and approves an agent with catalog:read and

search:run only. Days later the agent lists the saved pattern, submits it again, and

posts the report_url into the conversation. The person never pastes points into a chat,

and the agent cannot change the library because catalog:write was not granted. The

takeaway: approve the narrowest scope set that still does the job.

"A local script that behaves like a hosted integration"

A developer wants a scheduled scan without exposing a callback URL. They run the device

flow once, store the refresh token in the system keychain, and refresh on each run. The

scan submits the same pattern with an Idempotency-Key, so a retry after a network drop

does not start a second paid search. The takeaway: the device flow plus idempotent

submission is enough for a cron job.

Errors and what to do

CodeMeaningWhat to do
authorization_pendingThe human has not approved the device code yetKeep polling at the advertised interval
access_deniedThe human denied the requestAsk again, or narrow the scopes
expired_tokenThe device code expiredStart a new device authorization
auth_expiredThe session token is expired or revokedRun the flow again; do not retry the call
insufficient_scopeThe tool needs a scope the session was not grantedApprove a new session with that scope
quota_exceededThe account cannot afford the callTop up, wait for the reset, or choose a free window
spend_cap_exceededThe agent session reached its own ceilingRevoke the session and approve a new one
invalid_clientThe client is unknown or the redirect does not matchRegister again and reuse the exact redirect URI
invalid_scopeA requested scope is not in the listRequest only the documented scopes

HTTP errors carry a JSON body with a detail field. A 429 means the rate limiter is

active; back off and retry later.

Rules

  • One key per integration. Revoke keys and agent sessions you no longer use.
  • Stay inside the documented rate limits; do not build a bulk downloader or mirror the

dataset.

  • Approve the narrowest scopes that still do the job. A read-only integration should not

ask for catalog:write or analytics:write.

  • Never ask a person to paste a token into a chat, and never log one.
  • Everything in the Acceptable Use Policy

applies to programmatic access.

Last updated Nov 14, 2026