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.
The idea
- Reading is open. Markets, prices, positions, the liquidation map, the burn. No key, no account.
- Trading is four steps: ask for a quote, ask for the transaction, sign it yourself, send it.
- You keep your key. The API returns unsigned transactions. Your code signs them locally. Never send a private key or a seed phrase to any API, ours included.
- It is built for agents. One page of rules, plain JSON, exact numbers as strings, and every refusal comes with a code. See for AI agents.
Basics
| Base address | https://motion.trading/api/v1: the paper trading market until the hour the first live market opens, the live markets from then on |
| Paper trading, always | https://motion.trading/api/practice/v1: the same paths, on play SOL, before and after that hour |
| Format | JSON in, JSON out |
| Amounts | decimal strings in SOL, such as "0.5", exact to nine places |
| Prices | decimal strings, SOL for one unit, such as "1.00481639" |
| Times | milliseconds since 1970, UTC |
| Markets | named by id: ansem, alon, slingoor |
| Wallets and positions | Solana addresses in base58 |
| Limits | Counted 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.
- Any Solana keypair is a wallet. Make a fresh one. It needs no SOL and never touches a chain.
- Every wallet starts with 10 play SOL. When it falls under 1, refill it at
/practice/faucet, once every 10 minutes. - The transactions are real Solana transactions, so you sign them with the same library calls you will use live. Each one names a paper trading order and carries a made up block hash, so Solana itself would refuse it. It can never land on chain or cost a fee.
- Send signed transactions to
/tx/send, and nowhere else. An order stays valid for theorder_valid_secondsof/status: 60 in paper trading mode, about half a minute on live markets. - One paper trading market is shared by everyone. Agents on the API and people in the app trade it together, beside a simulated crowd. Trades and positions of the simulated crowd are marked
"simulated": true. - Keep an eye on your positions. A paper trading position is closed at the market price after 20 minutes with no request from its wallet, and what it was worth goes back to the wallet's play SOL. Any request that names the wallet counts: its state, its positions, its history, its rewards, a quote or an order for it. Such a trade has kind
close, with"reason": "idle", the play SOL that went back inreturned, and a note that says so. A side of a market has a limit, and this keeps the positions of traders who have left from filling it. - The built in keeper waits 2 seconds before it liquidates, so your liquidator can be faster and earn the bounty.
- Not in paper trading mode: referral codes, reward claims, referral payouts and staking.
- The band rule runs here too. The keeper closes a position by the band rule when funding has worn its margin under what it must hold at all times, its
band_need. Such a trade has kindband_closeand a note that it was closed by the band rule, not liquidated, and what the position was worth is back in your paper trading balance at once. There is nothing for you to send or collect. - The paper trading market can be reset at any time. Play SOL has no value.
What a market says
/markets, /markets/{id} and /snapshot describe a market with the same fields.
| Field | Meaning |
|---|---|
image, listed_at | the account's picture, and when the market was listed |
change_24h, volume_24h, trades_24h | the 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_price | the price now, and the price the market started at |
average_price, average_seconds | the 10 minute average price, and the seconds it averages over: 600 |
liquidation_rule | the 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_gate | how 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" |
waiting | SOL 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_order | the smallest order, in SOL of size: "0.01" |
band_low, band_high | the two prices this market can never leave. See the band |
depth | the size of the curve's SOL side when the market is balanced. It does not change |
long_size, short_size | the size open on each side, in SOL at entry |
long_units, short_units | the units each side holds |
long_full, short_full | how 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_cap | the most one side may hold, in SOL at today's price |
max_transaction | the largest size one transaction may carry, in SOL |
funding | paying_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_cap | what 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_margin | the trading fee as a share of size, and the smallest margin |
max_leverage_long, max_leverage_short | the 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 |
tiers | the 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_paused | true 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:
| Field | Meaning |
|---|---|
liquidation_price | an estimate of the price at which the position falls under its line |
liquidatable | true 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_now | true when it is under its line at the market price alone, which is not enough to liquidate it |
band_need | what 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_short | true when the margin, after funding, is under band_need: the position can be closed by the band rule |
band_closable | true 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_hours | the 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 |
held | SOL 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.
curl "https://motion.trading/api/v1/quote?market=ansem&side=long&margin=0.5&leverage=5"{
"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
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}'{
"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.
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);
}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.
curl "https://motion.trading/api/v1/tx/status?signature=YOUR_SIGNATURE"{
"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
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.
curl -N "https://motion.trading/api/v1/stream?markets=ansem,alon"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.
- Read
/markets/{id}/positions. It lists the positions nearest their liquidation price first.liquidatablesays whether a liquidation would be accepted right now;under_line_nowalone is not enough. On live marketsband_closablesays whether a band rule close would be;band_shortalone is not enough while the price gate is shut. - Post the position's address to
/tx/liquidate, or on live markets to/tx/band_close, with your wallet as the sender. - Sign and send. If someone was faster, the answer is
not_liquidatable, ornot_band_short, and nothing is lost. A band rule close also answersprice_gatewhile 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.
{ "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.
| Code | Meaning |
|---|---|
bad_request | a 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_found | no such endpoint. In paper trading mode /tx/referral_code answers this |
unknown_market | no market has that id |
opens_paused | new positions are paused in this market; closing still works |
min_margin | margin is under 0.05 SOL |
tier_limit | this size does not allow this much leverage, margin cannot be removed that far, or an addition would leave the position under its line |
too_large | the position would be larger than 1% of depth, or the order needs too many transactions |
side_full | this side has reached the edge of the market's band. Wait for room, trade smaller or take the other side |
band_margin | on 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_open | the wallet has a position on the other side; close it first |
same_slot | a position cannot be closed in the slot it was opened |
slippage | the 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_funds | the wallet cannot cover margin and fee |
no_position | the wallet has no position in this market, or no position has that address |
not_liquidatable | the 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_short | live 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_gate | live 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_met | there 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_transaction | the transaction was not built here, was already sent, or is too old. Status 404 |
bad_signature | the transaction is not signed by the wallet it was built for |
expired | the order is past its expires_at; build it again |
faucet_not_needed | the wallet still holds 1 play SOL or more |
rate_limited | slow 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_down | the 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_open | this 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:
- The SOL is real, and so is liquidation.
- The transactions carry instructions for the Motion program. You can send them to Solana through any RPC, or keep using
/tx/send. - You can skip the API altogether: everything it builds is a plain instruction to the program, which anyone can call directly. See the tech.
Only on live markets
POST /tx/band_closebuilds the band rule's close of a position whose margin funding has worn under what it must hold at all times, itsband_need. Anyone may send it, and the sender gets 0.0005 SOL. What the position is worth, less the closing fee and that 0.0005 SOL, waits for its owner.POST /tx/claimwith kindwaiting, amarketand anowner, builds the payout of what waits for that owner in that market. Anyone may send it; the SOL goes only to the owner. With kindreferralit builds the payout of a wallet's referral earnings. With kindrewardsit answersnot_openuntil season one closes.POST /tx/referral_codebuilds the transaction that makes a wallet a referral code. The wallet's address is the code.- A send can answer
pending, as after you send describes, and takes"wait": "processed". - Every endpoint that builds transactions takes
version, 0 (the default, which every wallet signs) or 1, and says it back in its answer. /statusand/snapshotalso carrychain, the name of the chain the way wallets spell it./statusalso carriesprogram,priority_fee,push,orders_on_their_wayandorders_limit./statuscarrieshistory, which says how far the service's history is behind the chain:behind, how many of the program's transactions it has not read yet, andoldest_waiting, the chain's time of the oldest of them in seconds,nullwhen none waits. Trades, feeds and candles are behind the chain by that much; prices, positions and quotes are read from the chain itself and are not. In paper trading mode nothing ever waits:behindis 0 andoldest_waitingisnull.