Overview
Therequests module provides async functions for interacting with the Exchange Web REST API. All functions use axios for HTTP requests and return typed responses.
Base URL
Market Data Functions
getDepth()
Retrieves the current order book depth for a specific market.Market symbol (e.g., “SOL_USDCT”, “SOL_USDCT”)
Order book depth data
bids(array): Array of [price, quantity] tuples for buy ordersasks(array): Array of [price, quantity] tuples for sell orderslastUpdateId(string): Sequential update identifier
Example
getTrades()
Retrieves recent trades for a specific market.Market symbol (e.g., “SOL_USDCT”, “SOL_USDCT”)
Array of recent trade objects:
id(number): Unique trade identifierisBuyerMaker(boolean): True if buyer initiated the tradeprice(string): Trade execution pricequantity(string): Trade quantityquoteQuantity(string): Quote asset quantity (price × quantity)timestamp(number): Unix timestamp in milliseconds
Example
getKlines()
Retrieves candlestick (K-line) data for a specific market and time range.Market symbol (e.g., “SOL_USDCT”, “SOL_USDCT”)
Candlestick interval (e.g., “1m”, “5m”, “1h”, “1d”)
Start time in Unix timestamp (milliseconds)
Array of candlestick data sorted by end time:
open(string): Opening pricehigh(string): Highest pricelow(string): Lowest priceclose(string): Closing pricevolume(string): Base asset volumequoteVolume(string): Quote asset volumestart(string): Candle start timeend(string): Candle end timetrades(string): Number of trades in this candle
The response is automatically sorted by end time in ascending order.
Example
getTicker()
Retrieves 24-hour ticker data for a specific market.Market symbol (e.g., “SOL_USDCT”, “SOL_USDCT”)
24-hour ticker statistics:
symbol(string): Market symbolfirstPrice(string): Price 24 hours agolastPrice(string): Current pricehigh(string): Highest price in 24hlow(string): Lowest price in 24hpriceChange(string): Absolute price changepriceChangePercent(string): Percentage price changevolume(string): Base asset volumequoteVolume(string): Quote asset volumetrades(string): Number of trades
This function calls
getTickers() internally and filters for the specific market.Example
getTickers()
Retrieves 24-hour ticker data for all markets.Array of ticker objects for all available markets (see Ticker structure above)
Example
Trading Functions
createOrder()
Places a new order on the exchange.Order parameters:
market(string): Market symbol (e.g., “SOL_USDCT”)side(string): Order side (“buy” or “sell”)quantity(number): Order quantity in base assetprice(number): Limit priceuserId(string): User identifier
Order creation response from the API
Example
Ensure the user has sufficient balance before placing orders. The API will reject orders with insufficient funds.
User Management Functions
createUser()
Creates a new user account on the exchange.User creation response:
status(string): Creation statususer_id(string): Newly created user identifier
Example
Error Handling
All functions can throw axios errors. Implement proper error handling:Complete Usage Example
Type Definitions
For complete type definitions, see:apps/web/src/utils/types.ts- Type interfaces:
Depth,Trade,KLine,Ticker,CreateOrder,UserId
Source Location
apps/web/src/utils/requests.ts