Skip to main content
Each entry names the release version from info.version in the OpenAPI spec. Breaking changes are marked, with the date they take effect. See Versioning for what counts as breaking.
0.1.0: combo RFQ quotes arrive sooner and replaced quotes are rejected
RFQs
  • On Kalshi and Polymarket US, POST /v1/rfqs and POST /v1/rfqs/{id}/accept now 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_unconfirmed because the maker replaced the quote now returns rejected, with the venue’s reason when it gives one. If you receive rejected, read the RFQ again before choosing another quote.
  • The RFQs reference now lists create, retrieve, accept and cancel.
0.1.0: discovery volume is dollars traded
Markets
  • Breaking, effective 2026-12-03: volume_24h_usd in POST /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_24h and the volume sort use the same dollars, so a threshold you send now selects by dollars rather than contracts.
0.1.0: reward programs carry exact Kalshi program fields
Rewards
  • Each Kalshi program in GET /v1/rewards/programs also carries period_reward_centicents, the exact target_size_fp decimal string, last_rest_update, created_at and updated_at. last_rest_update and updated_at record when a Kalshi refresh last inserted or changed the program; an unchanged refresh leaves them as they were.
0.1.0: limit chase lists show pending edits
Limit chases
  • GET /v1/limit-chases shows an edit Lean has accepted but not yet applied as reading the limit chase by id does: the edited values with edit_pending: true. A list read just after an edit can still trail it. See Change a limit chase.
0.1.0: order previews say whether a resting order earns liquidity rewards
Orders
  • Each execution.legs[] entry of an order preview carries reward: for a leg on a Polymarket, Kalshi or Polymarket US market with an active reward program, whether the part a gtc or gtd order would rest would score at its price and size, with reasons when it would not. null for a market without one.
0.1.0: amend in place, Polymarket US balance details
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_id and 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.
Account
  • Each Polymarket US balance from GET /v1/balances can carry polymarket_us_details, with buying_power_usd, asset_available_usd, open_orders_usd and unsettled_funds_usd.
0.1.0: trades and market lifecycle streams, closed event markets, reward programs, Kalshi subaccounts, weather, resolutions
Streams
  • The WebSocket stream has trades and market_lifecycle channels, each naming a venue listing by its ticker. trades sends trades as they happen, with maker and taker details. market_lifecycle sends 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 with 1013 and RATE_LIMITED.
Markets
  • An event listing takes include_closed=true to list closed event markets from the last 30 days, alone or with status=closed.
  • GET /v1/resolution/markets lists 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.
Account and rewards
  • GET /v1/kalshi/subaccounts lists your Kalshi subaccounts and their balances. Test keys get an empty list.
  • GET /v1/rewards/programs lists active reward programs on Kalshi, Polymarket US and Polymarket, filtered by venue, ticker_prefix and min_daily_reward, 200 per page by default and 1000 at most.
SDKs
  • The TypeScript and Rust SDKs cover the new endpoints and stream channels.
0.1.0: reward earnings
Rewards
  • GET /v1/rewards/earnings returns 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.
0.1.0: book channels stream deltas
Streams (breaking)
  • A WebSocket book channel now sends the whole book once, then book_delta frames 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.
  • book and book_delta frames carry a sequence, and a delta carries the prev_sequence it follows. A session that reads too slowly, or a market whose venues change, gets a whole book frame 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/book returns 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 1013 and RATE_LIMITED.
0.1.0: test cost basis with fees, MCP argument errors, expired transfer times
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_usd now matches what GET /v1/pnl realized for it.
  • A transfer that expired before anything was written for it shows when it expired in updated_at.
SDKs and MCP server
  • requestId in the TypeScript SDK and request_id in the Python SDK return nothing, rather than throwing, when an error body has no meta.
  • 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_INPUT and each refused field in details.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_after now 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. Pass ends_after to list only markets that have not reached their scheduled close.
  • An event market’s title starts with its event title when the venue names the market only by its range or outcome, so a daily temperature market reads Highest temperature in Miami on Nov 24, 2026? 77° to 78°: Yes instead of 77° to 78°: Yes.
  • search on 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, so rain finds Rain and Rainfall but no longer Ukraine. It answers faster on broad words. An event listing cursor issued with search before this change is refused; start that listing again from its first page.
  • search on a sports listing answers faster on broad words that used to time out.
  • An event listing with a category that has few open markets, such as transportation or society, 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_ERROR with Retry-After instead of 500 INTERNAL_ERROR. A busy search sends Retry-After too.
Orders
  • POST /v1/orders/preview-batch refuses a body with a field other than orders with 400 VALIDATION_ERROR, as the other order endpoints do.
0.1.0: faster previews, decimal quantities
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/orders still 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_ERROR instead of 500 INTERNAL_ERROR.
  • Quantities are summed as decimals, so a total reads 66.9 rather than 66.89999999999999, and fractional quantities are kept.
0.1.0: hosted MCP server with log in with Lean
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_stream watches 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 is null for a key made in settings.
0.1.0: faster positions, PnL and risk
Account
  • GET /v1/positions, GET /v1/pnl and GET /v1/risk answer 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’s mark_price for the read, and a read a few seconds later marks it from the book.
0.1.0: event listing cursors keep their filters, rules read once
Markets
  • An event listing’s next_cursor now works only with the category, venue, search, ends_after and ends_before that listed it, and is refused with 400 VALIDATION_ERROR otherwise. Event listing cursors issued before this change are refused too; start the listing again from its first page.
  • legs[].resolution.rules reads 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 search on an event listing matches text anywhere in a title, even inside a longer word, and that a market a venue stopped trading is refused with 409 on quotes, previews and orders while its book still reads.
Streams
  • The WebSocket docs list every error a frame sent before auth gets, and say that a book channel naming a venue symbol for more than one market ends with book_ended and unknown_market.
0.1.0: MCP server streams, previews on a read only key, test mode reset
MCP server
  • watch_stream watches 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_order and preview_orders_batch are read tools, offered with a Read only key as the API allows.
  • With a test key and trading on, reset_test_mode starts the test account over.
  • A rate limit error carries retry_after_seconds, errors add a hint where 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_at must be in UTC ending in Z.
0.1.0: Polymarket US and Lighter books on the first read
Markets
  • GET /v1/markets/{id}/book and GET /v1/prices wait 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 in unavailable. A stop loss or take profit trigger check waits the same way instead of refusing with 503 UPSTREAM_ERROR, and position marks wait within their read deadline.
0.1.0: Lighter closes, expired gtd orders, stricter queries
Orders
  • A Kalshi fok order that Kalshi cannot fill in full reads canceled with filled_quantity "0", as an ioc order that finds no match does.
  • A Polymarket gtd order that reaches expires_at reads expired. It used to read canceled.
  • An order or preview on a market every venue has stopped trading returns 409 CONFLICT with details.reason: "MARKET_NOT_TRADABLE" before any venue’s own order rules, so a Polymarket ioc buy sized with quantity on such a market gets the 409, not a 400. A Lighter window that has ended answers the same way.
  • Orders and fills on a Lighter window name it by title and outcome, as its position does. They used to read null.
  • A canceled row of POST /v1/orders/cancel-batch means every leg’s cancel was accepted. Its order can still read cancel_requested until each venue confirms, as the docs now say.
  • POST /v1/positions/close sells Lighter positions with the rest, and venue: "lighter" scopes it to them. Its limit sells on Lighter are ioc. It used to answer nothing_to_close for them. legs[].venue and unavailable_venues can name lighter.
Account
  • GET /v1/account/config lists lighter in venues, ready when a Lighter account is connected to the key’s trading account.
  • GET /v1/pnl/history reads an end after now as now, and the response’s end shows the time it used.
Requests
  • 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, and GET /v1/transfers/{id} refuse a query parameter with 400 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_ERROR naming it, instead of a type error such as received nan.
0.1.0: fill or kill on Polymarket US, fully filled Polymarket buys
Orders
  • Breaking, effective 2026-11-24: a fok order no longer goes to Polymarket US, which can fill part of a fill or kill order and expire the rest. A fok order goes whole to Polymarket, else Kalshi. On a market listed only on Polymarket US it is refused with 400 VALIDATION_ERROR; send ioc instead. A fok buy sized with quantity goes to Kalshi only.
  • An ioc or fok buy on Polymarket that bought every share its dollars could buy reads filled. It used to read canceled when Polymarket’s rounding of the spend to whole cents left it a fraction of a share short of quantity.
0.1.0: Kalshi and Polymarket US event markets
Markets
  • GET /v1/markets lists event markets on all four prediction venues: Polymarket, Polymarket US, Hyperliquid and Kalshi. venue=polymarket_us and venue=kalshi take 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 politics for Kalshi’s Elections, else uncategorized.
  • A pmus: ticker or Kalshi market ticker of a market outside sports names its event market, in symbol= and wherever a market ID is taken, when that listing pays one outcome.
Orders
  • 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/merge stays Polymarket and Hyperliquid only.
Streams
  • Subscribe to an event market’s book on /v1/ws with a book channel naming its mkt_… ID. The stream has no trades, quotes or fills channel; each orders frame carries the order’s fills.
  • orders frames name an event market by its mkt_… ID, title and outcome.
0.1.0: API keys that never expire, book snapshot flag, book stream ends
API keys
  • POST /api-keys takes expiresInDays: null for a key that never expires, and the dashboard adds a Never expires switch. See Authentication.
Streams
  • Each book frame has a snapshot field. It is true on the first frame after you subscribe, which is the newest book Lean already holds and can have an as_of up to about a second old, and false on every later frame. See Streaming.
  • A book channel whose market_id names no market, or whose market closed, sends one book_ended frame and stops, instead of staying silent. See WebSocket.
  • subscribed and unsubscribed frames list each channel once, even when the request named it twice.
0.1.0: event markets
Markets
  • GET /v1/markets lists Polymarket and Hyperliquid markets outside sports, such as elections, central bank decisions and coin prices on a date. Pass a category other than sports or crypto (politics, economy, business and more), or kind=event. Each venue market is two markets, its yes and no sides, with kind: "event", an event instead of fixture and group, one leg and equivalence: "single_venue". See Event markets.
  • GET /v1/markets takes kind, and ends_after and ends_before to list event markets by scheduled close. With no category or kind it still lists sports markets, and category=crypto still lists Lighter crypto windows; kind=event&category=crypto lists event coin-price markets.
  • A Polymarket token ID, pm: or hl: ticker, or Hyperliquid book coin of a market outside sports now names its event market, in symbol= and wherever a market ID is taken.
  • Books, prices, quotes, trades, candles and the book stream channel take event markets.
Orders
  • 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_start is 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.
Risk
  • GET /v1/risk groups event market holdings under their category in by_category, with sport: null.
0.1.0: positions read deadline, book stream on change, OR orders
Positions
  • GET /v1/positions answers within about 3 seconds. A venue that has not answered by then is listed in unavailable, and the other venues are still returned.
Streams
  • The book stream channel sends a frame as soon as a venue book changes, and at least once a second otherwise.
Conditional sells
  • Conditional orders made in the Lean app that rest on several markets at once are not conditional sells, so /v1/conditional-sells does not list them.
0.1.0: conditional sells, change stop losses and limit chases, more chase offsets
Conditional sells
  • POST /v1/conditional-sells sells 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} and DELETE /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_sells and get_conditional_sell, and with the trade scope create_conditional_sell and cancel_conditional_sell.
Stop losses and limit chases
  • 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 back edit_pending while Lean applies the edit, and last_error when Lean refuses it. See Change a limit chase.
  • A limit chase takes offset_shares, the most shares it lets rest ahead of it, and offset_beat_best, to rest one tick better than the best price. Every limit chase reads back offset_beat_best, and offset_midpoint for one made in the Lean app that rests within a set distance of the midpoint.
  • The MCP server has update_stop_loss and update_limit_chase.
0.1.0: gtd orders on Hyperliquid
Orders
  • gtd orders, expires_at game_start included, now reach Hyperliquid. Hyperliquid has no order expiry, so Lean places the order as gtc and cancels what is left at expires_at. It then reads expired, like a gtd order on any other venue, and keeps any shares that filled. See Fill or kill and expiring orders.
0.1.0: convert USDC and USDC.e to pUSD
Funding
  • GET /v1/conversions shows 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/conversions converts the whole balance of one source_asset, usdc or usdc_e, into pUSD. A USDC.e conversion is settled once it confirms. A USDC conversion is submitted, 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.reason NOTHING_TO_CONVERT.
  • When Lean cannot reach Polymarket’s relayer, a conversion is refused with 503 FEATURE_DISABLED and nothing is submitted.
  • The MCP server has get_convertible_balances and convert_to_pusd.
  • See Convert USDC to pUSD.
0.1.0: deposit history, leg results, venue connections, game start expiry
Deposits
  • GET /v1/deposits?venue= lists the latest deposits to your Polymarket or Hyperliquid addresses, newest first, each with its status (detected, processing, completed, failed or refunded), 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.
Markets
  • legs[].resolution.result reads won, lost or void once a leg is resolved, and null before. See Legs.
Account
  • GET /v1/account/config returns venues: each venue with status ready, not_configured or unavailable, so a client can see which venues it can order on before it orders. ready matches what POST /v1/orders allows for the key. Keys are still connected in the Lean app only. A test key reads every venue ready.
Orders
  • A gtd order takes expires_at game_start to 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.
MCP server
  • New tools: list_deposits, preview_orders_batch, create_routed_order and execute_routed_order. The routed order tools need the route scope, like the transfer tools. See Build with AI.
0.1.0: live transfers through Relay
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_DISABLED with details.reason: "LIVE_TRANSFERS_UNAVAILABLE".
  • from_venue and to_venue also take lighter. Test keys still move simulated cash between Polymarket and Hyperliquid only, and a test key that names lighter gets 400 VALIDATION_ERROR.
  • A live quote’s fee_usd is 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 authorization is null and 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.
0.1.0: Lighter crypto markets
Markets
  • GET /v1/markets lists Lighter’s BTC and ETH 15 minute up or down windows with category=crypto or venue=lighter. Each market has kind: "time_window" and a window instead of fixture and group. Sports markets now carry kind: "sports". See Crypto windows.
  • Books, prices, trades, candles and the book stream channel cover Lighter markets, and venue takes lighter on those reads. A Lighter lt: ticker lists both markets of its window with symbol=.
  • Quotes on Lighter markets are refused with 400 VALIDATION_ERROR.
Orders
  • POST /v1/orders/preview, POST /v1/orders and cancels take Lighter markets, in live and test mode. Orders take gtd or ioc, expire with their window, are sized in shares and cannot be amended. See Lighter.
  • An order’s venue and legs, and GET /v1/orders?venue=, can name lighter.
0.1.0: redeem and merge positions
Positions
  • Every position has redeemable and payout_usd. A Polymarket holding of a resolved market that pays out is redeemable until it is redeemed; other venues pay resolved holdings out on their own. payout_usd is what the holding pays once its market resolves, and null while it is open.
  • POST /v1/positions/redeem pays out every redeemable holding, or only those on one market_id, and lists each one with its payout.
  • POST /v1/positions/merge turns pairs of YES and NO shares on one market back into cash on Polymarket or Hyperliquid.
  • A venue symbol as market_id settles 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_positions and merge_positions.
  • See Redeem and merge.
0.1.0: the Lean MCP server on npm
Build with AI
  • The Lean MCP server is the @leanxyz/mcp package on npm. It needs Node.js 22 or later, and an MCP client starts it with npx -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.
0.1.0: settled positions, and names for futures and older holdings
Positions
  • Each position in GET /v1/positions and the positions stream channel carries settled: true once its market has resolved. Its unrealized_pnl_usd stays its settlement payout minus cost, but GET /v1/pnl leaves 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, title and outcome.
  • A holding on a market the API does not list, such as a season futures market, takes its title and outcome from the venue market; its market_id stays null. search matches it.
Profit and loss
  • GET /v1/pnl reports meta.source upstream for every read, the account included, since its unrealized amount marks open positions live. Each venue’s updated_at is now the read time, the same as as_of, instead of when the stored record last changed.
0.1.0: Kalshi and Polymarket US
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. venue takes kalshi and polymarket_us wherever 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 FORBIDDEN without 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_ERROR with Retry-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_only orders go to Kalshi, Polymarket US and Hyperliquid. gtd orders go to Kalshi, Polymarket and Polymarket US. A fok order goes whole to one venue: Polymarket, else Kalshi, else Polymarket US.
  • Paying from the other venue, best_price routes, self-signed routed orders, deposits, withdrawals and transfers stay on Polymarket and Hyperliquid only.
0.1.0: fee terms and fixture filters on markets, sizes on prices, batch previews, test-mode marks
Markets
  • Every market leg has fees: the formula (price_curve or notional_on_exit), taker_rate, maker_rate and, for price_curve, exponent. They are the terms the preview charges, so a client can set a fee-aware limit price before previewing. fees is null when the venue’s fee rate isn’t recorded. See Fees.
  • GET /v1/markets takes fixture (a fixture key) and group (a group key such as moneyline: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, resolving or resolved). An unopened or resolving leg has a live book on the Lean platform but stays tradable: false, because its venue refuses orders. See Legs.
Prices
  • GET /v1/prices returns best_bid_quantity and best_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. mid is the venue’s mid rounded down to the tick, and a book with only one side reads that side instead of null. One venue’s crossed book reads a spread of 0.
  • last_trade_price counts 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.
Candles
  • GET /v1/markets/{id}/candles leaves 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
  • Orders and fills carry the market’s title and outcome, as positions do.
  • A canceled ioc order and its canceled legs have status_reason.code IOC_REMAINDER_CANCELED; filled_quantity says how much filled first.
  • POST /v1/orders/preview-batch previews 1 to 25 orders in one request and returns each one’s preview or error in order. It needs only the read scope. See Preview orders (batch).
  • Orders carry remaining_quantity: the shares still working on the venues, 0 once the order is final. avg_fill_price is 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 reads filled, as the Lean app reports them.
  • A Polymarket ioc or fok sell may go below the market’s minimum shares, down to 0.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 mode
  • Test positions are marked as the Lean portfolio marks live ones: Polymarket at the last trade, Hyperliquid at the venue’s mid. GET /v1/pnl totals 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/history stays realized-only for test keys. See Test mode.
Errors
  • A 400 VALIDATION_ERROR message names the first failing field and what is wrong with it, such as market_ids: At most 25 market ids per request; split larger sets across requests, and says how many more problems are in details.
Performance
  • Responses report key authentication time in the Server-Timing header (auth), and a key’s last-used time is written at most once a minute instead of on every request.
0.1.0: unknown query parameters refused
Requests
  • Every endpoint that takes query parameters returns 400 VALIDATION_ERROR for one it does not take, as GET /v1/markets already did, naming it in details. A misspelled filter such as GET /v1/orders?stauts=open used to be ignored and return every order. Breaking: takes effect on release; remove any parameter an endpoint does not list.
0.1.0: client_order_id lookups across keys, cursors tied to their list, clearer errors
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 returned 502; the reference listed it by mistake.
Paging
  • 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, returns 400 VALIDATION_ERROR. Breaking: a cursor issued before this release is refused once with 400; page that list again from the start.
Errors
  • A path or method no endpoint serves returns the JSON 404 NOT_FOUND envelope, not plain text.
  • A malformed key returns 401 UNAUTHORIZED with “Invalid, expired or revoked API key”, the same as an unknown key, instead of “Missing API key”.
Funding
  • 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_usd is null: it has no minimum. See Funding.
0.1.0: steady search results, and closed markets refused on quote and preview
Markets
  • GET /v1/markets with search looks 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 as philly, when it ran slowly. One- and two-letter searches no longer return 503 UPSTREAM_ERROR.
  • A search that cannot finish in time returns 503 UPSTREAM_ERROR instead of a partial list.
  • GET /v1/markets/{id}/quote and POST /v1/orders/preview on a market Polymarket has stopped trading return 409 CONFLICT with details.reason: "MARKET_NOT_TRADABLE", as documented. They used to return 500, or 500 and 409 at random for a market with both a YES and a NO Polymarket listing. The OpenAPI spec now lists this 409 on both routes.
  • When Polymarket answers that check with a response Lean cannot read, quote and preview return 503 UPSTREAM_ERROR instead of 500.
  • POST /v1/orders/preview returns these errors, and 503 UPSTREAM_ERROR when a venue book can’t be read, as the quote does. It no longer answers 200 with a ROUTE_UNAVAILABLE warning 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.
0.1.0: profit and loss, risk and the Lean MCP server
Profit and loss
  • New GET /v1/pnl returns realized, unrealized and total profit and loss for the account and for each venue. Pass venue or market_id to narrow it.
  • New GET /v1/pnl/history returns profit and loss over time at a 1h or 1d interval, for up to 365 days and 1000 points. See Profit and loss.
Risk
  • New GET /v1/risk returns 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.
Account
  • GET /v1/account/config now returns scopes, what the key may do: read, trade, route and withdraw.
MCP server
  • 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 the trade scope 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 the route scope. Withdrawals need only the withdraw scope. Only the Lean app resumes trading or raises a limit.
See Run the Lean MCP server.
0.1.0: withdrawals to more chains
Withdrawals
  • POST /v1/withdrawals pays USDC out on every chain the Lean app withdraws to: destination.chain is one of polygon, arbitrum, base, optimism, ethereum, bsc or solana, from either venue. A Solana withdrawal takes a Solana address, and every other chain a 0x address; an address the chain cannot take is refused with 400 VALIDATION_ERROR. GET /v1/withdrawals and GET /v1/withdrawals/{id} return the chain each withdrawal paid out on. See Withdrawals through the API.
0.1.0: market search matches the Lean app search
Markets
  • GET /v1/markets with search now 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 cursor work as before.
  • search no longer matches a market by its league. A league name such as nba finds only the markets with a listing whose title contains it, such as some Hyperliquid listings. Use league to list a league.
  • A request with search can return 503 UPSTREAM_ERROR while search is briefly unavailable. Retry it.
0.1.0: filter positions, and find positions, orders and fills by text
Positions
  • GET /v1/positions takes venue, market_id and search. With venue, Lean reads only that venue, so only it can be listed in unavailable. See Read positions.
Orders and fills
  • GET /v1/orders and GET /v1/fills take search. It keeps the records on a market whose title or outcome contains the text, in any letter case, and pages with next_cursor as usual. See Find by text.
  • search must be 1 to 100 characters once spaces at either end are removed. Anything else returns 400 VALIDATION_ERROR.
0.1.0: venue symbols wherever a market id goes
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 leg ticker that 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 book stream channel named by a symbol read only that listing, so they price what the order would trade.
  • A book stream channel takes a venue symbol as well as a market id. Each book frame now carries a top level market_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 returns 404 NOT_FOUND, as an unknown market id does.
Breaking, effective 2026-11-12: in a REST path, query or body, a value that is neither a market id nor a venue symbol now returns 400 VALIDATION_ERROR instead of 404 NOT_FOUND. A mkt_… id Lean did not issue still returns 404 NOT_FOUND.
0.1.0: transfers between your venues
Transfers
  • POST /v1/transfers/quote shows what moving USDC from one of your account’s venues to the other costs: fee_usd, receive_usd, minimum_usd, available_usd and expires_at.
  • POST /v1/transfers creates a transfer to the account’s own balance on the other venue and returns the message to sign. Sending the same client_transfer_id again returns the same transfer. POST /v1/transfers/{id}/execute takes your signature, or "delegated" to have Lean sign.
  • GET /v1/transfers and GET /v1/transfers/{id} show each transfer from awaiting_authorization to completed, failed or expired.
  • 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 trade and route scopes. Transfers are test mode only for now: a live key gets 503 FEATURE_DISABLED with details.reason: "LIVE_TRANSFERS_UNAVAILABLE". See Transfers.
Test mode
  • POST /v1/test/reset also deletes the account’s test transfers and returns deleted_transfers.
0.1.0: limit chases
Limit chases
  • POST /v1/limit-chases rests a post only limit order on Polymarket a set distance behind the best price on its own side, given in offset_ticks or offset_price, and moves it as the book moves until it fills, is canceled or reaches expires_at. price_limit caps how far it follows. Hyperliquid does not run them, and a request for it is refused with 400 VALIDATION_ERROR. GET /v1/limit-chases, GET /v1/limit-chases/{id} and DELETE /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 in GET /v1/fills with order_id null, as a live limit chase’s fills are. POST /v1/test/reset also deletes them and returns deleted_limit_chases. See Limit chases.
0.1.0: market names on positions, older trades, fill filters and price candles
Fills
  • Each fill in GET /v1/fills now carries market_id, the market it filled on, or null when Lean cannot tie it to one.
  • GET /v1/fills takes market_id, filled_after and filled_before to narrow the list to one market or a time window. See Read fills.
Positions
  • Each position in GET /v1/positions and the positions stream channel now carries title and outcome beside market_id. All three are null whenever market_id is. See Reconcile.
Markets
  • Each market now carries title, the fixture, proposition and outcome in words.
  • GET /v1/markets/{id}/trades returns next_cursor. Pass it as cursor, with the same market and venue, to read older trades. See Recent trades.
  • New GET /v1/markets/{id}/candles returns open, high, low, close and volume per venue listing, from one second to two hours per candle. See Price candles.
0.1.0: order management
Orders
  • POST /v1/orders/cancel-batch cancels up to 50 orders in one call, named by id, client_order_id or both, with one result for each name. See Track and cancel.
  • post_only on POST /v1/orders and POST /v1/orders/preview places an order that only rests on the book. It runs on Hyperliquid, and an order that would trade at once is refused with details.reason POST_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, answering 409 REPLACEMENT_PENDING until then, and the two name each other in the new replaces_order_id and replaced_by_order_id fields. The new order is placed as the key that sends the amend places one. See Amend an order.
  • type: "market" on POST /v1/orders and POST /v1/orders/preview trades at once with limit_price as an optional cap. Without one, a buy is capped at 0.99 and a sell at 0.01. It needs time_in_force ioc or fok. See Market orders.
  • time_in_force fok fills an order in full at once or cancels all of it, and gtd rests an order until the new expires_at. Both run on Polymarket, and a request for Hyperliquid is refused with 400 VALIDATION_ERROR. A fok buy is sized with notional. See Fill or kill and expiring orders.
  • Orders and previews show the new type and expires_at fields.
Withdrawals
  • POST /v1/withdrawals withdraws cash from a venue to the address the request names, within the key’s single and daily withdrawal limits. GET /v1/withdrawals and GET /v1/withdrawals/{id} read them back. It needs the new withdraw scope, which a live key takes when you turn on withdrawals for it in the Lean app. Both limits are optional. A request names its source venue and asset, its destination chain, asset and address, and the amount; the response adds the venue’s fee and the net_amount quoted 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 with 400. It starts pending, and becomes completed or failed with a failure_reason as the venue settles it. The account must have trading enabled. POST /v1/test/reset also deletes test withdrawals and returns deleted_withdrawals. See Withdrawals through the API.
Stop losses and take profits
  • POST /v1/stop-losses sells 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 with 400 VALIDATION_ERROR. GET /v1/stop-losses, GET /v1/stop-losses/{id} and DELETE /v1/stop-losses/{id} read and cancel them, and a cancel shows in the new cancel_requested_at field. 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/reset also deletes them and returns deleted_stop_losses. See Stop losses and take profits.
0.1.0: more fixes from agent testing
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/preview now returns the same 403 error as POST /v1/orders and the quote. It used to return 200 with a TRADING_UNAVAILABLE warning. See Preview.
  • Order docs now say where fees are: an order has no fee field, and its fees are the fee_usd of its fills. A live Hyperliquid buy fill shows fee_usd 0 because the buy pays its fee when the position closes or settles. See Limitations.
  • Breaking, effective 2026-11-12: an order you canceled reads cancel_requested until its venue confirms the cancel, then canceled, or filled if a fill beat the cancel. It used to keep reading open or partially_filled meanwhile. GET /v1/orders takes status=cancel_requested. See Statuses.
  • Orders carry filled_notional_usd, what the filled shares traded for across every leg. notional_usd stays the order at its own limit. See Orders.
  • A sell at 0.01, as a close without limit_price places, now shows the lowest limit among its legs as its limit_price, the protection the venue orders carry. It used to show 0.01.
  • An ioc buy can send notional, the dollars to spend, in place of quantity. Lean walks the books within your limit and slippage bound and never spends more than notional before fees. limit_price is optional with it. POST /v1/orders/preview and GET /v1/markets/{id}/quote take it too. See Buying a dollar amount.
  • An ioc buy sized with notional can now fill on Polymarket. One sized with quantity is still refused there, and the error now says to send notional.
  • Reading a filled Hyperliquid or Polymarket order with GET /v1/orders/{id} now brings its fills into GET /v1/fills. Before, the order could read filled a 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.
Closing positions
  • Each placed sell in a close is read back before the response, so a sell the venue matched at once reads filled with 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.
Test mode
  • 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, and unrealized_pnl_usd. Both used to be null.
Streaming
  • The Streaming page names the WebSocket URL, wss://api.lean.xyz/v1/ws.
0.1.0: fixes from agent testing
Markets
  • GET /v1/markets takes venue, polymarket or hyperliquid, 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 reads closed.
  • Breaking, effective 2026-11-12: GET /v1/markets refuses a query parameter it does not know with 400 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 CONFLICT with details.reason: "MARKET_NOT_TRADABLE". It used to return 503 UPSTREAM_ERROR. See Errors.
Orders and account
  • Each item of GET /v1/positions carries market_id, the Lean market the position belongs to. market_id is null when no listed market currently matches the holding, for example a fixture that settled more than 7 days ago. It can also be null for 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/preview prices route_plan at the order’s limit. A limit at the best ask no longer warns, and a buy limit below the book reports limited_by: "depth", not "funds". The LIMIT_BELOW_ROUTE_PRICE preview warning is gone: ROUTE_LIMITED covers a limit the books cannot fill. See Preview.
  • GET /v1/balances answers within about 3 seconds. A venue that has not answered by then is listed in unavailable, and the other venues are still returned.
0.1.0: one-call orders across venues
Orders
  • POST /v1/orders now 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 carries route: { funding_venue, execution_venue }, or route: null when nothing was moved. See Paying from the other venue.
  • It needs the key’s route scope, trading enabled in the Lean app for a live key, and routing available. If any is missing, the order is refused as before with 422 VALIDATION_ERROR and details.reason: "INSUFFICIENT_FUNDS".
  • Read and trade keys made in the Lean app now include the route scope, in test and live mode. Keys made earlier keep their scopes: create a new key, or one with route through POST /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-orders and POST /v1/routed-orders/{id}/execute remain for programs that sign each payment themselves. See Advanced: self-signed routed orders.
  • venues on POST /v1/orders keeps 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/preview honors venues, and shows the route a buy would take in route.
  • best_price on POST /v1/orders and POST /v1/orders/preview pays from the other venue whenever that costs less in all than buying where the account’s cash is. It is false by default. See Best price across venues.
Nothing breaking: an order that would have been refused with INSUFFICIENT_FUNDS can now fill.
Preview release
The first public preview of the Lean API, served at https://api.lean.xyz/v1.Markets
  • GET /v1/markets lists 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}/quote quotes a market across the venues that list it.
Orders
  • POST /v1/orders/preview prices an order and shows the route Lean would take.
  • POST /v1/orders places an order on Hyperliquid, Polymarket or both. client_order_id makes retries safe.
  • GET /v1/orders, GET /v1/orders/{id} and POST /v1/orders/{id}/cancel reconcile and cancel orders. Each order has legs, one per venue order, each with its own status and status_reason, and an avg_fill_price for the whole order.
  • Venue outcomes are order statuses: an unfilled ioc order is canceled, a venue refusal is rejected, and a submit the venue did not confirm is unconfirmed. See Order statuses.
Account
  • GET /v1/balances and GET /v1/positions read each venue, and report a venue that cannot be read as unavailable rather than as zero.
  • POST /v1/account/pause lets a key stop new orders for itself or its whole trading account. Only the Lean dashboard resumes. See Pause trading.
Keys
  • POST /api-keys, GET /api-keys and DELETE /api-keys/{id} manage keys, each with scopes and per order and daily limits.
  • Test keys simulate fills against simulated balances. See Test mode.