Local API, SDK and MCP
Read market data and the account from a running Spectre Terminal and trade through it from your own programs.
The Local API is an HTTP and WebSocket interface that a running Spectre
Terminal serves on 127.0.0.1. A program on the same machine reads what the
terminal window shows and sends the same commands, including orders.
Where to start
- Getting started: switch the API on, get the token, make the first request.
- Authentication: send the token and fix a refused request.
- The guide for your task: market data, the account, trading, the layout, settings or live streams.
Client packages
| Package | For | Install |
|---|---|---|
spectre-terminal | Python 3.10 or newer | pip install spectre-terminal |
@spectre-trade/terminal | TypeScript and JavaScript, Node 22 or newer | npm install @spectre-trade/terminal |
spectre-terminal-mcp | AI agents, as an MCP server | pip install spectre-terminal-mcp |
The clients find the port on their own and read the token from the environment. See Discovery.
Reference
- HTTP API: every operation with its parameters, answers and errors.
- WebSocket stream: requests, frames and topics.
- Errors and limits.
- Specification files: OpenAPI and AsyncAPI.
Keep in mind
- The API is off by default. Switch it on in Settings App → General → Local API.
- The token is a secret. It allows everything the terminal window can do, including placing orders.
- Web pages cannot call the API. Run the examples from a script or a program.
- Prices and sizes are decimal strings. Times are UTC milliseconds.
acceptedis notfilled. A trading call says the terminal took the command. Read the outcome from the account.