info.version in the
OpenAPI spec. Breaking changes are marked, with the date they take
effect. See Versioning for what counts as breaking.
RFQs
- On Kalshi and Polymarket US,
POST /v1/rfqsandPOST /v1/rfqs/{id}/acceptnow follow the venue’s private stream while they wait, so initial quotes and accept results return sooner. If the stream is unavailable, Lean reads the venue as before.GET /v1/rfqs/{id}still reads the latest quotes from the venue when you call it. - A Kalshi accept that would previously end as
acceptance_unconfirmedbecause the maker replaced the quote now returnsrejected, with the venue’s reason when it gives one. If you receiverejected, read the RFQ again before choosing another quote. - The RFQs reference now lists create, retrieve, accept and cancel.
Markets
- Breaking, effective 2026-12-03:
volume_24h_usdinPOST /v1/discover, its batch and taxonomy responses is now dollars traded over the last 24 hours. It was previously the number of contracts traded. Volume computed from trades counts each fill at its YES price times its contracts; a Hyperliquid or Lighter market can instead carry the venue’s own reported 24h dollar notional, which on Hyperliquid adds YES- and NO-token notional.min_volume_24h,max_volume_24hand thevolumesort use the same dollars, so a threshold you send now selects by dollars rather than contracts.
Rewards
- Each Kalshi program in
GET /v1/rewards/programsalso carriesperiod_reward_centicents, the exacttarget_size_fpdecimal string,last_rest_update,created_atandupdated_at.last_rest_updateandupdated_atrecord when a Kalshi refresh last inserted or changed the program; an unchanged refresh leaves them as they were.
Limit chases
GET /v1/limit-chasesshows an edit Lean has accepted but not yet applied as reading the limit chase by id does: the edited values withedit_pending: true. A list read just after an edit can still trail it. See Change a limit chase.
Orders
- Each
execution.legs[]entry of an order preview carriesreward: for a leg on a Polymarket, Kalshi or Polymarket US market with an active reward program, whether the part agtcorgtdorder would rest would score at its price and size, withreasonswhen it would not.nullfor a market without one.
Orders
- Amending a resting Kalshi or Polymarket US order to a smaller size at
the same price, with the key that placed it, now changes the venue order in place. The order
keeps its Lean ID,
client_order_idand fills, and a Kalshi order keeps its place in the queue. Every other amend still cancels and replaces. - An amend in place whose venue order changed meanwhile returns
409 CONFLICT. Read the order back and try again. - A Polymarket US amend keeps
post_only.
- Each Polymarket US balance from
GET /v1/balancescan carrypolymarket_us_details, withbuying_power_usd,asset_available_usd,open_orders_usdandunsettled_funds_usd.
0.1.0: trades and market lifecycle streams, closed event markets, reward programs, Kalshi subaccounts, weather, resolutions
Streams
- The WebSocket stream has
tradesandmarket_lifecyclechannels, each naming a venue listing by itsticker.tradessends trades as they happen, with maker and taker details.market_lifecyclesends status changes, with the result once known, and tick size changes. Live and test keys get the same frames. A session that falls behind on either is closed with1013andRATE_LIMITED.
- An event listing takes
include_closed=trueto list closed event markets from the last 30 days, alone or withstatus=closed. GET /v1/resolution/marketslists recent Kalshi and Polymarket resolutions, newest first and once per event, 100 per page by default and 200 at most.GET /v1/weather/{stationCode}returns a weather station’s last 24 hours of readings, its forecasts and when the next reading is expected.
GET /v1/kalshi/subaccountslists your Kalshi subaccounts and their balances. Test keys get an empty list.GET /v1/rewards/programslists active reward programs on Kalshi, Polymarket US and Polymarket, filtered byvenue,ticker_prefixandmin_daily_reward, 200 per page by default and 1000 at most.
- The TypeScript and Rust SDKs cover the new endpoints and stream channels.
Rewards
GET /v1/rewards/earningsreturns what the key’s account earned in Polymarket rewards today, an estimate for the whole day and its share of each market’s pool. Test keys get zeros.
Streams (breaking)
- A WebSocket
bookchannel now sends the whole book once, thenbook_deltaframes holding only the levels that changed since the book Lean last published. A quantity of"0"removes a level. A book with no change gets an empty delta about once a second. bookandbook_deltaframes carry asequence, and a delta carries theprev_sequenceit follows. A session that reads too slowly, or a market whose venues change, gets a wholebookframe again. The TypeScript and Rust SDKs apply deltas and still hand you the whole book.- Stream book quantities keep the venue’s precision, as
GET /v1/markets/:id/bookreturns them, so a level holding a fraction of a share is listed. - A session can hold up to 1000 channels.
- A key can hold up to 500 open streams at once, up from 50. One more is closed with
1013andRATE_LIMITED.
Account
- A test position’s cost basis now includes the fees its buys paid, as a live position’s does.
A settled test position’s
unrealized_pnl_usdnow matches whatGET /v1/pnlrealized for it. - A transfer that expired before anything was written for it shows when it expired in
updated_at.
requestIdin the TypeScript SDK andrequest_idin the Python SDK return nothing, rather than throwing, when an error body has nometa.- An MCP tool called with arguments its schema refuses now returns a tool error in the same
shape as an API error, with code
INVALID_INPUTand each refused field indetails.issues, so the assistant can correct the call.
0.1.0: event listings reach back 48 hours, titles name the event, faster search and category listings
Markets
- An event listing’s
ends_afternow defaults to 48 hours ago, so a market the venue keeps trading after its scheduled close, such as a daily weather market waiting for the day’s reading, stays listed. Passends_afterto list only markets that have not reached their scheduled close. - An event market’s
titlestarts with its event title when the venue names the market only by its range or outcome, so a daily temperature market readsHighest temperature in Miami on Nov 24, 2026? 77° to 78°: Yesinstead of77° to 78°: Yes. searchon an event listing now matches whole words of the venue market title, its event title and its outcome names, the last word as a prefix, sorainfindsRainandRainfallbut no longerUkraine. It answers faster on broad words. An event listing cursor issued withsearchbefore this change is refused; start that listing again from its first page.searchon a sports listing answers faster on broad words that used to time out.- An event listing with a
categorythat has few open markets, such astransportationorsociety, answers in about a second instead of timing out. - A read that runs out of time, such as a broad market listing, now returns
503 UPSTREAM_ERRORwithRetry-Afterinstead of500 INTERNAL_ERROR. A busysearchsendsRetry-Aftertoo.
POST /v1/orders/preview-batchrefuses a body with a field other thanorderswith400 VALIDATION_ERROR, as the other order endpoints do.
Orders
- Previews and quotes now price on books at most about 2 seconds old and read funds from a read
at most 30 seconds old, so they answer faster.
POST /v1/ordersstill reads everything fresh. - When Kalshi throttles a balance read, a preview answers from the last balance read instead of failing.
- A venue route that cannot reach Lean’s cache returns
503 UPSTREAM_ERRORinstead of500 INTERNAL_ERROR. - Quantities are summed as decimals, so a total reads
66.9rather than66.89999999999999, and fractional quantities are kept.
MCP server
- Lean hosts the MCP server at
https://api.lean.xyz/mcp. Add the address to Claude, ChatGPT, Claude Code, Codex, Cursor or VS Code, log in with Lean, and choose what the assistant gets, as when you create a key. See Connect Lean to your assistant. watch_streamwatches for up to 25 seconds per call, down from 50, so a hosted call always answers before the connection times out. Call it again to keep watching.- API keys: a key granted to an assistant this way carries
oauthClient, the assistant it was granted to. It isnullfor a key made in settings.
Account
GET /v1/positions,GET /v1/pnlandGET /v1/riskanswer faster on accounts with many holdings. Position marks no longer wait for the Polymarket US or Lighter book of a market no one read in the last few seconds: that holding keeps its source’smark_pricefor the read, and a read a few seconds later marks it from the book.
Markets
- An event listing’s
next_cursornow works only with thecategory,venue,search,ends_afterandends_beforethat listed it, and is refused with400 VALIDATION_ERRORotherwise. Event listing cursors issued before this change are refused too; start the listing again from its first page. legs[].resolution.rulesreads a Polymarket US market’s rules once. The venue stores the same text as its main and secondary rules, and both used to be shown.- The docs now say that
searchon an event listing matches text anywhere in a title, even inside a longer word, and that a market a venue stopped trading is refused with409on quotes, previews and orders while its book still reads.
- The WebSocket docs list every error a frame sent
before
authgets, and say that abookchannel naming a venue symbol for more than one market ends withbook_endedandunknown_market.
MCP server
watch_streamwatches order updates, best price changes of up to 10 books, positions and balances for up to 50 seconds and returns what arrived, so an assistant can wait for a fill without polling. It needs Node.js 22.4 or later.preview_orderandpreview_orders_batchare read tools, offered with a Read only key as the API allows.- With a test key and trading on,
reset_test_modestarts the test account over. - A rate limit error carries
retry_after_seconds, errors add ahintwhere the next step is clear, and responses are compact JSON. - The tool schemas carry the API’s own caps, so a value the API would refuse is caught first:
book depth, trades per page, market IDs per price read, limit chase offset ticks and
conditional sell followers. A stop loss or limit chase
expires_atmust be in UTC ending inZ.
Markets
GET /v1/markets/{id}/bookandGET /v1/priceswait up to a second for the Polymarket US or Lighter book of a market no one read in the last few seconds, as quotes and orders do, instead of listing the venue inunavailable. A stop loss or take profit trigger check waits the same way instead of refusing with503 UPSTREAM_ERROR, and position marks wait within their read deadline.
Orders
- A Kalshi
fokorder that Kalshi cannot fill in full readscanceledwithfilled_quantity"0", as aniocorder that finds no match does. - A Polymarket
gtdorder that reachesexpires_atreadsexpired. It used to readcanceled. - An order or preview on a market every venue has stopped trading returns
409 CONFLICTwithdetails.reason: "MARKET_NOT_TRADABLE"before any venue’s own order rules, so a Polymarketiocbuy sized withquantityon such a market gets the409, not a400. A Lighter window that has ended answers the same way. - Orders and fills on a Lighter window name it by
titleandoutcome, as its position does. They used to readnull. - A
canceledrow ofPOST /v1/orders/cancel-batchmeans every leg’s cancel was accepted. Itsordercan still readcancel_requesteduntil each venue confirms, as the docs now say. POST /v1/positions/closesells Lighter positions with the rest, andvenue: "lighter"scopes it to them. Its limit sells on Lighter areioc. It used to answernothing_to_closefor them.legs[].venueandunavailable_venuescan namelighter.
GET /v1/account/configlistslighterinvenues, ready when a Lighter account is connected to the key’s trading account.GET /v1/pnl/historyreads anendafter now as now, and the response’sendshows the time it used.
- Breaking, effective 2026-11-24:
GET /v1/balances,GET /v1/account/config,GET /v1/risk,GET /v1/conversions, the list and read of stop losses, limit chases and conditional sells, andGET /v1/transfers/{id}refuse a query parameter with400 VALIDATION_ERROR, since they take none. They used to ignore it. - Breaking, effective 2026-11-24: a query parameter sent more than once returns
400 VALIDATION_ERRORnaming it, instead of a type error such asreceived nan.
Orders
- Breaking, effective 2026-11-24: a
fokorder no longer goes to Polymarket US, which can fill part of a fill or kill order and expire the rest. Afokorder goes whole to Polymarket, else Kalshi. On a market listed only on Polymarket US it is refused with400 VALIDATION_ERROR; sendiocinstead. Afokbuy sized withquantitygoes to Kalshi only. - An
iocorfokbuy on Polymarket that bought every share its dollars could buy readsfilled. It used to readcanceledwhen Polymarket’s rounding of the spend to whole cents left it a fraction of a share short ofquantity.
Markets
GET /v1/marketslists event markets on all four prediction venues: Polymarket, Polymarket US, Hyperliquid and Kalshi.venue=polymarket_usandvenue=kalshitake event listings. Kalshi multivariate (parlay) markets are not listed.- A Kalshi event Lean has not categorized takes the category Kalshi files it under, such as
politicsfor Kalshi’s Elections, elseuncategorized. - A
pmus:ticker or Kalshi market ticker of a market outside sports names its event market, insymbol=and wherever a market ID is taken, when that listing pays one outcome.
- Event markets on every venue trade single-venue through the normal order API, in live and test
mode. Sports markets keep smart order routing; a routed order on an event market is refused with
ROUTE_NOT_EXECUTABLE. - Orders, fills and positions on Kalshi and Polymarket US event markets name the event market by
its
mkt_…ID, title and outcome, as on Polymarket and Hyperliquid.POST /v1/positions/mergestays Polymarket and Hyperliquid only.
- Subscribe to an event market’s book on
/v1/wswith abookchannel naming itsmkt_…ID. The stream has no trades, quotes or fills channel; eachordersframe carries the order’s fills. ordersframes name an event market by itsmkt_…ID, title and outcome.
API keys
POST /api-keystakesexpiresInDays: nullfor a key that never expires, and the dashboard adds a Never expires switch. See Authentication.
- Each
bookframe has asnapshotfield. It istrueon the first frame after you subscribe, which is the newest book Lean already holds and can have anas_ofup to about a second old, andfalseon every later frame. See Streaming. - A
bookchannel whosemarket_idnames no market, or whose market closed, sends onebook_endedframe and stops, instead of staying silent. See WebSocket. subscribedandunsubscribedframes list each channel once, even when the request named it twice.
Markets
GET /v1/marketslists Polymarket and Hyperliquid markets outside sports, such as elections, central bank decisions and coin prices on a date. Pass acategoryother thansportsorcrypto(politics,economy,businessand more), orkind=event. Each venue market is two markets, itsyesandnosides, withkind: "event", aneventinstead offixtureandgroup, one leg andequivalence: "single_venue". See Event markets.GET /v1/marketstakeskind, andends_afterandends_beforeto list event markets by scheduled close. With nocategoryorkindit still lists sports markets, andcategory=cryptostill lists Lighter crypto windows;kind=event&category=cryptolists event coin-price markets.- A Polymarket token ID,
pm:orhl:ticker, or Hyperliquid book coin of a market outside sports now names its event market, insymbol=and wherever a market ID is taken. - Books, prices, quotes, trades, candles and the
bookstream channel take event markets.
- Previews, orders, amends, cancels, stop losses, limit chases and conditional sells take event
markets, with the same order types as sports markets, in live and test mode.
game_startis refused on them. - Routed orders stay sports only: a routed order on an event market is refused with
ROUTE_NOT_EXECUTABLE, since it lists on a single venue.
GET /v1/riskgroups event market holdings under theircategoryinby_category, withsport: null.
Positions
GET /v1/positionsanswers within about 3 seconds. A venue that has not answered by then is listed inunavailable, and the other venues are still returned.
- The
bookstream channel sends a frame as soon as a venue book changes, and at least once a second otherwise.
- Conditional orders made in the Lean app that rest on several markets at once are not
conditional sells, so
/v1/conditional-sellsdoes not list them.
Conditional sells
POST /v1/conditional-sellssells one position and, as it fills, sells the same number of shares of up to five others, each never below its floor price.GET /v1/conditional-sells,GET /v1/conditional-sells/{id}andDELETE /v1/conditional-sells/{id}list, read and cancel them. They run on Kalshi, Polymarket, Polymarket US and Hyperliquid. See Conditional sells.- A test key’s conditional sell is checked, listed, read and canceled like a live one but never
sells. Reset test mode clears them and counts them in
deleted_conditional_sells. - The MCP server adds
list_conditional_sellsandget_conditional_sell, and with thetradescopecreate_conditional_sellandcancel_conditional_sell.
PATCH /v1/stop-losses/{id}changes the trigger price, quantity or slippage limit of a stop loss or take profit that is still watching the market, keeping its id. See Change a stop loss.PATCH /v1/limit-chases/{id}changes the quantity, offset or price limit of an active limit chase, keeping its id. Where the venue amends in place, a smaller size keeps its place in the queue. A limit chase reads backedit_pendingwhile Lean applies the edit, andlast_errorwhen Lean refuses it. See Change a limit chase.- A limit chase takes
offset_shares, the most shares it lets rest ahead of it, andoffset_beat_best, to rest one tick better than the best price. Every limit chase reads backoffset_beat_best, andoffset_midpointfor one made in the Lean app that rests within a set distance of the midpoint. - The MCP server has
update_stop_lossandupdate_limit_chase.
Orders
gtdorders,expires_atgame_startincluded, now reach Hyperliquid. Hyperliquid has no order expiry, so Lean places the order asgtcand cancels what is left atexpires_at. It then readsexpired, like agtdorder on any other venue, and keeps any shares that filled. See Fill or kill and expiring orders.
Funding
GET /v1/conversionsshows the USDC and USDC.e in the account’s Polymarket wallet. Polymarket trades only with pUSD, so these are not cash until they are converted.POST /v1/conversionsconverts the whole balance of onesource_asset,usdcorusdc_e, into pUSD. A USDC.e conversion issettledonce it confirms. A USDC conversion issubmitted, and its pUSD arrives a few minutes later.- It needs the trade scope and follows the trading pause and venue limits. A test key holds
nothing to convert, so it is refused with
details.reasonNOTHING_TO_CONVERT. - When Lean cannot reach Polymarket’s relayer, a conversion is refused with
503 FEATURE_DISABLEDand nothing is submitted. - The MCP server has
get_convertible_balancesandconvert_to_pusd. - See Convert USDC to pUSD.
Deposits
GET /v1/deposits?venue=lists the latest deposits to your Polymarket or Hyperliquid addresses, newest first, each with itsstatus(detected,processing,completed,failedorrefunded), the amount credited and its transactions. Deposits through Relay or the Polymarket bridge are listed; pUSD sent straight to the Polymarket wallet is not. A test key reads an empty list. See Deposits through the API.
legs[].resolution.resultreadswon,lostorvoidonce a leg isresolved, andnullbefore. See Legs.
GET /v1/account/configreturnsvenues: each venue withstatusready,not_configuredorunavailable, so a client can see which venues it can order on before it orders.readymatches whatPOST /v1/ordersallows for the key. Keys are still connected in the Lean app only. A test key reads every venueready.
- A
gtdorder takesexpires_atgame_startto expire when its market’s game starts. It is refused once the game has started, and like any expiry it must be three minutes to thirty days away. See Fill or kill and expiring orders.
- New tools:
list_deposits,preview_orders_batch,create_routed_orderandexecute_routed_order. The routed order tools need theroutescope, like the transfer tools. See Build with AI.
Transfers
- Live keys can now transfer. A live transfer moves real cash through Relay between
Polymarket, Hyperliquid and Lighter, in any direction. Live keys no longer get
503 FEATURE_DISABLEDwithdetails.reason: "LIVE_TRANSFERS_UNAVAILABLE". from_venueandto_venuealso takelighter. Test keys still move simulated cash between Polymarket and Hyperliquid only, and a test key that nameslightergets400 VALIDATION_ERROR.- A live quote’s
fee_usdis Relay’s price at that moment plus any fee the sending venue charges. The live minimum is 2 USD. - A live transfer has nothing to sign: its
authorizationisnulland it executes with"delegated"only, so the account must have enabled trading in the Lean app. An account moves one transfer at a time. - See Live transfers.
Markets
GET /v1/marketslists Lighter’s BTC and ETH 15 minute up or down windows withcategory=cryptoorvenue=lighter. Each market haskind: "time_window"and awindowinstead offixtureandgroup. Sports markets now carrykind: "sports". See Crypto windows.- Books, prices, trades, candles and the
bookstream channel cover Lighter markets, andvenuetakeslighteron those reads. A Lighterlt:ticker lists both markets of its window withsymbol=. - Quotes on Lighter markets are refused with
400 VALIDATION_ERROR.
POST /v1/orders/preview,POST /v1/ordersand cancels take Lighter markets, in live and test mode. Orders takegtdorioc, expire with their window, are sized in shares and cannot be amended. See Lighter.- An order’s
venueand legs, andGET /v1/orders?venue=, can namelighter.
Positions
- Every position has
redeemableandpayout_usd. A Polymarket holding of a resolved market that pays out isredeemableuntil it is redeemed; other venues pay resolved holdings out on their own.payout_usdis what the holding pays once its market resolves, andnullwhile it is open. POST /v1/positions/redeempays out every redeemable holding, or only those on onemarket_id, and lists each one with its payout.POST /v1/positions/mergeturns pairs of YES and NO shares on one market back into cash on Polymarket or Hyperliquid.- A venue symbol as
market_idsettles only that listing of a market listed more than once. - Both need the trade scope and follow the trading pause and venue limits. A test key redeems
and merges in simulation. Reset test mode undoes them and returns
deleted_settlements. - The MCP server has
redeem_positionsandmerge_positions. - See Redeem and merge.
Build with AI
- The Lean MCP server is the
@leanxyz/mcppackage on npm. It needs Node.js 22 or later, and an MCP client starts it withnpx -y @leanxyz/mcp, so you no longer need a copy of the source. See Run the Lean MCP server for Claude Desktop, Claude Code and Cursor settings.
Positions
- Each position in
GET /v1/positionsand thepositionsstream channel carriessettled:trueonce its market has resolved. Itsunrealized_pnl_usdstays its settlement payout minus cost, butGET /v1/pnlleaves it out of the account’s unrealized PnL. See Read positions. - A holding on a fixture that started more than 7 days ago keeps its
market_id,titleandoutcome. - A holding on a market the API does not list, such as a season futures market, takes its
titleandoutcomefrom the venue market; itsmarket_idstaysnull.searchmatches it.
GET /v1/pnlreportsmeta.sourceupstreamfor every read, the account included, since its unrealized amount marks open positions live. Each venue’supdated_atis now the read time, the same asas_of, instead of when the stored record last changed.
Venues
- Markets, quotes, books, trades, prices, orders, fills, positions, balances, PnL, risk, stop
losses and limit chases cover Kalshi and Polymarket US as well as Polymarket and Hyperliquid.
venuetakeskalshiandpolymarket_uswherever it names a trading venue. - Kalshi and Polymarket US accounts belong to the user, so every trading account and key of the
user shares their cash and shares. A live order there goes out under the user’s API key for
that venue, connected in the Lean app, and is refused with
403 FORBIDDENwithout one. See Kalshi and Polymarket US. - A quote, preview or order that needs a Polymarket US book Lean has not loaded yet answers
503 UPSTREAM_ERRORwithRetry-After. Send it again after that time. - A test key starts with 10,000 USD of simulated cash on Kalshi and on Polymarket US.
- Stop losses and limit chases run on every venue. They no longer refuse
hyperliquid. post_onlyorders go to Kalshi, Polymarket US and Hyperliquid.gtdorders go to Kalshi, Polymarket and Polymarket US. Afokorder goes whole to one venue: Polymarket, else Kalshi, else Polymarket US.- Paying from the other venue,
best_priceroutes, self-signed routed orders, deposits, withdrawals and transfers stay on Polymarket and Hyperliquid only.
Markets
- Every market leg has
fees: the formula (price_curveornotional_on_exit),taker_rate,maker_rateand, forprice_curve,exponent. They are the terms the preview charges, so a client can set a fee-aware limit price before previewing.feesisnullwhen the venue’s fee rate isn’t recorded. See Fees. GET /v1/marketstakesfixture(a fixture key) andgroup(a group key such asmoneyline:game), so one event’s market group loads in one request instead of a whole league.- Every market leg has
status, the venue market’s status (unopened,open,closed,resolvingorresolved). Anunopenedorresolvingleg has a live book on the Lean platform but staystradable: false, because its venue refuses orders. See Legs.
GET /v1/pricesreturnsbest_bid_quantityandbest_ask_quantity, top level and per venue: the shares at the best price, so a client can see how much an edge is worth before previewing.- Prices match the Lean platform’s orderbook. Best prices are snapped to the market’s tick.
midis the venue’s mid rounded down to the tick, and a book with only one side reads that side instead ofnull. One venue’s crossed book reads aspreadof0. last_trade_pricecounts a Hyperliquid trade of the opposite outcome at 1 minus its price, as Polymarket’s already did, so it is the latest trade on either outcome.
GET /v1/markets/{id}/candlesleaves out periods the Lean chart treats as unpriced (an open of 0 or a close below 0.001), as the chart does.
- Orders and fills carry the market’s
titleandoutcome, as positions do. - A canceled
iocorder and its canceled legs havestatus_reason.codeIOC_REMAINDER_CANCELED;filled_quantitysays how much filled first. POST /v1/orders/preview-batchpreviews 1 to 25 orders in one request and returns each one’s preview or error in order. It needs only thereadscope. See Preview orders (batch).- Orders carry
remaining_quantity: the shares still working on the venues,0once the order is final.avg_fill_priceis documented as excluding fees. - An order or leg the venue rejected or canceled after part of it filled reads
canceled, and one whose whole size filled readsfilled, as the Lean app reports them. - A Polymarket
iocorfoksell may go below the market’s minimum shares, down to0.01, so a position under the minimum can be closed. A sell that can rest keeps the minimum. - Closing positions skips a Hyperliquid remainder under one whole contract instead of sending a sell the venue refuses.
- Test positions are marked as the Lean portfolio marks live ones: Polymarket at the last trade,
Hyperliquid at the venue’s mid.
GET /v1/pnltotals their unrealized profit and loss exactly as it does for a live key, so a position on a resolved market counts none.GET /v1/pnl/historystays realized-only for test keys. See Test mode.
- A
400 VALIDATION_ERRORmessage names the first failing field and what is wrong with it, such asmarket_ids: At most 25 market ids per request; split larger sets across requests, and says how many more problems are indetails.
- Responses report key authentication time in the
Server-Timingheader (auth), and a key’s last-used time is written at most once a minute instead of on every request.
Requests
- Every endpoint that takes query parameters returns
400 VALIDATION_ERRORfor one it does not take, asGET /v1/marketsalready did, naming it indetails. A misspelled filter such asGET /v1/orders?stauts=openused to be ignored and return every order. Breaking: takes effect on release; remove any parameter an endpoint does not list.
Orders
GET /v1/orders?client_order_id=lists the orders any key of the account placed with that ID, not only the calling key’s, so an order placed before a key rotation can still be found. It combines with the other filters.- Quotes, previews and placement report a venue failure as
503 UPSTREAM_ERROR. They never returned502; the reference listed it by mistake.
- A cursor is tied to the list that issued it. An orders cursor sent to
GET /v1/fills, or any cursor sent to another list, returns400 VALIDATION_ERROR. Breaking: a cursor issued before this release is refused once with400; page that list again from the start.
- A path or method no endpoint serves returns the JSON
404 NOT_FOUNDenvelope, not plain text. - A malformed key returns
401 UNAUTHORIZEDwith “Invalid, expired or revoked API key”, the same as an unknown key, instead of “Missing API key”.
- When a venue already has some deposit addresses, the deposit address note names only the
network still missing one, such as Solana, and says the returned addresses are ready to use.
Hyperliquid’s
min_deposit_usdisnull: it has no minimum. See Funding.
Markets
GET /v1/marketswithsearchlooks only at the listings of games in the start window. The same search now returns the same markets every time; it used to drop nickname and typo matches, such asphilly, when it ran slowly. One- and two-letter searches no longer return503 UPSTREAM_ERROR.- A search that cannot finish in time returns
503 UPSTREAM_ERRORinstead of a partial list. GET /v1/markets/{id}/quoteandPOST /v1/orders/previewon a market Polymarket has stopped trading return409 CONFLICTwithdetails.reason: "MARKET_NOT_TRADABLE", as documented. They used to return500, or500and409at random for a market with both a YES and a NO Polymarket listing. The OpenAPI spec now lists this409on both routes.- When Polymarket answers that check with a response Lean cannot read, quote and preview return
503 UPSTREAM_ERRORinstead of500. POST /v1/orders/previewreturns these errors, and503 UPSTREAM_ERRORwhen a venue book can’t be read, as the quote does. It no longer answers200with aROUTE_UNAVAILABLEwarning for them; that warning now means routing is off or no route can take the order.- A leg whose venue market has closed now reads
tradable: false. Closed markets used to show every leg as tradable.
Profit and loss
- New
GET /v1/pnlreturns realized, unrealized and total profit and loss for the account and for each venue. Passvenueormarket_idto narrow it. - New
GET /v1/pnl/historyreturns profit and loss over time at a1hor1dinterval, for up to 365 days and 1000 points. See Profit and loss.
- New
GET /v1/riskreturns cost basis, mark value, cash and open order notional for the account and for each venue, with the largest positions and the split by market and by category. See Risk.
GET /v1/account/confignow returnsscopes, what the key may do:read,trade,routeandwithdraw.
- The Lean MCP server lets an AI assistant use your key to read markets, orders, fills, positions, profit and loss, risk, stop losses, limit chases, deposits, withdrawals and transfers. Every tool that takes a market id also takes a venue symbol.
- It is read only unless it starts with
--enable-trading. Then a key with thetradescope can place, preview, amend and cancel orders, close positions, create stop losses and limit chases, pause trading and lower its own limits. Transfers also need theroutescope. Withdrawals need only thewithdrawscope. Only the Lean app resumes trading or raises a limit.
Withdrawals
POST /v1/withdrawalspays USDC out on every chain the Lean app withdraws to:destination.chainis one ofpolygon,arbitrum,base,optimism,ethereum,bscorsolana, from either venue. A Solana withdrawal takes a Solana address, and every other chain a0xaddress; an address the chain cannot take is refused with400 VALIDATION_ERROR.GET /v1/withdrawalsandGET /v1/withdrawals/{id}return the chain each withdrawal paid out on. See Withdrawals through the API.
Markets
GET /v1/marketswithsearchnow finds markets the way the search box in the Lean app does. Every word is matched against Polymarket and Hyperliquid listing titles, with common team nicknames and small typos tried when few listings match. See Search by text.- Only markets with a matching listing are returned, not every market of the same game. Results
keep their order by start time, and the other filters and
cursorwork as before. searchno longer matches a market by its league. A league name such asnbafinds only the markets with a listing whose title contains it, such as some Hyperliquid listings. Useleagueto list a league.- A request with
searchcan return503 UPSTREAM_ERRORwhile search is briefly unavailable. Retry it.
Positions
GET /v1/positionstakesvenue,market_idandsearch. Withvenue, Lean reads only that venue, so only it can be listed inunavailable. See Read positions.
GET /v1/ordersandGET /v1/fillstakesearch. It keeps the records on a market whosetitleoroutcomecontains the text, in any letter case, and pages withnext_cursoras usual. See Find by text.searchmust be 1 to 100 characters once spaces at either end are removed. Anything else returns400 VALIDATION_ERROR.
Markets
- Every path and field that takes a market id also takes a venue symbol that names one market:
a Polymarket token id, a Hyperliquid book coin (
#…, written%23…in a path), or a legtickerthat pays only one outcome. Responses, orders, fills and filters always use the market id. See Venue symbols. - An order named by a venue symbol trades only that listing, and a buy Lean routes for it can
still be paid from the other venue. Quotes, books, trades, prices and the
bookstream channel named by a symbol read only that listing, so they price what the order would trade. - A
bookstream channel takes a venue symbol as well as a market id. Eachbookframe now carries a top levelmarket_id: the id or symbol the channel was subscribed with. The book inside it still carries the market id. See Book. - A symbol that names more than one market, such as a Polymarket condition id, returns
400 VALIDATION_ERROR. An unknown symbol returns404 NOT_FOUND, as an unknown market id does.
400 VALIDATION_ERROR instead of 404 NOT_FOUND. A mkt_… id
Lean did not issue still returns 404 NOT_FOUND.Transfers
POST /v1/transfers/quoteshows what moving USDC from one of your account’s venues to the other costs:fee_usd,receive_usd,minimum_usd,available_usdandexpires_at.POST /v1/transferscreates a transfer to the account’s own balance on the other venue and returns the message to sign. Sending the sameclient_transfer_idagain returns the same transfer.POST /v1/transfers/{id}/executetakes your signature, or"delegated"to have Lean sign.GET /v1/transfersandGET /v1/transfers/{id}show each transfer fromawaiting_authorizationtocompleted,failedorexpired.- Transfers count against the key’s limits and stop while the key or account is paused. A
quote still answers while paused. They need the
tradeandroutescopes. Transfers are test mode only for now: a live key gets503 FEATURE_DISABLEDwithdetails.reason: "LIVE_TRANSFERS_UNAVAILABLE". See Transfers.
POST /v1/test/resetalso deletes the account’s test transfers and returnsdeleted_transfers.
Limit chases
POST /v1/limit-chasesrests a post only limit order on Polymarket a set distance behind the best price on its own side, given inoffset_ticksoroffset_price, and moves it as the book moves until it fills, is canceled or reachesexpires_at.price_limitcaps how far it follows. Hyperliquid does not run them, and a request for it is refused with400 VALIDATION_ERROR.GET /v1/limit-chases,GET /v1/limit-chases/{id}andDELETE /v1/limit-chases/{id}read and cancel them. Each one counts against the key’s order and daily limits at the most it can trade for. A test key’s limit chases follow the public book and fill in simulation. What one has filled is listed inGET /v1/fillswithorder_idnull, as a live limit chase’s fills are.POST /v1/test/resetalso deletes them and returnsdeleted_limit_chases. See Limit chases.
Fills
- Each fill in
GET /v1/fillsnow carriesmarket_id, the market it filled on, ornullwhen Lean cannot tie it to one. GET /v1/fillstakesmarket_id,filled_afterandfilled_beforeto narrow the list to one market or a time window. See Read fills.
- Each position in
GET /v1/positionsand thepositionsstream channel now carriestitleandoutcomebesidemarket_id. All three arenullwhenevermarket_idis. See Reconcile.
- Each market now carries
title, the fixture, proposition and outcome in words. GET /v1/markets/{id}/tradesreturnsnext_cursor. Pass it ascursor, with the same market andvenue, to read older trades. See Recent trades.- New
GET /v1/markets/{id}/candlesreturns open, high, low, close and volume per venue listing, from one second to two hours per candle. See Price candles.
Orders
POST /v1/orders/cancel-batchcancels up to 50 orders in one call, named by id,client_order_idor both, with one result for each name. See Track and cancel.post_onlyonPOST /v1/ordersandPOST /v1/orders/previewplaces an order that only rests on the book. It runs on Hyperliquid, and an order that would trade at once is refused withdetails.reasonPOST_ONLY_WOULD_CROSS. See Post only orders.PATCH /v1/orders/{id}changes the price, the size or both of a resting order. Lean cancels it and places a new order for the rest once the cancel is confirmed, answering409REPLACEMENT_PENDINGuntil then, and the two name each other in the newreplaces_order_idandreplaced_by_order_idfields. The new order is placed as the key that sends the amend places one. See Amend an order.type: "market"onPOST /v1/ordersandPOST /v1/orders/previewtrades at once withlimit_priceas an optional cap. Without one, a buy is capped at0.99and a sell at0.01. It needstime_in_forceiocorfok. See Market orders.time_in_forcefokfills an order in full at once or cancels all of it, andgtdrests an order until the newexpires_at. Both run on Polymarket, and a request for Hyperliquid is refused with400 VALIDATION_ERROR. Afokbuy is sized withnotional. See Fill or kill and expiring orders.- Orders and previews show the new
typeandexpires_atfields.
POST /v1/withdrawalswithdraws cash from a venue to the address the request names, within the key’s single and daily withdrawal limits.GET /v1/withdrawalsandGET /v1/withdrawals/{id}read them back. It needs the newwithdrawscope, which a live key takes when you turn on withdrawals for it in the Lean app. Both limits are optional. A request names itssourcevenue and asset, itsdestinationchain, asset and address, and theamount; the response adds the venue’sfeeand thenet_amountquoted to arrive. A live withdrawal pays USDC on Polygon from Polymarket’s pUSD and USDC on Arbitrum from Hyperliquid’s USDC; any other pair is refused with400. It startspending, and becomescompletedorfailedwith afailure_reasonas the venue settles it. The account must have trading enabled.POST /v1/test/resetalso deletes test withdrawals and returnsdeleted_withdrawals. See Withdrawals through the API.
POST /v1/stop-lossessells shares the account holds on Polymarket once the best bid falls to a trigger price (stop_loss) or rises to it (take_profit). Hyperliquid does not run them, and a request for it is refused with400 VALIDATION_ERROR.GET /v1/stop-losses,GET /v1/stop-losses/{id}andDELETE /v1/stop-losses/{id}read and cancel them, and a cancel shows in the newcancel_requested_atfield. Each sale counts against the key’s order and daily limits at its trigger price. A test key’s stop losses are checked and listed but never sell.POST /v1/test/resetalso deletes them and returnsdeleted_stop_losses. See Stop losses and take profits.
Orders
- Breaking, effective 2026-11-12: when no venue that lists the market is open to the trading
account, for example because the venue is not available in your region,
POST /v1/orders/previewnow returns the same403error asPOST /v1/ordersand the quote. It used to return200with aTRADING_UNAVAILABLEwarning. See Preview. - Order docs now say where fees are: an order has no fee field, and its fees are the
fee_usdof its fills. A live Hyperliquid buy fill showsfee_usd0because the buy pays its fee when the position closes or settles. See Limitations. - Breaking, effective 2026-11-12: an order you canceled reads
cancel_requesteduntil its venue confirms the cancel, thencanceled, orfilledif a fill beat the cancel. It used to keep readingopenorpartially_filledmeanwhile.GET /v1/orderstakesstatus=cancel_requested. See Statuses. - Orders carry
filled_notional_usd, what the filled shares traded for across every leg.notional_usdstays the order at its own limit. See Orders. - A sell at
0.01, as a close withoutlimit_priceplaces, now shows the lowest limit among its legs as itslimit_price, the protection the venue orders carry. It used to show0.01. - An
iocbuy can sendnotional, the dollars to spend, in place ofquantity. Lean walks the books within your limit and slippage bound and never spends more thannotionalbefore fees.limit_priceis optional with it.POST /v1/orders/previewandGET /v1/markets/{id}/quotetake it too. See Buying a dollar amount. - An
iocbuy sized withnotionalcan now fill on Polymarket. One sized withquantityis still refused there, and the error now says to sendnotional. - Reading a filled Hyperliquid or Polymarket order with
GET /v1/orders/{id}now brings its fills intoGET /v1/fills. Before, the order could readfilleda few seconds before its fills were listed. A Polymarket fill whose trade Polygon has not confirmed yet, or a fill of an order you have not read, can still be listed a few seconds later. See Limitations.
- Each placed sell in a close is read back before the response, so a sell the venue matched at once
reads
filledwith its filled quantity and average price. It used to read as first placed. - A close scoped to one market no longer includes positions that can’t be matched to a market the API trades. A close of every position still includes them.
- A test buy paid from the other venue now fills at the asks that venue’s public book shows. When
those asks can’t fill the whole size within the limit, the buy is refused with
422 VALIDATION_ERROR, as a live one is. It used to fill at the limit. See Test mode. - Test positions now carry
mark_price, the best bid on the venue’s public book, andunrealized_pnl_usd. Both used to benull.
- The Streaming page names the WebSocket URL,
wss://api.lean.xyz/v1/ws.
Markets
GET /v1/marketstakesvenue,polymarketorhyperliquid, to list only markets with a leg on that venue. See Query parameters.- A Polymarket leg the venue no longer trades now reads
tradable: false, and a market with no tradable open leg readsclosed. - Breaking, effective 2026-11-12:
GET /v1/marketsrefuses a query parameter it does not know with400 VALIDATION_ERROR. It used to ignore it and return the whole list. - Breaking, effective 2026-11-12: a request that needs the book of a market Polymarket has
stopped trading returns
409 CONFLICTwithdetails.reason: "MARKET_NOT_TRADABLE". It used to return503 UPSTREAM_ERROR. See Errors.
- Each item of
GET /v1/positionscarriesmarket_id, the Lean market the position belongs to.market_idisnullwhen no listed market currently matches the holding, for example a fixture that settled more than 7 days ago. It can also benullfor a moment after an API restart or a failed market list load, until the market list loads. Closing still works because the close path resolves the market from the ticker. POST /v1/orders/previewpricesroute_planat the order’s limit. A limit at the best ask no longer warns, and a buy limit below the book reportslimited_by: "depth", not"funds". TheLIMIT_BELOW_ROUTE_PRICEpreview warning is gone:ROUTE_LIMITEDcovers a limit the books cannot fill. See Preview.GET /v1/balancesanswers within about 3 seconds. A venue that has not answered by then is listed inunavailable, and the other venues are still returned.
Orders
-
POST /v1/ordersnow buys with cash held on the other venue in the same call. Lean moves the cash and buys on the venue with the book. The response carriesroute: { funding_venue, execution_venue }, orroute: nullwhen nothing was moved. See Paying from the other venue. -
It needs the key’s
routescope, trading enabled in the Lean app for a live key, and routing available. If any is missing, the order is refused as before with422 VALIDATION_ERRORanddetails.reason: "INSUFFICIENT_FUNDS". -
Read and trade keys made in the Lean app now include the
routescope, in test and live mode. Keys made earlier keep their scopes: create a new key, or one withroutethroughPOST /api-keys, to use one-call routing. See Authentication. - Test keys get the same one call against the simulator. No real funds move.
-
POST /v1/routed-ordersandPOST /v1/routed-orders/{id}/executeremain for programs that sign each payment themselves. See Advanced: self-signed routed orders. -
venuesonPOST /v1/orderskeeps an order on the venues it names. A single venue places the order only there, or refuses it. The list can only narrow the account’s venues. See Choosing venues. -
POST /v1/orders/previewhonorsvenues, and shows the route a buy would take inroute. -
best_priceonPOST /v1/ordersandPOST /v1/orders/previewpays from the other venue whenever that costs less in all than buying where the account’s cash is. It isfalseby default. See Best price across venues.
INSUFFICIENT_FUNDS can now fill.The first public preview of the Lean API, served at
https://api.lean.xyz/v1.MarketsGET /v1/marketslists canonical sports markets, without naming a venue. Each leg carries the venue’s resolution terms, and each market says whether its venue listings were reviewed as the same proposition. See Markets.GET /v1/markets/{id}/quotequotes a market across the venues that list it.
POST /v1/orders/previewprices an order and shows the route Lean would take.POST /v1/ordersplaces an order on Hyperliquid, Polymarket or both.client_order_idmakes retries safe.GET /v1/orders,GET /v1/orders/{id}andPOST /v1/orders/{id}/cancelreconcile and cancel orders. Each order haslegs, one per venue order, each with its ownstatusandstatus_reason, and anavg_fill_pricefor the whole order.- Venue outcomes are order statuses: an unfilled
iocorder iscanceled, a venue refusal isrejected, and a submit the venue did not confirm isunconfirmed. See Order statuses.
GET /v1/balancesandGET /v1/positionsread each venue, and report a venue that cannot be read as unavailable rather than as zero.POST /v1/account/pauselets a key stop new orders for itself or its whole trading account. Only the Lean dashboard resumes. See Pause trading.
POST /api-keys,GET /api-keysandDELETE /api-keys/{id}manage keys, each with scopes and per order and daily limits.- Test keys simulate fills against simulated balances. See Test mode.