Help / Developers
The API
The same data and tools as the app, over HTTP: market data, your alerts and your paper trading account. Use it from scripts, spreadsheets, bots or your own apps. The base URL is https://<server>, and every route starts with /v1.
Conventions#
- Times are UTC epoch milliseconds, everywhere (
1791262800000). A bar is keyed by its open time. - Instruments are
venue:symbol:hyperliquid:BTCfor crypto, and the venue the symbol search shows for stocks, ETFs and forex.GET /v1/instrumentslists every one. - Resolutions are written like
1m,15m,1h,4h,1Dand1W. - Errors come as
{ "error": "…" }with a 4xx status: 400 for a bad request (the message says which field), 401 without a valid key, 403 when your plan doesn’t include something, 404 for an unknown instrument or id, 429 over a limit. Some carry acodeto act on:/v1/barsanswers 404 withunknown_instrumentfor a symbol nobody has (a typo, or delisted or renamed), rather than an empty list, and 401 or 403 withneeds_feedand aproviderfor a stock or forex pair that charts from your own Alpaca or OANDA keys;helplinks to the step-by-step guide for adding them. A request with no key at all gets 401api_key_required(withWWW-Authenticate: Bearer). When a data source is throttling us, bars answer 503upstream_busywithretryAfter, the seconds to wait. - Retries: a create sent with an
Idempotency-Keygets its first successful answer back for an hour; the MCP server does this for you, so an agent’s identical retry within two minutes doesn’t place a second order or alert. - Your own symbols’ quotes, many at once:
GET /v1/data/tickers?ids=alpaca:AAPL,oanda:EUR_USD(up to 100 ids).
API keys#
Every request needs a key, market data included. Alerts and paper trading act as you, so give the key read & write access for those.
- Sign in and open the Account page.
- Under API keys, give the key a name (what will use it), choose what it Can do (Read only or Read & change) and when it Expires (30 days, 90 days or a year, so a lost one stops working; only the site owner’s account can also choose Never), then press Create key.
- For ai-algo’s signals API (
/v1/ai-algo/…), if your account has ai-algo, choose ai-algo signals instead. Only that key reaches it, and it reaches nothing else, so a bot following the signals can’t see the rest of your account. - Copy it straight away: it’s shown once. Keep it where your script reads secrets, such as an environment variable.
- Send it on every request as
x-api-key: …orAuthorization: Bearer ….
What each kind of key can do
| Read only | Read & change | ai-algo signals | |
|---|---|---|---|
| Market data, charts, your portfolios and the Strategy Lab | Look | Look | — |
| Alerts, paper orders and saved items | Look | Look and change | — |
ai-algo’s signals (/v1/ai-algo/…) | — | — | Look |
| Admin actions (giving plans and add-ons) | — | — | — |
Read only is for scripts and AI apps that only look. Read & change can also act on your account: make and delete alerts, place and cancel paper orders, save things. ai-algo signals reaches ai-algo’s signals and nothing else, so a bot that follows them holds a key that can’t see or change the rest of your account; the other two keys are refused there. No key can do admin actions: those need you signed in on the site. In AI apps (the MCP server) a read-only key gets the tools that look, a read & change key those that change things too, and an ai-algo key just ai_algo_today and ai_algo_signals.
ai-algo’s signals#
For accounts with ai-algo, its day as data: what each run signalled, what opens and closes, and what’s near its stop. Every route takes an ai-algo signals key, and most take ?algo= (a folder: MAIN, AGGRESSIVE, CONSERVATIVE) and ?date= (a New York date, YYYY-MM-DD; today when left out).
| Route | What it returns |
|---|---|
/v1/ai-algo/today | Each folder’s runs today, what opens, what closes at the close, what closed and why, and what’s near its stop |
/v1/ai-algo/signals | The pre-open swing signals, with what each means for its position |
/v1/ai-algo/day-trades | The day trades the pre-open run fired, with their stops and targets |
/v1/ai-algo/positions/open | Every swing position held, with its stop level |
/v1/ai-algo/positions/closed | Positions closed on the day, and why |
/v1/ai-algo/runs | Whether each run (pre-open, morning, end of day) has finished, per folder |
/v1/ai-algo/events | What happened, in order, from an id on (`?since=`): runs, day trades, positions opened and closed |
/v1/ai-algo/stream | A WebSocket that pushes those events as they happen, after any missed since the id you give |
# Today's ai-algo, for the Main folder
curl -H "x-api-key: $OPENTAPEFOLIO_AI_ALGO_KEY" "https://<server>/v1/ai-algo/today?algo=MAIN"Try it#
# The last three hourly bars of Bitcoin
curl -H "x-api-key: $OPENTAPEFOLIO_API_KEY" "https://<server>/v1/bars?instrumentId=hyperliquid:BTC&resolution=1h&limit=3"
# Your alerts
curl -H "x-api-key: $OPENTAPEFOLIO_API_KEY" "https://<server>/v1/alerts"A price alert, made from Python:
import os, requests
requests.post(
"https://<server>/v1/alerts",
headers={"x-api-key": os.environ["OPENTAPEFOLIO_API_KEY"]},
json={
"instrumentId": "hyperliquid:BTC",
"resolution": "1h",
"condition": {
"left": {"kind": "price"},
"operator": "crossing-up",
"right": {"kind": "value", "value": 100000},
},
"frequency": "once",
"message": "BTC above 100k",
"expiresAt": None,
"webhookUrl": None,
},
).raise_for_status()What’s in the public API#
| Area | What you can do | Key |
|---|---|---|
| Market data | Instruments, 24-hour tickers, bars (candles), watchlist sparklines, trades | No |
| Alerts | List, create, replace, pause or start, delete, and read the log of what fired | Yes |
| Paper trading | Read the account, place, move and cancel orders, close a position (simulated: nothing reaches a broker) | Yes |
The full list, with every parameter and response, is on the Developers page, read live from the OpenAPI 3.1 description at /v1/openapi.json. Load that into Postman, Insomnia or a code generator for a typed client in your language.
/v1 serve the app’s own screens and may change without notice. The documented ones won’t: fields may be added, but not renamed or removed. A change that can’t be made that way gets a new /v2 route.AI apps#
Claude, ChatGPT and other AI apps don’t need the HTTP API: connect them to the MCP server and they get the same tools, with your permission. See Connect Claude or ChatGPT.
Next
- Limits and rate limits: how many requests, and what to do with a 429.
- Live data over WebSocket
- Bulk downloads as Parquet
TradingView and Pine Script are trademarks of TradingView, Inc. OpenTapefolio is not affiliated with or endorsed by TradingView.