Business news

How JAFX opens up to developers, from REST to MCP

Written by
Read time
3 min
Published
Filed under
Add to Preferred Sources
JAFX featured image: “REST, WebSocket and MCP.” beside the JAFX Trading API.

The first retail trading APIs worked like a vending machine. A program asked for a price, got one back, and asked again a moment later. The next generation kept a connection open and let the market speak first. The third is still taking shape: the caller is no longer only a script but an AI assistant that reads the account and chooses its own tools.

JAFX, an AI-native forex broker, offers all three over one set of keys and one set of limits. Taken layer by layer, the design shows what developers can now expect from a broker API.

Request and response: the REST layer

The JAFX Trading API’s REST interface covers quotes, candles, the account, positions and orders. A first call to /me returns the key’s account, scopes, limits and whether trading is allowed right now, so a bot learns of a restriction before it trades.

Orders take the same route as trades placed by hand in the web terminal, with the same checks on instrument, volume step, stop distance, margin and market hours. Every write carries an Idempotency-Key header: if the connection drops mid-order, the same request with the same key returns the original answer instead of a second trade. When the broker is still deciding, the API answers 202, and the docs are explicit: poll or watch the stream, never resend under a new key.

The version sits in the address. Changes within v1 only add things; a breaking change comes as a new version, announced on the changelog first.

Live streams: the WebSocket layer

Polling wastes requests and still misses things. One WebSocket connection carries quotes (at most four updates a second per instrument), candles from one minute to one week, account updates at most once a second, and order events.

The order events are where the design shows care. Each carries a sequence number. After a reconnect, a client subscribes with the last number it processed and the server replays what it missed from the last five minutes, in order. If the gap is longer, a resync_required frame tells the client to reload positions over REST. When a slow client falls behind, quote, candle and account frames are skipped until it catches up. Order events never are.

Agents: the MCP layer

The newest layer is the JAFX MCP server, built on the Model Context Protocol, the open standard AI applications use to call outside tools. It exposes up to 24 tools, filtered by what the key allows. Each calls the same service as the matching REST endpoint and returns the same JSON, so an agent and a bot see the account the same way.

One addition is written for language models. When a tool refuses, the error carries an extra field, next: one plain sentence saying what to do, and whether that step belongs to the user. A REST client branches on an error code; a model reads the sentence.

Porting a bot that already exists

Many developers switching brokers bring a bot with them. The JAFX docs include porting notes built around three habits such bots rely on. A client_tag of up to 32 characters labels each order with its strategy, and positions can be filtered by tag. Idempotent orders take the guesswork out of retries. Stop and target changes have their own per-minute budget, so frequent stop adjustments don’t eat into the allowance for entries and exits.

The docs are just as plain about what is missing: maximum slippage on market orders, stop-limit orders, OCO pairs and server-side trailing stops are listed as not available yet.

For working code, the documentation ships examples in curl, Python and TypeScript, an OpenAPI file, and two example bots, both moving-average crossovers, one in Python and one in TypeScript. Both refuse to run unless the key belongs to a demo account. The JAFX developer docs tell builders to test with virtual money first, and demo orders take the same route as live ones.

Across all three layers, a key belongs to one trading account, carries read-only, trading or proposals scope, and is held to limits on the server whatever the caller sends. The docs end every page with the same reminder: automated and AI-driven trading can lose money quickly.

JAFX (PTY) LTD is an authorised Financial Services Provider (FSP No. 52058) regulated by the FSCA. Trading leveraged derivatives carries a high risk of losing money rapidly and is not suitable for everyone.

Spotted an error? Request a correction
Never miss a storyThe TechBullion Weekly newsletter and your preferred channels.Subscribe
Share this
Comment

More executive interviews

Founders, CEOs and technology leaders talk about what they build, how they fund it, and where AI, finance and data are taking their industries next.

All interviews