ChartnautDocs

Overview

The Terminal SDK puts Chartnaut's trading terminal inside your own app. Your page shows the charts, your code drives them, and every click your user makes reaches your code as an event.

Two packages do it:

Package

Runs on

What it does

@chartnaut/charts

Your page

The terminal as a React component (<Terminal>) or a plain JavaScript object, with hooks for charts, scripts, drawings, replay, orders and the account

@chartnaut/node

Your server

Mints the terminal's sign-in for the user on your site (frameRoute), calls the partner API and checks webhooks

Your secret key stays on your server. The page only ever holds a short-lived frame address.

The whole thing in two files

With Next.js, one route on your server and one component on your page:

// app/api/chartnaut/frame/route.ts
import { frameRoute } from "@chartnaut/node";

export const GET = frameRoute({
  getUser: async () => (await auth())?.user.id ?? null, // your own sign-in
  whenNotLinked: { link: { scopes: ["frame:instant", "terminal:read", "terminal:write"] } },
});
// app/trade/page.tsx
"use client";
import { Terminal, useChart, useTerminal } from "@chartnaut/charts/react";

export default function TradePage() {
  const terminal = useTerminal();
  const main = useChart(terminal, "main");
  return (
    <div style={{ height: "100vh" }}>
      <button onClick={() => main.setTimeframe("15m")}>15m</button>
      <Terminal ref={terminal.ref} charts={{ main: { symbol: "NAS100", timeframe: "1h" } }} />
    </div>
  );
}

<Terminal> asks your server for its address at /api/chartnaut/frame, which frameRoute answers. The first time someone opens it, the terminal shows Sign in with Chartnaut and opens once they approve. Getting started sets this up for you in one command.

Three layers, one channel

Layer

What you write

Use it for

Friendly

<Terminal>, terminal.chart("main").setSymbol("NAS100"), terminal.orders.buy(...), hooks

Nearly everything

Raw

terminal.send("set_symbol", {...}), terminal.on("symbol_changed", ...)

Any command or event, including new ones before they get a friendly name

Protocol

postMessage with v: 1

Pages with no JavaScript tooling. See The frame and embed.js

Every friendly call is a thin wrapper over one command or event, so you can mix them freely. The terminal stays in charge of prices, rules and limits: the SDK never decides anything the terminal doesn't check again.

What you can build

  • Your own terminal. Hide Chartnaut's toolbars and put your own around the charts: Layout and charts.

  • Scripts as components. Add an indicator when a component mounts, read its values, react to a definition's events: Scripts.

  • Your data on the chart. Lines, zones and markers from your own database: Drawings and overlays.

  • Drills and journals. Pause the replay on an event until your user answers, journal every closed trade: Replay, orders and the account.

  • Saved setups. Keep each user's layout in your own database: Workspace and persist.

Where to go next

You want to

Read

Get a terminal on your page

Getting started

Learn the React component and hooks

React

Understand projects, Test and Live, keys and sites

Projects

Know who signs in, and how

Users

Look up an error code

Errors

Test your app without a terminal

Testing

See what changed

Changelog

Coding agents can start from llms.txt, an index of these docs, or read every page as one file in llms-full.txt.