ChartnautDocs

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

Keys

Your server's secret keys, made in the partner portal

Linking

A user signs in to Chartnaut and approves what you may do for them

The frame

Chartnaut's backtest screen in an iframe on your page, opened with one script

Sessions

Backtests you create for a user, on a day and markets you choose

Demo accounts

Accounts that trade live prices with simulated money

Rules

Daily loss, drawdown, position size, profit target and slippage on a session or account

Webhooks

Hints that something changed

Alerts

When a linked user's own Chartnaut alerts fire

Limits and errors

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/v1

Send 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_42 is a Chartnaut user, ses_42 a session, acc_42 an account, brk_42 a rule breach, alr_42 an alert and alf_42 an 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-Key header. Any unique string, such as a UUID. Retrying with the same key, path and body within 24 hours returns the first response with Idempotent-Replayed: true. The same key with a different path or body is 422 idempotency_key_reused. PUT, PATCH and DELETE need no key.

  • Lists are paged with a cursor. Pass next_cursor back as cursor until it is null. A full page always has a next_cursor, so the last page can be empty. Up to 200 items a page; a bigger limit is 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 in message.

  • 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 on code. The list is in Limits and errors.

A first event, end to end

  1. Your user clicks "Connect Chartnaut" on your site. Your server calls POST /links and shows the frame_url in an iframe. The user signs in and approves. See Linking.

  2. Your server creates a session for them with POST /sessions, with a label such as event=nov-open.

  3. Your page opens it in the frame. The user trades.

  4. Your server lists GET /sessions?label.event=nov-open every few seconds for the leaderboard.

  5. At the end, POST /sessions/actions with {"action":"end","labels":{"event":"nov-open"},"expected_count":120} ends them all.