For agents and developers

API

Bots and agents trade Motion the same way people do: they sign their own transactions. The API reads the markets for you and builds the transactions. It never holds a key.

Paper trading: liveTrade play SOL through the API today. Live markets, on the same paths at the main address: open. Ansem's market is open for real trading since 25 November 2026, 02:36 UTC.

The idea

Basics

Base addresshttps://motion.trading/api/v1: the paper trading market until the hour the first live market opens, the live markets from then on
Paper trading, alwayshttps://motion.trading/api/practice/v1: the same paths, on play SOL, before and after that hour
FormatJSON in, JSON out
Amountsdecimal strings in SOL, such as "0.5", exact to nine places
Pricesdecimal strings, SOL for one unit, such as "1.00481639"
Timesmilliseconds since 1970, UTC
Marketsnamed by id: ansem, alon, slingoor
Wallets and positionsSolana addresses in base58
LimitsCounted for each visitor: one IPv4 address, or one block of 64 bits of IPv6. Most paths: 10 requests a second, bursts of 30. /snapshot, /wallets/{address}/state and /tx/status: 60 a second, bursts of 120. Building and sending orders (/tx/): 5 a second, bursts of 15, and 50 a second for all visitors together. Four open streams. Past a limit you get status 429, rate_limited, with a Retry-After header.

Paper trading mode

Everything on this page works today, on play SOL. Paper trading mode runs the same integer engine the program is built against, with the same limits, fees and liquidation rules as these docs.

In answers, mode is "practice" in this mode, some answers carry "practice": true, and the faucet's path is /practice/faucet: the path and the field keep the word practice.

What a market says

/markets, /markets/{id} and /snapshot describe a market with the same fields.

FieldMeaning
image, listed_atthe account's picture, and when the market was listed
change_24h, volume_24h, trades_24hthe last 24 hours: how far the price moved as a share (against the start price for a market younger than a day), the size traded in SOL, and how many trades
price, start_pricethe price now, and the price the market started at
average_price, average_secondsthe 10 minute average price, and the seconds it averages over: 600
liquidation_rulethe rule in words: a position is liquidated only when its line is crossed by the price and by the 10 minute average of the price, both
band_close_gatehow far, as a share, the price may stand from the average on an owner's wrong side before a band rule close waits: "0.002"
waitingSOL in this market set aside for owners of positions the band rule closed. Always "0" in paper trading mode, where it goes back to the wallet at once
smallest_orderthe smallest order, in SOL of size: "0.01"
band_low, band_highthe two prices this market can never leave. See the band
depththe size of the curve's SOL side when the market is balanced. It does not change
long_size, short_sizethe size open on each side, in SOL at entry
long_units, short_unitsthe units each side holds
long_full, short_fullhow full each side is, from "0.0000" to "1.0000": the units the side holds against the units the band lets it hold. At 1 the side is at the edge of the band and an open on it is refused
side_capthe most one side may hold, in SOL at today's price
max_transactionthe largest size one transaction may carry, in SOL
fundingpaying_side, which side pays; rate_hour, the rate from the funding formula as a share of size an hour, the most the crowded side pays now; max_rate_hour, the setting the rate is drawn from; and receiver_cap, how many times the payers' rate the light side may receive. The crowded side pays less when it holds more than receiver_cap times the units of the light side, and nothing when the other side is empty
cushion, cushion_capwhat the market's cushion holds, and its cap. A market starts with an empty cushion, in paper trading mode as on live markets, and the cushion fills from the fees the market takes
fee, min_marginthe trading fee as a share of size, and the smallest margin
max_leverage_long, max_leverage_shortthe most leverage a new position of 1 SOL of size is offered on each side at the price of this second, to one decimal and never rounded up; null when that side is full. Away from the middle of the band it is under the tier's top. See leverage on offer
tiersthe size tiers: for each, the largest position size in SOL, the top leverage, the margin to open and the liquidation line as shares of size. The 20x tier's line is "0.02"
opens_pausedtrue when new positions are paused. Closing still works

What a position says

/markets/{id}/positions, /wallets/{address}/positions and /wallets/{address}/state describe a position with the same fields. Beside side, size, units, margin, entry price, equity and profit:

FieldMeaning
liquidation_pricean estimate of the price at which the position falls under its line
liquidatabletrue when the position is under its line at the market price and at the 10 minute average price: a liquidation would be accepted now
under_line_nowtrue when it is under its line at the market price alone, which is not enough to liquidate it
band_needwhat the position must hold at all times, in SOL: what the price could still cost it inside the band, and its liquidation line counted at the far edge of the band
band_shorttrue when the margin, after funding, is under band_need: the position can be closed by the band rule
band_closabletrue when a band rule close of the position would be taken at this second: it is band_short, it is not liquidatable (a liquidation comes first), and the price stands no further than band_close_gate from its 10 minute average on the owner's wrong side. A position that is band_short and not band_closable waits for the price
band_close_in_hoursthe hours until funding wears the margin under band_need at the funding rate of this second; null while the position receives funding or pays none. Add margin to push it back
heldSOL that already waits for this wallet in this market from an earlier band rule close. Always "0" in paper trading mode

A wallet's state also carries waiting: one entry for each market where money waits for the wallet, with market, held (what a band rule close set aside; it is the wallet's already) and owed (what a close could not be paid at the time). On live markets it is collected with /tx/claim, kind waiting. In paper trading mode it is always empty.

Place a trade

1. Quote

A quote changes nothing. It tells you what the order would do right now.

bash
curl "https://motion.trading/api/v1/quote?market=ansem&side=long&margin=0.5&leverage=5"
json
{
  "market": "ansem",
  "side": "long",
  "margin": "0.5",
  "leverage": 5.0,
  "size": "2.5",
  "price_before": "1.000588909",
  "max_leverage": 20.0,
  "entry_price": "1.000755624",
  "price_after": "1.000922368",
  "liquidation_price": "0.816943",
  "fee": "0.0025",
  "you_pay": "0.5025",
  "transactions": 1,
  "allowed": true
}

If the order would be refused, allowed is false and reason says why, with the same codes as the errors below.

max_leverage is the largest leverage, to one decimal and never rounded up, at which this margin opens here right now, by the same check the order itself goes through. It depends on where in the band the order fills: under 20 away from the middle of the band. An order past it is refused with band_margin.

An order added to a position the wallet already holds, and an order that needs more than one transaction, is held one part in a thousand under its tier's limit, because funding can run before its last transaction lands. So for a small addition to a large position max_leverage is a little under the tier's top. An order that is over that limit by no more than half a percent of its own size is sized down to fit, and size in the quote says the size it will have; an order further over is refused with tier_limit. Both modes plan an order with the same code and name the same max_leverage.

liquidation_price is an estimate of where the position would fall under its line. Compare it with the market's band_low and band_high. In this example it is far below band_low, so a price move alone cannot liquidate this position. Only funding it pays can bring that price closer.

2. Build

bash
curl -X POST "https://motion.trading/api/v1/tx/open" \
  -H "Content-Type: application/json" \
  -d '{"wallet":"YOUR_WALLET","market":"ansem","side":"long","margin":"0.5","leverage":5,"slippage_bps":50}'
json
{
  "transactions": ["AQAAAA...base64..."],
  "worst_price": "1.005759402",
  "worst_prices": ["1.005759402"],
  "expires_at": 1795475199000,
  "quote": { "entry_price": "1.000755624", "liquidation_price": "0.816943", "fee": "0.0025" }
}

slippage_bps sets your worst fill: 50 means each transaction may fill at most 0.5% worse than its own expected fill. It can be at most 300. If the price moved further, the transaction is refused and nothing is taken. worst_prices holds the worst fill of each transaction, and worst_price is the last of them. A large order comes back as several transactions. Send them in the order given.

Send expected_entry, the entry price your screen showed, and an order whose fill would be further from it than slippage_bps is refused with slippage instead of filled at a price you never saw.

3. Sign and 4. Send

Sign with your own key, then post the signed transaction to /tx/send.

typescript
import { Keypair, VersionedTransaction } from "@solana/web3.js";

const API = "https://motion.trading/api/practice/v1";   // paper trading; /api/v1 for the live markets once they open
const wallet = Keypair.generate();               // paper trading: any keypair, a fresh one is fine

async function post(path: string, body: unknown) {
  const res = await fetch(API + path, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body),
  });
  const json = await res.json();
  if (!res.ok) throw new Error(json.error.code);
  return json;
}

const built = await post("/tx/open", {
  wallet: wallet.publicKey.toBase58(),
  market: "ansem",
  side: "long",
  margin: "0.5",
  leverage: 5,
  slippage_bps: 50,
});

for (const b64 of built.transactions) {
  const tx = VersionedTransaction.deserialize(Buffer.from(b64, "base64"));
  tx.sign([wallet]);                              // the key never leaves your machine
  const sent = await post("/tx/send", { transaction: Buffer.from(tx.serialize()).toString("base64") });
  console.log(sent.signature, sent.result);
}
python
import base64, requests
from solders.keypair import Keypair
from solders.transaction import VersionedTransaction

API = "https://motion.trading/api/practice/v1"    # paper trading; /api/v1 for the live markets once they open
wallet = Keypair()                               # paper trading: any keypair, a fresh one is fine

built = requests.post(f"{API}/tx/open", json={
    "wallet": str(wallet.pubkey()), "market": "ansem", "side": "long",
    "margin": "0.5", "leverage": 5, "slippage_bps": 50,
}).json()

for b64 in built["transactions"]:
    unsigned = VersionedTransaction.from_bytes(base64.b64decode(b64))
    signed = VersionedTransaction(unsigned.message, [wallet])     # the key never leaves your machine
    sent = requests.post(f"{API}/tx/send", json={"transaction": base64.b64encode(bytes(signed)).decode()}).json()
    print(sent["signature"], sent["result"])

Both were run against this API as written here. A complete agent in one file is on the agents page.

After you send

/tx/send answers within about two seconds with one of three things: the fill in result, a refusal as an error, or, on live markets, "kind": "pending" in result when the chain has not confirmed the transaction yet. A pending order can still land: do not send it again. Its answer carries signature, poll, the address to ask, and last_valid_block_height, after which it can no longer land. In paper trading mode an order is decided at once and is never pending.

bash
curl "https://motion.trading/api/v1/tx/status?signature=YOUR_SIGNATURE"
json
{
  "signature": "cXhEuPtZhmRJiGXfv38y4xY74PNQHSCKq3EemPmgAg4Yie4TFkERk3QHV2x9WnQCJBuRjQ5opkhN3vxc7HTxWti",
  "practice": true,
  "status": "confirmed",
  "result": { "kind": "open", "market": "ansem", "units": "2.498112364", "price": "1.000755624", "fee": "0.0025" },
  "error": null,
  "slot": 4488687850
}

GET /tx/status says what became of a transaction by its signature. status is confirmed (with the same result its send would have given), failed (with error, as the send would have answered), expired (it is in no block and can no longer land: nothing was filled), pending (still on its way) or unknown (never seen here). On live markets /tx/send also takes "wait": "processed": then the answer comes as soon as the transaction is in a block, with "kind": "processed", and promises no fill, because that block can still be dropped. Every send answer also carries commitment, slot and timing, how long each step took in milliseconds.

Close a position

bash
curl -X POST "https://motion.trading/api/v1/tx/close" \
  -H "Content-Type: application/json" \
  -d '{"wallet":"YOUR_WALLET","market":"ansem","fraction":"1","slippage_bps":50}'

fraction is the share of the position to close, from just above 0 to 1. Sign and send what comes back the same way. A position cannot be closed in the slot it was opened, so leave half a second between the two. A close that would leave less than 0.01 SOL of size closes the whole position. expected_exit works as expected_entry does for an open.

Live data

One stream carries every event, as server sent events: trade, liquidation, band_close, burn, a row of /fund/burns, and price, which comes right after every trade with the trade's id. In paper trading mode also funding. There is no depth event, because a market's depth does not change. Reconnect with the last event id you saw and nothing is missed.

bash
curl -N "https://motion.trading/api/v1/stream?markets=ansem,alon"
text
event: trade
id: 191
data: {"id":4751,"market":"ansem","kind":"open","side":"long","size":"4.820851168","price":"1.000588909","wallet":"GK9B...","simulated":true,"signature":null,"time":1795475139751}

event: price
id: 192
data: {"market":"ansem","price":"1.000588909","time":1795475139751,"trade":4751}

Run a liquidator

Anyone can liquidate a position that is under its line at the market price and at the 10 minute average price, and whoever sends it earns 5% of what the position has left, at least 0.001 SOL and never more than what is left. On live markets the band rule's close is open to anyone too, through /tx/band_close, and pays its sender 0.0005 SOL. In paper trading mode the keeper sends every band rule close itself and that path answers conditions_not_met.

  1. Read /markets/{id}/positions. It lists the positions nearest their liquidation price first. liquidatable says whether a liquidation would be accepted right now; under_line_now alone is not enough. On live markets band_closable says whether a band rule close would be; band_short alone is not enough while the price gate is shut.
  2. Post the position's address to /tx/liquidate, or on live markets to /tx/band_close, with your wallet as the sender.
  3. Sign and send. If someone was faster, the answer is not_liquidatable, or not_band_short, and nothing is lost. A band rule close also answers price_gate while the price stands too far from its 10 minute average on the owner's wrong side; try again once the average has followed.

Errors

An error is a JSON body with a code and a plain message, and a matching HTTP status.

json
{ "error": { "code": "side_full", "message": "The long side is full right now." } }

A refusal by the market's rules, such as side_full, tier_limit, band_margin or too_large, comes with status 409.

CodeMeaning
bad_requesta field is missing or malformed; slippage_bps is above 300; or the order is under 0.01 SOL of size, in these words: "That is too small. The smallest order is 0.01 SOL of size."
not_foundno such endpoint. In paper trading mode /tx/referral_code answers this
unknown_marketno market has that id
opens_pausednew positions are paused in this market; closing still works
min_marginmargin is under 0.05 SOL
tier_limitthis size does not allow this much leverage, margin cannot be removed that far, or an addition would leave the position under its line
too_largethe position would be larger than 1% of depth, or the order needs too many transactions
side_fullthis side has reached the edge of the market's band. Wait for room, trade smaller or take the other side
band_marginon an open: "This much leverage is not on offer at this price. The margin must cover how far the price can still move against the position, and its liquidation line there. Use less leverage: the quote says how much is on offer." On taking margin out: "Margin can be removed down to what this position must keep: what the price could cost it, its liquidation line at the far edge of the band, and a little more to carry its funding."
opposite_side_openthe wallet has a position on the other side; close it first
same_slota position cannot be closed in the slot it was opened
slippagethe price moved past your worst fill, or the order would fill further from your expected_entry or expected_exit than slippage_bps; look again and build the order again
insufficient_fundsthe wallet cannot cover margin and fee
no_positionthe wallet has no position in this market, or no position has that address
not_liquidatablethe position cannot be liquidated: "Its line must be crossed by the price and by the 10 minute average of the price, both." Or it is already gone
not_band_shortlive markets: "This position still holds what it must hold at all times, or it is under its liquidation line and is liquidated instead." Status 409
price_gatelive markets: not right now, the price stands too far from its 10 minute average on the owner's wrong side. It passes once the average has followed. Status 409
conditions_not_metthere is nothing to do right now: nothing to sweep; a market's depth does not change, so /tx/grow_depth always answers this; in paper trading mode /tx/band_close answers this; on live markets also: the wallet is already a referral code, or nothing waits or is there to claim
unknown_transactionthe transaction was not built here, was already sent, or is too old. Status 404
bad_signaturethe transaction is not signed by the wallet it was built for
expiredthe order is past its expires_at; build it again
faucet_not_neededthe wallet still holds 1 play SOL or more
rate_limitedslow down; see the Retry-After header (1 second from the web server, 5 from the service). On live markets the relay behind /tx/send also answers this at once when the wallet already has an order on its way, or when too many orders are on their way: wait for the outcome, then send. And a wallet's first read on live markets can be told "Many wallets are connecting right now. Ask again in a moment." when many wallets connect at once: ask again after the Retry-After. Status 429
api_downthe service is not answering right now. An order you just sent may still have gone through: look at your positions before sending it again. Status 503
not_openthis part of the API is not open yet

When markets go live

Ansem's market is open for real trading since 25 November 2026, 02:36 UTC. The paths, the fields and the four steps stay the same. Three things change:

Only on live markets

Next