openapi: 3.1.0 info: title: Api version: 0.1.0 description: >- OrahDEX API. Public market-data routes can be called without a key. Personal API keys are optional credentials accepted in X-API-Key or Authorization: Bearer headers. They apply per-key request limits and enforce the selected read, trading, or full scope. Wallet signatures are still required for sensitive trading and withdrawal actions; admin routes still require admin authorization. Never put API keys in URLs. servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: markets description: Market data and trading pairs - name: orderbook description: Order book operations - name: orders description: Order management - name: trades description: Trade history - name: wallet description: Wallet operations - name: portfolio description: Portfolio and balances - name: futures description: Futures/perpetuals trading - name: candles description: OHLCV candlestick data - name: personal-api-keys description: Wallet-owned personal API key management paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /markets: get: operationId: getMarkets tags: [markets] summary: Get all trading pairs/markets responses: "200": description: List of markets content: application/json: schema: type: array items: $ref: "#/components/schemas/Market" /markets/{symbol}: get: operationId: getMarket tags: [markets] summary: Get a single market parameters: - in: path name: symbol required: true schema: type: string responses: "200": description: Market details content: application/json: schema: $ref: "#/components/schemas/Market" /markets/{symbol}/ticker: get: operationId: getTicker tags: [markets] summary: Get 24h ticker for a market parameters: - in: path name: symbol required: true schema: type: string responses: "200": description: Ticker data content: application/json: schema: $ref: "#/components/schemas/Ticker" /markets/{symbol}/candles: get: operationId: getCandles tags: [candles] summary: Get OHLCV candlestick data parameters: - in: path name: symbol required: true schema: type: string - in: query name: interval schema: type: string enum: [1m, 5m, 15m, 1h, 4h, 1d, 1w] default: 1h - in: query name: limit schema: type: integer default: 200 responses: "200": description: Candlestick data content: application/json: schema: type: array items: $ref: "#/components/schemas/Candle" /markets/{symbol}/orderbook: get: operationId: getOrderBook tags: [orderbook] summary: Get order book for a market parameters: - in: path name: symbol required: true schema: type: string - in: query name: depth schema: type: integer default: 50 responses: "200": description: Order book content: application/json: schema: $ref: "#/components/schemas/OrderBook" /markets/{symbol}/trades: get: operationId: getRecentTrades tags: [trades] summary: Get recent trades for a market parameters: - in: path name: symbol required: true schema: type: string - in: query name: limit schema: type: integer default: 50 responses: "200": description: Recent trades content: application/json: schema: type: array items: $ref: "#/components/schemas/Trade" /orders: get: operationId: getOrders tags: [orders] summary: Get user orders parameters: - in: query name: walletAddress required: true schema: type: string - in: query name: symbol schema: type: string - in: query name: status schema: type: string enum: [open, filled, cancelled, partial, expired, pending, processing] - in: query name: limit schema: type: integer default: 50 minimum: 1 maximum: 200 - in: query name: offset schema: type: integer minimum: 0 default: 0 - in: query name: prioritizeSymbol description: Put this pair first without excluding any other pairs. schema: type: string - in: query name: includeTotals schema: type: boolean default: false responses: "200": description: User orders headers: X-Orders-Total: schema: type: integer X-Orders-Active: schema: type: integer X-Orders-Selected-Pair: schema: type: integer content: application/json: schema: type: array items: $ref: "#/components/schemas/Order" post: operationId: placeOrder tags: [orders] summary: Place a new order requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PlaceOrderRequest" responses: "201": description: Order placed content: application/json: schema: $ref: "#/components/schemas/Order" /orders/{orderId}: get: operationId: getOrder tags: [orders] summary: Get order by ID parameters: - in: path name: orderId required: true schema: type: string responses: "200": description: Order details content: application/json: schema: $ref: "#/components/schemas/Order" delete: operationId: cancelOrder tags: [orders] summary: Cancel an order parameters: - in: path name: orderId required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CancelOrderRequest" responses: "200": description: Order cancelled content: application/json: schema: $ref: "#/components/schemas/Order" /trades/history: get: operationId: getTradeHistory tags: [trades] summary: Get user trade history parameters: - in: query name: walletAddress required: true schema: type: string - in: query name: symbol schema: type: string - in: query name: limit schema: type: integer default: 50 responses: "200": description: Trade history content: application/json: schema: type: array items: $ref: "#/components/schemas/Trade" /explorer/blocks: get: operationId: getExplorerBlocks tags: [explorer] summary: Get recent BSV blocks parameters: - in: query name: limit schema: type: integer minimum: 1 maximum: 12 default: 8 responses: "200": description: Recent BSV block summaries content: application/json: schema: $ref: "#/components/schemas/ExplorerBlocksResponse" /explorer/block/{height}: get: operationId: getExplorerBlock tags: [explorer] summary: Get a BSV block and a page of its transaction IDs parameters: - in: path name: height required: true schema: type: integer minimum: 0 - in: query name: limit schema: type: integer minimum: 1 maximum: 100 default: 50 - in: query name: offset schema: type: integer minimum: 0 default: 0 responses: "200": description: Block details and paginated transaction IDs content: application/json: schema: $ref: "#/components/schemas/ExplorerBlockTransactions" /explorer/tx/{txid}: get: operationId: getExplorerTransaction tags: [explorer] summary: Look up a BSV transaction by ID parameters: - in: path name: txid required: true schema: type: string pattern: "^[a-fA-F0-9]{64}$" responses: "200": description: BSV transaction details content: application/json: schema: $ref: "#/components/schemas/ExplorerTransaction" /explorer/address/{address}/history: get: operationId: getExplorerAddressHistory tags: [explorer] summary: Get confirmed transactions for a BSV address parameters: - in: path name: address required: true schema: type: string - in: query name: limit schema: type: integer minimum: 1 maximum: 50 default: 25 - in: query name: token schema: type: string responses: "200": description: Paginated confirmed address history content: application/json: schema: $ref: "#/components/schemas/ExplorerAddressHistory" /explorer/activity: get: operationId: getExplorerActivity tags: [explorer] summary: Get recent public OrahDEX exchange activity parameters: - in: query name: limit schema: type: integer minimum: 1 maximum: 50 default: 25 - in: query name: offset schema: type: integer minimum: 0 default: 0 responses: "200": description: Paginated exchange activity with private address fields omitted content: application/json: schema: $ref: "#/components/schemas/ExplorerActivityPage" /portfolio: get: operationId: getPortfolio tags: [portfolio] summary: Get user portfolio/balances parameters: - in: query name: walletAddress required: true schema: type: string responses: "200": description: Portfolio data content: application/json: schema: $ref: "#/components/schemas/Portfolio" /futures/positions: get: operationId: getFuturesPositions tags: [futures] summary: Get user futures positions parameters: - in: query name: walletAddress required: true schema: type: string responses: "200": description: Futures positions content: application/json: schema: type: array items: $ref: "#/components/schemas/FuturesPosition" post: operationId: openFuturesPosition tags: [futures] summary: Open a futures position requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OpenFuturesPositionRequest" responses: "201": description: Position opened content: application/json: schema: $ref: "#/components/schemas/FuturesPosition" /futures/positions/{positionId}: delete: operationId: closeFuturesPosition tags: [futures] summary: Close a futures position parameters: - in: path name: positionId required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CloseFuturesPositionRequest" responses: "200": description: Position closed content: application/json: schema: $ref: "#/components/schemas/FuturesPosition" /futures/funding-rates: get: operationId: getFundingRates tags: [futures] summary: Get funding rates for futures markets responses: "200": description: Funding rates content: application/json: schema: type: array items: $ref: "#/components/schemas/FundingRate" /wallet/connect: post: operationId: connectWallet tags: [wallet] summary: Register wallet connection requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ConnectWalletRequest" responses: "200": description: Wallet connected content: application/json: schema: $ref: "#/components/schemas/WalletSession" /wallet/transactions: get: operationId: getWalletTransactions tags: [wallet] summary: Get wallet on-chain transactions parameters: - in: query name: walletAddress required: true schema: type: string - in: query name: limit schema: type: integer default: 20 responses: "200": description: Wallet transactions content: application/json: schema: type: array items: $ref: "#/components/schemas/WalletTransaction" /wallet-request/challenge: post: operationId: issueWalletRequestChallenge tags: [wallet] summary: Issue a short-lived wallet-signature challenge requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/WalletRequestChallengeInput" responses: "200": description: Single-use challenge to sign content: application/json: schema: $ref: "#/components/schemas/WalletRequestChallenge" "400": description: Unsupported resource or action /user/api-keys: get: operationId: listPersonalApiKeys tags: [personal-api-keys] summary: List keys owned by a wallet description: Requires X-Wallet-Auth-Challenge and X-Wallet-Auth-Signature headers from a fresh challenge bound to this wallet and request. parameters: - in: query name: walletAddress required: true schema: type: string - in: header name: X-Wallet-Auth-Challenge required: true schema: type: string - in: header name: X-Wallet-Auth-Signature required: true schema: type: string responses: "200": description: Safe key metadata; raw keys are never returned by list content: application/json: schema: $ref: "#/components/schemas/PersonalApiKeyListResponse" "401": description: Wallet proof missing, invalid, expired, or already used post: operationId: createPersonalApiKey tags: [personal-api-keys] summary: Create a wallet-owned API key description: Requires a fresh wallet signature bound to the normalized key name, permission, and rate limit. The raw key is returned once. parameters: - in: header name: X-Wallet-Auth-Challenge required: true schema: type: string - in: header name: X-Wallet-Auth-Signature required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PersonalApiKeyCreateRequest" responses: "201": description: Created key with one-time raw credential reveal content: application/json: schema: $ref: "#/components/schemas/PersonalApiKeyCreateResponse" "400": description: Invalid key details "401": description: Wallet proof missing, invalid, expired, or already used "503": description: API key secret or database is unavailable /user/api-keys/{id}: delete: operationId: revokePersonalApiKey tags: [personal-api-keys] summary: Revoke a key owned by a wallet parameters: - in: path name: id required: true schema: type: string - in: query name: walletAddress required: true schema: type: string - in: header name: X-Wallet-Auth-Challenge required: true schema: type: string - in: header name: X-Wallet-Auth-Signature required: true schema: type: string responses: "200": description: Key revoked content: application/json: schema: $ref: "#/components/schemas/PersonalApiKeyOperationResponse" "401": description: Wallet proof missing, invalid, expired, or already used "404": description: Key not owned by this wallet components: schemas: WalletRequestChallengeInput: type: object required: [walletAddress, resource, method] properties: walletAddress: type: string resource: type: string enum: [withdrawal-history, notifications, social-notifications, personal-api-keys] method: type: string enum: [GET, POST, DELETE] resourceId: type: string description: Required for DELETE personal-api-keys challenges context: type: object description: Required for key-creation challenges; contains name, permission, and rateLimit additionalProperties: true WalletRequestChallenge: type: object required: [challengeId, message] properties: challengeId: type: string message: type: string PersonalApiKey: type: object required: [id, name, permission, rateLimit, keyPreview, status, createdAt, lastUsedAt] properties: id: type: string name: type: string permission: type: string enum: [read, trading, full] rateLimit: type: integer minimum: 10 maximum: 200 keyPreview: type: string status: type: string enum: [active, revoked] createdAt: type: string format: date-time lastUsedAt: type: [string, "null"] format: date-time PersonalApiKeyListResponse: type: object required: [keys] properties: keys: type: array items: $ref: "#/components/schemas/PersonalApiKey" PersonalApiKeyCreateRequest: type: object required: [walletAddress, name, permission, rateLimit] properties: walletAddress: type: string name: type: string minLength: 1 maxLength: 100 permission: type: string enum: [read, trading, full] rateLimit: type: integer minimum: 10 maximum: 200 PersonalApiKeyCreateResponse: type: object required: [key, apiKey, oneTimeReveal] properties: key: type: string description: Raw API key, returned once only apiKey: $ref: "#/components/schemas/PersonalApiKey" oneTimeReveal: type: boolean const: true PersonalApiKeyOperationResponse: type: object required: [success] properties: success: type: boolean HealthStatus: type: object properties: status: type: string enum: [starting, ok, degraded, outage, unknown] uptime: type: integer minimum: 0 timestamp: type: string format: date-time services: type: array items: type: object properties: name: type: string status: type: string enum: [healthy, degraded, stuck, dead, starting] lastRunAt: type: [string, "null"] format: date-time lastSuccessAt: type: [string, "null"] format: date-time consecutiveFails: type: integer minimum: 0 avgDurationMs: type: integer minimum: 0 staleSinceMs: type: [integer, "null"] minimum: 0 required: - name - status - lastRunAt - lastSuccessAt - consecutiveFails - avgDurationMs - staleSinceMs alerts: type: array items: type: string required: - status - uptime - timestamp - services - alerts Market: type: object properties: symbol: type: string example: "BSV/USDT" baseAsset: type: string example: "BSV" quoteAsset: type: string example: "USDT" lastPrice: type: number priceChange24h: type: number priceChangePercent24h: type: number volume24h: type: number high24h: type: number low24h: type: number marketCap: type: number status: type: string enum: [active, suspended, delisted] type: type: string enum: [spot, futures] minOrderSize: type: number maxOrderSize: type: number tickSize: type: number makerFee: type: number takerFee: type: number required: - symbol - baseAsset - quoteAsset - lastPrice - priceChange24h - priceChangePercent24h - volume24h - high24h - low24h - status - type - makerFee - takerFee Ticker: type: object properties: symbol: type: string lastPrice: type: number bidPrice: type: number askPrice: type: number openPrice: type: number highPrice: type: number lowPrice: type: number volume: type: number quoteVolume: type: number priceChange: type: number priceChangePercent: type: number timestamp: type: string format: date-time required: - symbol - lastPrice - bidPrice - askPrice - openPrice - highPrice - lowPrice - volume - priceChange - priceChangePercent - timestamp Candle: type: object properties: time: type: number description: Unix timestamp in seconds open: type: number high: type: number low: type: number close: type: number volume: type: number required: - time - open - high - low - close - volume OrderBookEntry: type: object properties: price: type: number quantity: type: number total: type: number required: - price - quantity - total OrderBook: type: object properties: symbol: type: string bids: type: array items: $ref: "#/components/schemas/OrderBookEntry" asks: type: array items: $ref: "#/components/schemas/OrderBookEntry" lastUpdateTime: type: string format: date-time required: - symbol - bids - asks - lastUpdateTime Trade: type: object properties: id: type: string symbol: type: string side: type: string enum: [buy, sell] price: type: number quantity: type: number total: type: number fee: type: number feeAsset: type: string timestamp: type: string format: date-time txid: type: string description: BSV on-chain transaction ID walletAddress: type: string required: - id - symbol - side - price - quantity - total - fee - feeAsset - timestamp Order: type: object properties: id: type: string symbol: type: string walletAddress: type: string side: type: string enum: [buy, sell] type: type: string enum: [limit, market, stop_limit, stop_market, take_profit, oco] status: type: string enum: [open, filled, cancelled, partial, expired] price: type: number stopPrice: type: number quantity: type: number filledQuantity: type: number remainingQuantity: type: number total: type: number fee: type: number feeAsset: type: string timeInForce: type: string enum: [GTC, IOC, FOK, GTD] createdAt: type: string format: date-time updatedAt: type: string format: date-time txid: type: string signedTx: type: string description: BSV signed transaction hex required: - id - symbol - walletAddress - side - type - status - quantity - filledQuantity - remainingQuantity - fee - feeAsset - timeInForce - createdAt - updatedAt PlaceOrderRequest: type: object properties: symbol: type: string walletAddress: type: string side: type: string enum: [buy, sell] type: type: string enum: [limit, market, stop_limit, stop_market, take_profit, oco] price: type: number stopPrice: type: number quantity: type: number timeInForce: type: string enum: [GTC, IOC, FOK, GTD] default: GTC signedTx: type: string description: BSV signed transaction hex for on-chain settlement required: - symbol - walletAddress - side - type - quantity CancelOrderRequest: type: object properties: walletAddress: type: string signedTx: type: string required: - walletAddress Portfolio: type: object properties: walletAddress: type: string totalValueUSD: type: number totalPnlUSD: type: number totalPnlPercent: type: number balances: type: array items: $ref: "#/components/schemas/AssetBalance" openOrdersCount: type: integer openPositionsCount: type: integer required: - walletAddress - totalValueUSD - totalPnlUSD - totalPnlPercent - balances - openOrdersCount - openPositionsCount AssetBalance: type: object properties: asset: type: string free: type: number locked: type: number total: type: number valueUSD: type: number pnl24h: type: number pnl24hPercent: type: number required: - asset - free - locked - total - valueUSD FuturesPosition: type: object properties: id: type: string walletAddress: type: string symbol: type: string side: type: string enum: [long, short] leverage: type: number entryPrice: type: number markPrice: type: number liquidationPrice: type: number quantity: type: number margin: type: number unrealizedPnl: type: number unrealizedPnlPercent: type: number realizedPnl: type: number fundingFee: type: number status: type: string enum: [open, closed, liquidated] openedAt: type: string format: date-time closedAt: type: string format: date-time txid: type: string required: - id - walletAddress - symbol - side - leverage - entryPrice - markPrice - liquidationPrice - quantity - margin - unrealizedPnl - unrealizedPnlPercent - status - openedAt OpenFuturesPositionRequest: type: object properties: walletAddress: type: string symbol: type: string side: type: string enum: [long, short] leverage: type: number minimum: 1 maximum: 125 quantity: type: number orderType: type: string enum: [market, limit] price: type: number marginMode: type: string enum: [cross, isolated] signedTx: type: string required: - walletAddress - symbol - side - leverage - quantity - orderType - marginMode CloseFuturesPositionRequest: type: object properties: walletAddress: type: string closePrice: type: number signedTx: type: string required: - walletAddress FundingRate: type: object properties: symbol: type: string fundingRate: type: number nextFundingTime: type: string format: date-time lastFundingRate: type: number predictedFundingRate: type: number interval: type: string required: - symbol - fundingRate - nextFundingTime - interval ConnectWalletRequest: type: object properties: address: type: string description: BSV wallet address publicKey: type: string description: BSV public key provider: type: string enum: [handcash, relayx, twetch, panda, yours, sensilet] signature: type: string description: Signed message to verify wallet ownership message: type: string description: The message that was signed required: - address - provider WalletSession: type: object properties: address: type: string provider: type: string connected: type: boolean connectedAt: type: string format: date-time publicKey: type: string required: - address - provider - connected - connectedAt WalletTransaction: type: object properties: txid: type: string type: type: string enum: [deposit, withdrawal, trade, fee, funding] asset: type: string amount: type: number fee: type: number status: type: string enum: [confirmed, pending, failed] confirmations: type: integer timestamp: type: string format: date-time blockHeight: type: integer required: - txid - type - asset - amount - status - timestamp ExplorerBlock: type: object properties: height: type: integer hash: type: string confirmations: type: integer timestamp: type: integer sizeBytes: type: integer transactionCount: type: integer miner: type: string nullable: true previousBlockHash: type: string nullable: true required: - height - hash - confirmations - timestamp - sizeBytes - transactionCount - miner - previousBlockHash ExplorerBlocksResponse: type: object properties: network: type: string tipHeight: type: integer bestBlockHash: type: string blocks: type: array items: $ref: "#/components/schemas/ExplorerBlock" source: type: string updatedAt: type: string format: date-time required: - network - tipHeight - bestBlockHash - blocks - source - updatedAt ExplorerBlockTransactions: type: object properties: block: $ref: "#/components/schemas/ExplorerBlock" transactions: type: array items: type: string offset: type: integer limit: type: integer totalTransactions: type: integer hasMore: type: boolean required: - block - transactions - offset - limit - totalTransactions - hasMore ExplorerTransactionInput: type: object properties: txid: type: string nullable: true outputIndex: type: integer nullable: true coinbase: type: boolean addresses: type: array items: type: string required: - txid - outputIndex - coinbase - addresses ExplorerTransactionOutput: type: object properties: index: type: integer valueBsv: type: number addresses: type: array items: type: string type: type: string nullable: true required: - index - valueBsv - addresses - type ExplorerTransaction: type: object properties: txid: type: string blockHeight: type: integer nullable: true blockHash: type: string nullable: true confirmations: type: integer timestamp: type: integer nullable: true sizeBytes: type: integer inputs: type: array items: $ref: "#/components/schemas/ExplorerTransactionInput" outputs: type: array items: $ref: "#/components/schemas/ExplorerTransactionOutput" totalOutputBsv: type: number explorerUrl: type: string required: - txid - blockHeight - blockHash - confirmations - timestamp - sizeBytes - inputs - outputs - totalOutputBsv - explorerUrl ExplorerAddressTransaction: type: object properties: txid: type: string blockHeight: type: integer nullable: true required: - txid - blockHeight ExplorerAddressHistory: type: object properties: address: type: string items: type: array items: $ref: "#/components/schemas/ExplorerAddressTransaction" nextToken: type: string nullable: true source: type: string required: - address - items - nextToken - source ExplorerActivity: type: object properties: id: type: string category: type: string summary: type: string status: type: string pair: type: string nullable: true amount: type: string nullable: true asset: type: string nullable: true network: type: string nullable: true txid: type: string nullable: true blockHeight: type: integer nullable: true createdAt: type: string format: date-time onChain: type: boolean description: A recognized chain transaction reference is available; this does not prove confirmation. chainId: type: integer nullable: true description: EVM chain ID from stored order evidence, when unambiguous. transactionUrl: type: string format: uri nullable: true description: Chain-specific public explorer link. BSV references use the built-in BSV lookup. required: - id - category - summary - status - pair - amount - asset - network - txid - blockHeight - createdAt - onChain ExplorerActivityPage: type: object properties: items: type: array items: $ref: "#/components/schemas/ExplorerActivity" limit: type: integer offset: type: integer hasMore: type: boolean scope: type: string required: - items - limit - offset - hasMore - scope securitySchemes: PersonalApiKey: type: apiKey in: header name: X-API-Key description: "Optional personal API key. Authorization: Bearer is also accepted."