Skip to the content

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:BTC for crypto, and the venue the symbol search shows for stocks, ETFs and forex. GET /v1/instruments lists every one.
  • Resolutions are written like 1m, 15m, 1h, 4h, 1D and 1W.
  • 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 a code to act on: /v1/bars answers 404 with unknown_instrument for a symbol nobody has (a typo, or delisted or renamed), rather than an empty list, and 401 or 403 with needs_feed and a provider for a stock or forex pair that charts from your own Alpaca or OANDA keys; help links to the step-by-step guide for adding them. A request with no key at all gets 401 api_key_required (with WWW-Authenticate: Bearer). When a data source is throttling us, bars answer 503 upstream_busy with retryAfter, the seconds to wait.
  • Retries: a create sent with an Idempotency-Key gets 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.

  1. Sign in and open the Account page.
  2. 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.
  3. 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.
  4. Copy it straight away: it’s shown once. Keep it where your script reads secrets, such as an environment variable.
  5. Send it on every request as x-api-key: … or Authorization: Bearer ….

What each kind of key can do

Read onlyRead & changeai-algo signals
Market data, charts, your portfolios and the Strategy LabLookLook—
Alerts, paper orders and saved itemsLookLook 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.

Careful:A key that can change things can do anything you can, so keep it like a password, and give a script that only reads a read-only key. Never put it in a web page or a public repository. If one leaks, delete it on the Account page; it stops working at once. Every change a key makes is listed there under “What AI apps and API keys changed”.

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

RouteWhat it returns
/v1/ai-algo/todayEach folder’s runs today, what opens, what closes at the close, what closed and why, and what’s near its stop
/v1/ai-algo/signalsThe pre-open swing signals, with what each means for its position
/v1/ai-algo/day-tradesThe day trades the pre-open run fired, with their stops and targets
/v1/ai-algo/positions/openEvery swing position held, with its stop level
/v1/ai-algo/positions/closedPositions closed on the day, and why
/v1/ai-algo/runsWhether each run (pre-open, morning, end of day) has finished, per folder
/v1/ai-algo/eventsWhat happened, in order, from an id on (`?since=`): runs, day trades, positions opened and closed
/v1/ai-algo/streamA 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#

AreaWhat you can doKey
Market dataInstruments, 24-hour tickers, bars (candles), watchlist sparklines, tradesNo
AlertsList, create, replace, pause or start, delete, and read the log of what firedYes
Paper tradingRead 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.

Note:Other routes under /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

TradingView and Pine Script are trademarks of TradingView, Inc. OpenTapefolio is not affiliated with or endorsed by TradingView.