Overview
TheAlphaClient is the main entry point for interacting with Alpha Market prediction markets on Algorand. It provides a comprehensive set of methods organized into four categories:
- Trading: Create, modify, and cancel orders
- Positions: Manage outcome token positions and claims
- Orderbook: Read on-chain orderbook data
- Markets: Fetch market information
Constructor
Configuration object for initializing the client. See Configuration for details.
Trading Methods
Methods for creating, modifying, and canceling orders on prediction markets.createLimitOrder
Creates a limit order on a market. A limit order sits on the orderbook at your specified price until matched or cancelled. Slippage is 0 — the order executes only at your exact price.Order parameters
CreateLimitOrderParams fields
CreateLimitOrderParams fields
The market application ID on Algorand
Position to trade:
1 for Yes, 0 for NoPrice in microunits (e.g.,
500000 = $0.50)Quantity in microunits (e.g.,
1000000 = 1 share)Whether this is a buy order (
true) or sell order (false)Fee base in microunits (e.g.,
70000 = 7%). If omitted, reads from market global state.createMarketOrder
Creates a market order with automatic matching. Fetches the live orderbook, finds the best counterparty orders within your slippage tolerance, then creates the order and proposes matches in a single atomic transaction group.Order parameters
CreateMarketOrderParams fields
CreateMarketOrderParams fields
The market application ID
Position to trade:
1 for Yes, 0 for NoPrice in microunits (e.g.,
500000 = $0.50)Quantity in microunits
Whether this is a buy order
Slippage tolerance in microunits (e.g.,
50000 = $0.05)Fee base in microunits. If omitted, reads from market global state.
Pre-computed matching orders. If omitted, auto-fetches orderbook and computes matches.
The escrow app ID of the newly created order
Transaction IDs from the atomic group
Confirmed round number
Total quantity that was matched
Weighted average fill price in microunits (accounts for complementary matching)
cancelOrder
Cancels an open order by deleting its escrow app. Returns the escrowed funds (USDC or outcome tokens) to the order owner, and reclaims the ALGO minimum balance used by the escrow app.proposeMatch
Proposes a match between an existing maker order and a new taker order. Use this for advanced matching scenarios where you want to explicitly specify which orders to match against.amendOrder
Amends (edits) an existing unfilled order in-place. Cheaper and faster than cancel + recreate. The escrow contract adjusts collateral automatically — sends you a refund if the new value is lower, or requires extra funds if higher. Note: Only works on orders with zero quantity filled.Amend parameters
AmendOrderParams fields
AmendOrderParams fields
Position Methods
Methods for managing outcome token positions and claiming resolved markets.splitShares
Splits USDC into equal amounts of YES and NO outcome tokens. For example, splitting 1 USDC gives you 1 YES token + 1 NO token. Together they’re always worth $1.00 — you can trade them independently.Split parameters
SplitSharesParams fields
SplitSharesParams fields
mergeShares
Merges equal amounts of YES and NO tokens back into USDC. The inverse of split. 1 YES + 1 NO = 1 USDC, always.Merge parameters
MergeSharesParams fields
MergeSharesParams fields
claim
Claims USDC from a resolved market by redeeming outcome tokens:- Winning tokens: redeemed 1:1 for USDC
- Voided market: redeemed at half value
- Losing tokens: burned (no USDC returned)
getPositions
Gets all token positions for a wallet across all markets. Reads on-chain account info and maps ASA holdings to markets. Returns raw token balances (YES/NO amounts per market).Optional wallet address. Defaults to the client’s
activeAddress if not provided.Array of positions with market app IDs and token balances
Market application ID
Market title (fetched from on-chain global state)
YES token ASA ID
NO token ASA ID
YES token balance in microunits
NO token balance in microunits
Orderbook Methods
Methods for reading on-chain orderbook data.getOrderbook
Fetches the full on-chain orderbook for a market. Reads all escrow apps created by the market contract, decodes their global state, and organizes into yes/no bids and asks. Only includes limit orders (slippage = 0) with unfilled quantity.The market application ID
getOpenOrders
Gets open orders for a specific wallet on a market.The market application ID
Optional wallet address. Defaults to the client’s
activeAddress if not provided.Array of open orders
Escrow app ID
Market app ID
Position: 0=No, 1=Yes
Side: 0=Sell, 1=Buy
Price in microunits
Total quantity in microunits
Filled quantity in microunits
Slippage in microunits (0 = limit order)
Owner address
getWalletOrdersFromApi
Gets all open orders for a wallet across every live market using the Alpha REST API.The wallet address
Array of open orders for the wallet across all markets
Market Methods
Methods for fetching market information from the Alpha API or directly from the blockchain.getLiveMarkets
Fetches all live, tradeable markets.- If an API key is configured, uses the Alpha REST API (richer data: images, categories, volume)
- Otherwise, discovers markets on-chain from the market creator address (no API key needed)
Array of live markets
Market ID (app ID as string for on-chain, UUID for API)
Market title
Market application ID on Algorand
YES token ASA ID
NO token ASA ID
YES probability (API only)
NO probability (API only)
Trading volume (API only)
End/resolution timestamp in seconds
Market image URL (API only)
Market categories (API only)
getMarket
Fetches a single market by its ID.- If an API key is configured, uses the Alpha REST API
- Otherwise, reads the market’s on-chain global state (pass the market app ID as a string)
The market ID (UUID for API, app ID string for on-chain)
The market data, or null if not found
getMarketsOnChain
Fetches all live markets directly from the blockchain (no API key needed). Discovers markets by looking up all apps created by the market creator address. Returns core data: title, asset IDs, resolution time, fees. Does NOT include images, categories, volume, or probabilities.Array of live markets from on-chain data
getMarketOnChain
Fetches a single market by app ID directly from the blockchain (no API key needed).The market application ID
The market data, or null if not found
getLiveMarketsFromApi
Fetches all live markets from the Alpha REST API (requires API key). Returns richer data than on-chain: images, categories, volume, probabilities.Array of live markets from the API
getRewardMarkets
Fetches the reward markets from the Alpha REST API (requires API key).Array of reward markets
getMarketFromApi
Fetches a single market by ID from the Alpha REST API (requires API key).The market UUID
The market data, or null if not found
