Partner API overview
The partner API is for companies that put Chartnaut inside their own product. Your users link their own Chartnaut account to their account on your site, and your server then creates backtest sessions and demo accounts for them, reads the results, and shows Chartnaut's backtest screen in a frame on your page.
It works in primitives. You create sessions and demo accounts, attach your own labels, list by label and act on many at once. Competitions, leaderboards, groups and schedules are yours to build on top.
How the pieces fit
Piece | What it does |
|---|---|
Your server's secret keys, made in the partner portal | |
A user signs in to Chartnaut and approves what you may do for them | |
Chartnaut's backtest screen in an iframe on your page, opened with one script | |
Backtests you create for a user, on a day and markets you choose | |
Accounts that trade live prices with simulated money | |
Daily loss, drawdown, position size, profit target and slippage on a session or account | |
Hints that something changed | |
When a linked user's own Chartnaut alerts fire | |
Rate limits, caps and every error code |
Reads are the truth
Every fact has a GET. Webhooks and the frame's page events only say that something changed and name it by id, so read the object before you act on it. A missed or late webhook never leaves you with a wrong answer.
Base URL
https://api.chartnaut.com/partner/v1Send your key as a bearer token on every call:
curl https://api.chartnaut.com/partner/v1/users \
-H "Authorization: Bearer cn_partner_live_XXXX"{ "data": [], "next_cursor": null }The full contract is an OpenAPI 3.1 file: partner-api.yaml. From Node, @chartnaut/node wraps every route with types, retries and webhook checks. To put the terminal in your app and drive it from your page, start with the Terminal SDK.
Conventions
Ids carry their type.
usr_42is a Chartnaut user,ses_42a session,acc_42an account,brk_42a rule breach,alr_42an alert andalf_42an alert fire. Positions and orders are plain numbers. Wherever a user goes, you can use your own id instead:ext:<your ref>, URL-encoded in a path.Every POST needs an
Idempotency-Keyheader. Any unique string, such as a UUID. Retrying with the same key, path and body within 24 hours returns the first response withIdempotent-Replayed: true. The same key with a different path or body is422 idempotency_key_reused. PUT, PATCH and DELETE need no key.Lists are paged with a cursor. Pass
next_cursorback ascursoruntil it isnull. A full page always has anext_cursor, so the last page can be empty. Up to 200 items a page; a biggerlimitis cut to 200.Lists have their own order. Sessions and demo accounts come newest first; linked users and alert fires oldest first. Trades and breaches differ between sessions and accounts: see their pages.
Unknown fields are refused with
400 invalid_request. The field is named inmessage.Money is a decimal number in the account's currency, USD today, with at most two decimal places.
Users' plans apply to sessions. A session you create follows the user's Chartnaut plan. Demo accounts don't use the plan.
Errors look like
{"error": {"code": "scope_not_granted", "message": "…", "details": {"scope": "sessions:read"}}}. Branch oncode. The list is in Limits and errors.
A first event, end to end
Your user clicks "Connect Chartnaut" on your site. Your server calls
POST /linksand shows theframe_urlin an iframe. The user signs in and approves. See Linking.Your server creates a session for them with
POST /sessions, with a label such asevent=nov-open.Your page opens it in the frame. The user trades.
Your server lists
GET /sessions?label.event=nov-openevery few seconds for the leaderboard.At the end,
POST /sessions/actionswith{"action":"end","labels":{"event":"nov-open"},"expected_count":120}ends them all.
