### Node.js Quick Start Example Source: https://docs.houdiniswap.com/developer-hub/core-concepts/websocket-order-updates Example of how to connect and interact with the WebSocket API using Node.js. ```APIDOC ## Node.js Quick Start Example This example demonstrates how to connect to the WebSocket API, authenticate, and subscribe to order updates using Node.js. ```javascript // Note: Custom headers require a Node.js WebSocket client (e.g. 'ws' npm package). // Browser-native WebSocket does not support custom headers. const WebSocket = require("ws"); const ws = new WebSocket("wss://partner-api.houdiniswap.com/v2/ws", { headers: { Authorization: "your-partner-id:your-secret" }, }); ws.onopen = () => { // Subscribe to all your orders ws.send(JSON.stringify({ type: "subscribe" })); }; ws.onmessage = (event) => { const message = JSON.parse(event.data); switch (message.type) { case "welcome": console.log("Connected as", message.partnerId); break; case "order_update": console.log("Order updated:", message.data.houdiniId, "→", message.data.status); break; case "subscribed": console.log("Subscribed to:", message.houdiniIds); break; } }; ``` ``` -------------------------------- ### Complete Houdini Widget Implementation Source: https://docs.houdiniswap.com/developer-hub/widget/overview A full HTML example demonstrating the script inclusion, container setup, and initialization with custom theme options. ```html My App with Houdini
``` -------------------------------- ### Install x402 Dependencies Source: https://docs.houdiniswap.com/developer-hub/core-concepts/x402-pay-per-request Install the necessary packages to enable x402 payment handling in a Node.js environment. ```bash npm install @x402/fetch @x402/evm viem ``` -------------------------------- ### v1 Order Status Request Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v1 GET request to check order status using an ID query parameter. ```http GET /status?id=HOUDINI123 ``` -------------------------------- ### v2 List Orders Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of the new v2 endpoint to list orders with pagination. ```http GET /v2/orders ``` -------------------------------- ### v2 Exchange Request Example (Step 1: Get Quote) Source: https://docs.houdiniswap.com/migration/v1-to-v2 First step in the v2 exchange flow: obtaining a quote using token ObjectIds. ```http # Step 1: Get quote GET /v2/quotes?from=&to=&amount=1 ``` -------------------------------- ### v2 Volume Stats Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of fetching volume statistics using the v2 endpoint. ```http GET /v2/stats/volume ``` -------------------------------- ### v1 Quote Request Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v1 GET request to retrieve a quote using token short names. ```http GET /quote?from=BTC&to=ETH&amount=1 ``` -------------------------------- ### v2 Order Status Request Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v2 GET request to retrieve order status using the order ID as a path parameter. ```http GET /v2/orders/HOUDINI123 ``` -------------------------------- ### v1 Exchange Request Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v1 POST request to initiate an exchange directly with token details. ```json POST /exchange { "from": "BTC", "to": "ETH", "amount": 1, "addressTo": "0x..." } ``` -------------------------------- ### Example API Request with Authentication Source: https://docs.houdiniswap.com/developer-hub/getting-started/authentication This example demonstrates how to make a quote request using fetch, including the Authorization header with your API key and secret, and mandatory compliance headers. ```javascript // Build query parameters const params = new URLSearchParams({ amount: '1', from: 'ETH', to: 'USDC', anonymous: 'true', useXmr: 'false' }); const response = await fetch(`https://api-partner.houdiniswap.com/quote?${params}`, { method: 'GET', headers: { 'Authorization': 'your_api_key:your_api_secret', // Mandatory compliance headers 'x-user-ip': '192.168.1.1', 'x-user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36...', 'x-user-timezone': 'America/New_York' } }); const data = await response.json(); ``` ```bash curl -X GET "https://api-partner.houdiniswap.com/quote?amount=1&from=ETH&to=USDC&anonymous=true&useXmr=false" \ -H "Authorization: your_api_key:your_api_secret" \ -H "x-user-ip: 192.168.1.1" \ -H "x-user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36..." \ -H "x-user-timezone: America/New_York" ``` -------------------------------- ### v1 MinMax Response Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v1 response for min/max values, returned as a flat array. ```json [ 0.001, 10 ] ``` -------------------------------- ### v2 MinMax Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of fetching min/max values using the v2 endpoint, which returns a structured object. ```http GET /v2/minMax ``` -------------------------------- ### v2 Weekly Volume Stats Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of fetching weekly volume statistics using the v2 endpoint. ```http GET /v2/stats/weeklyVolume ``` -------------------------------- ### v2 DEX Confirm Transaction Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of the v2 endpoint for confirming a DEX transaction. ```http POST /v2/dex/confirmTx ``` -------------------------------- ### v2 Quote Request Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v2 GET request to retrieve a quote using MongoDB ObjectId strings for tokens. ```http GET /v2/quotes?from=&to=&amount=1 ``` -------------------------------- ### v2 Token Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of fetching paginated token data using the v2 endpoint. Note the use of ObjectIds. ```http GET /v2/tokens ``` -------------------------------- ### v2 MinMax Response Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of a v2 response for min/max values, returned as a structured object with cex, dex, and private fields. ```json { "cex": { "min": 0.001, "max": 10 }, "dex": { "min": 0.01, "max": 5 }, "private": { "min": 0.1, "max": 100 } } ``` -------------------------------- ### v2 DEX Quote Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of fetching a DEX-specific quote by specifying the type in the query parameters. ```http GET /v2/quotes?types=DEX ``` -------------------------------- ### v2 DEX Token Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of filtering tokens to include only DEX-enabled ones using a query parameter. ```http GET /v2/tokens?hasDex=true ``` -------------------------------- ### v2 Chain Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of fetching chain data using the v2 endpoint. Note the use of ObjectIds for chain identifiers. ```http GET /v2/chains ``` -------------------------------- ### v2 DEX Allowance Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of the v2 endpoint for checking DEX allowance, which uses quoteId. ```http POST /v2/dex/allowance ``` -------------------------------- ### Order Response Structure Source: https://docs.houdiniswap.com/developer-hub/swap-flows/standard-swap Example JSON response received after successfully creating an order. ```json { "houdiniId": "iBQMRX3xvXrFMGQi71ogo9", "created": "2025-12-25T06:13:46.673Z", "expires": "2025-12-25T06:43:46.673Z", "depositAddress": "0x7364a0b6c55004427a4a7c26355ce9c75ef56194", "receiverAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", "anonymous": false, "status": -1, "statusLabel": "NEW", "inAmount": 1, "inSymbol": "ETH", "inStatus": 0, "inStatusLabel": "NEW", "outAmount": 2456.78, "outSymbol": "USDC", "outStatus": 0, "outStatusLabel": "NEW", "eta": 3, "inAmountUsd": 2937, "swapName": "Changelly", "inToken": { "id": "6689b73ec90e45f3b3e51566", "symbol": "ETH", "name": "Ethereum", "decimals": 18, "chain": "ethereum" }, "outToken": { "id": "6689b73ec90e45f3b3e51558", "symbol": "USDC", "name": "USD Coin", "decimals": 6, "chain": "ethereum" } } ``` -------------------------------- ### GET /swaps Source: https://docs.houdiniswap.com/api-reference/liquidity-providers/get-all-available-swapsexchanges Retrieves a list of all available swap providers (exchanges) that can be used for trading. ```APIDOC ## GET /swaps ### Description Returns all available swap providers (exchanges) that can be used for trading. This includes both centralized exchanges (CEX) and decentralized exchanges (DEX). ### Method GET ### Endpoint /swaps ### Response #### Success Response (200) - **id** (string) - Unique identifier of the swap provider - **name** (string) - Full name of the provider - **shortName** (string) - Shortened name of the provider - **txUrl** (string) - URL for transaction tracking - **enabled** (boolean) - Whether the provider is currently enabled - **isDex** (boolean) - Whether the provider is a decentralized exchange - **deprecated** (boolean) - Whether the provider is deprecated - **markupSupported** (boolean) - Whether markup is supported - **slippageSupported** (boolean) - Whether slippage is supported - **autoSlippageSupported** (boolean) - Whether auto-slippage is supported - **logoUrl** (string) - URL to the provider's logo #### Response Example [ { "id": "example-id", "name": "Example Exchange", "shortName": "EX", "enabled": true } ] ``` -------------------------------- ### Example Token Response Source: https://docs.houdiniswap.com/developer-hub/core-concepts/tokens-networks Structure of the JSON response returned by the tokens endpoint. ```json { "tokens": [ { "id": "6689b73ec90e45f3b3e51566", "symbol": "ETH", "name": "Ethereum", "address": "0x0000000000000000000000000000000000000000", "chain": "ethereum", "decimals": 18, "icon": "https://api.houdiniswap.com/assets/tokens/ETH.png", "hasCex": true, "hasDex": true, "enabled": true, "price": 2937, "minMax": { "cex": { "min": 0.0253712625, "max": 16.914175 }, "dex": { "min": 0.005, "max": 50 }, "private": { "min": 0.0845708751, "max": 16.914175 } } } ], "total": 1, "totalPages": 1 } ``` -------------------------------- ### Response structure for chains Source: https://docs.houdiniswap.com/api-reference/chains/get-available-chains Example JSON response containing the list of chains and pagination metadata. ```json { "chains": [ { "id": "507f1f77bcf86cd799439011", "name": "Bitcoin", "shortName": "bitcoin", "memoNeeded": false, "explorerUrl": "https://blockchair.com/bitcoin/transaction/{txHash}", "addressUrl": "https://blockchair.com/bitcoin/address/{address}", "kind": "bitcoin", "addressValidation": "^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,59}$", "tokenAddressValidation": "^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,59}$", "icon": "https://api.houdiniswap.com/assets/networks/BTC.png", "priority": 2, "chainId": 1 } ], "total": 123, "totalPages": 123 } ``` -------------------------------- ### Node.js WebSocket Client Implementation Source: https://docs.houdiniswap.com/developer-hub/core-concepts/websocket-order-updates Example using the 'ws' package to connect, authenticate, and handle incoming order updates. ```javascript // Note: Custom headers require a Node.js WebSocket client (e.g. 'ws' npm package). // Browser-native WebSocket does not support custom headers. const WebSocket = require("ws"); const ws = new WebSocket("wss://partner-api.houdiniswap.com/v2/ws", { headers: { Authorization: "your-partner-id:your-secret" }, }); ws.onopen = () => { // Subscribe to all your orders ws.send(JSON.stringify({ type: "subscribe" })); }; ws.onmessage = (event) => { const message = JSON.parse(event.data); switch (message.type) { case "welcome": console.log("Connected as", message.partnerId); break; case "order_update": console.log("Order updated:", message.data.houdiniId, "→", message.data.status); break; case "subscribed": console.log("Subscribed to:", message.houdiniIds); break; } }; ``` -------------------------------- ### Get Standard Swap Quotes Source: https://docs.houdiniswap.com/developer-hub/swap-flows/standard-swap Call the /quotes endpoint using token IDs to get quotes from all providers. This example specifically filters for 'standard' type quotes, which represent single-hop CEX routing. ```javascript const params = new URLSearchParams({ amount: '1', from: '6689b73ec90e45f3b3e51566', // ETH token id from /tokens to: '6689b73ec90e45f3b3e51558', // USDC token id from /tokens types: 'standard', // only return standard quotes }); const response = await fetch( `https://api-partner.houdiniswap.com/v2/quotes?${params}`, { headers: { 'Authorization': `${API_KEY}:${API_SECRET}`, 'x-user-ip': userIp, 'x-user-agent': userAgent, 'x-user-timezone': userTimezone } } ); const { quotes } = await response.json(); // Pick a standard (single-hop CEX) quote const standardQuote = quotes.find(q => q.type === 'standard'); console.log('Provider:', standardQuote.swapName); console.log('Amount out:', standardQuote.amountOut); console.log('ETA:', standardQuote.duration, 'minutes'); console.log('Quote ID:', standardQuote.quoteId); // needed for next step ``` -------------------------------- ### Example Standard Swap Progress JSON Source: https://docs.houdiniswap.com/developer-hub/core-concepts/order-lifecycle Illustrates a JSON object representing the progress of a standard swap, showing the overall status and the current input status. ```json { "houdiniId": "abc123", "status": 2, // EXCHANGING "inStatus": 3, // Currently swapping } ``` -------------------------------- ### Initialize x402 Payment Client Source: https://docs.houdiniswap.com/developer-hub/core-concepts/x402-pay-per-request Configure the x402 client with an EVM signer to handle automated USDC payments for API requests. ```javascript import { x402Client, x402HTTPClient } from "@x402/fetch"; import { registerExactEvmScheme } from "@x402/evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; // Create signer from your wallet's private key const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`); // Create x402 client and register EVM payment scheme const client = new x402Client(); registerExactEvmScheme(client, { signer }); const httpClient = new x402HTTPClient(client); ``` -------------------------------- ### Execute Full Exchange Flow Source: https://docs.houdiniswap.com/developer-hub/core-concepts/x402-pay-per-request A complete implementation demonstrating token lookup, quoting, exchange creation, and status polling using the x402 SDK. ```typescript import { x402Client, x402HTTPClient } from "@x402/fetch"; import { registerExactEvmScheme } from "@x402/evm/exact/client"; import { privateKeyToAccount } from "viem/accounts"; const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`); const client = new x402Client(); registerExactEvmScheme(client, { signer }); const httpClient = new x402HTTPClient(client); const BASE = "https://api-partner.houdiniswap.com/v2"; const x402Fetch = async (url: string, options: RequestInit = {}) => { const res = await fetch(url, options); if (res.status !== 402) return res; const pr = httpClient.getPaymentRequiredResponse((n) => res.headers.get(n), undefined); const payload = await client.createPaymentPayload(pr); const headers = httpClient.encodePaymentSignatureHeader(payload); return fetch(url, { ...options, headers: { ...options.headers, ...headers } }); }; // Step 1: Look up tokens ($0.0001 each) const btcRes = await x402Fetch(`${BASE}/tokens?term=BTC&hasCex=true`); const btcData = await btcRes.json(); const btcToken = btcData.tokens.find((t: any) => t.chain === "bitcoin"); const ethRes = await x402Fetch(`${BASE}/tokens?term=ETH&hasCex=true`); const ethData = await ethRes.json(); const ethToken = ethData.tokens.find((t: any) => t.chain === "ethereum"); // Step 2: Get a quote ($0.001) const quoteRes = await x402Fetch( `${BASE}/quotes?from=${btcToken.id}&to=${ethToken.id}&amount=0.01` ); const quoteData = await quoteRes.json(); const quote = quoteData.quotes[0]; console.log(`Quote: ${quote.amountOut} ETH`); // Step 3: Create exchange ($0.01) const exchangeRes = await x402Fetch(`${BASE}/exchanges`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ quoteId: quote.quoteId, addressTo: "0xYourEthAddress...", }), }); const exchange = await exchangeRes.json(); console.log(`Order: ${exchange.houdiniId}, deposit to: ${exchange.depositAddress}`); // Step 4: Poll status ($0.0001 each) const checkStatus = async () => { const res = await x402Fetch(`${BASE}/orders/${exchange.houdiniId}`); return res.json(); }; let status = await checkStatus(); const DONE = [4, 5, 6, 7, 8]; // completed, expired, failed, refunded, deleted while (!DONE.includes(status.status)) { await new Promise((r) => setTimeout(r, 30000)); // Wait 30s status = await checkStatus(); console.log(`Status: ${status.status}`); } ``` -------------------------------- ### v2 Exchange Request Example (Step 2: Create Exchange) Source: https://docs.houdiniswap.com/migration/v1-to-v2 Second step in the v2 exchange flow: creating an exchange using the obtained quoteId. ```json # Step 2: Create exchange with quoteId POST /v2/exchanges { "quoteId": "", "addressTo": "0x..." } ``` -------------------------------- ### Welcome Message Source: https://docs.houdiniswap.com/developer-hub/core-concepts/websocket-order-updates The initial message received upon successful connection. ```json { "type": "welcome", "partnerId": "your-partner-id" } ``` -------------------------------- ### v2 DEX Chain Signatures Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of the v2 endpoint for obtaining DEX chain signatures, which uses quoteId. ```http POST /v2/dex/chainSignatures ``` -------------------------------- ### v2 Merged Exchange Endpoint Example Source: https://docs.houdiniswap.com/migration/v1-to-v2 Example of using the merged v2 exchanges endpoint for both CEX and DEX trades, requiring a quoteId. ```json POST /v2/exchanges { "quoteId": "", "addressTo": "0x..." } ``` -------------------------------- ### Initialize Houdini Widget Source: https://docs.houdiniswap.com/developer-hub/widget/overview Configure and mount the widget using your API key and the target container selector. ```javascript HoudiniWidget.init({ apiKey: 'your_api_key_here', container: '#houdini-swap-widget' }); ``` -------------------------------- ### Get partner rate limits OpenAPI definition Source: https://docs.houdiniswap.com/api-reference/rate-limits/get-partner-rate-limits Defines the GET /rateLimits endpoint and the associated response schemas for partner rate limits. ```yaml openapi: 3.0.0 info: title: houdiniswap-backend version: 2.1.0 description: Houdiniswap Backend license: name: ISC contact: {} servers: - url: https://api-partner.houdiniswap.com/v2 security: [] paths: /rateLimits: get: tags: - Rate Limits summary: Get partner rate limits operationId: GetRateLimits parameters: [] responses: '200': description: Success content: application/json: schema: $ref: '#/components/schemas/RateLimitsResponse' '403': description: Access Denied content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '422': description: Validation Failed content: application/json: schema: $ref: '#/components/schemas/ValidationError' '500': description: Internal Server Error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' security: - apiKey: [] components: schemas: RateLimitsResponse: properties: quote: properties: perDay: type: number format: double description: Requests allowed per day perHour: type: number format: double description: Requests allowed per hour perMinute: type: number format: double description: Requests allowed per minute required: - perDay - perHour - perMinute type: object exchange: properties: perDay: type: number format: double description: Requests allowed per day perHour: type: number format: double description: Requests allowed per hour perMinute: type: number format: double description: Requests allowed per minute required: - perDay - perHour - perMinute type: object required: - quote - exchange type: object additionalProperties: false ErrorResponse: properties: message: type: string code: type: string requestId: type: string required: - message - code type: object additionalProperties: false ValidationError: properties: message: type: string code: type: string requestId: type: string fields: $ref: '#/components/schemas/FieldErrors' required: - message - code - fields type: object additionalProperties: false FieldErrors: properties: {} type: object additionalProperties: properties: value: {} message: type: string required: - message type: object securitySchemes: apiKey: type: apiKey name: Authorization in: header ``` -------------------------------- ### Example Private Swap Status Object Source: https://docs.houdiniswap.com/developer-hub/core-concepts/order-lifecycle Represents a private swap currently in progress across two hops. ```json { "houdiniId": "bwc5iKVeeW5GiQpLHCm65w", "status": 3, // ANONYMIZING (overall status) "inStatus": 4, // First hop: sending to second exchange "outStatus": 2, // Second hop: receiving from first hop } ``` -------------------------------- ### v1 vs v2 Behavior Comparison Source: https://docs.houdiniswap.com/developer-hub/core-concepts/payout-wallet-rotation Highlights the differences in rotation configuration and behavior between v1 and v2 of the API. ```APIDOC ## API Version Behavior Comparison ### Description This section details the differences in how rotation is handled between API v1 and v2. ### Key Differences | Aspect | v1 | v2 | |---|---|---| | **Where rotation is configured** | Quote endpoint, exchange endpoint, or both | Quote endpoint only | | **How rotation reaches the exchange** | `filters` object passed directly in exchange body | Inherited from the selected quote via `quoteId` | | **Quote IDs with rotation** | Discarded when rotation is enabled on exchange | Preserved — rotation is already applied to the quote | | **Latency impact** | Adds ~3-5s when used on exchange (re-quotes) | No additional latency on exchange | ### Recommendation for v1 Integrations For v1 integrations, it is recommended to use rotation at **quote time** (Option A) rather than exchange time. This approach avoids the re-quoting overhead and provides visibility into the rotated quotes before finalizing an exchange. ``` -------------------------------- ### GET /v2/quotes Source: https://docs.houdiniswap.com/developer-hub/troubleshooting/error-codes-and-troubleshooting Retrieves price quotes for token exchanges. This endpoint allows users to get the best available rates for swapping one token to another. ```APIDOC ## GET /v2/quotes ### Description Retrieves price quotes for token exchanges. This endpoint allows users to get the best available rates for swapping one token to another. ### Method GET ### Endpoint /v2/quotes ### Query Parameters - **from** (string) - Required - The token to swap from. - **to** (string) - Required - The token to swap to. - **amount** (string) - Required - The amount of the `from` token to swap. - **anonymousToken** (string) - Optional - An intermediary token for private quotes. ### Response #### Success Response (200) - **data** (object) - Contains quote details. - **toAmount** (string) - The amount of the `to` token received. - **fromAmount** (string) - The amount of the `from` token used. - **quoteId** (string) - Unique identifier for the quote. - **provider** (string) - The exchange provider used for the quote. - **estimatedGas** (string) - Estimated gas fees for the transaction. - **swapType** (string) - Type of swap (e.g., 'direct', 'private'). - **allowPartialFill** (boolean) - Whether partial fills are allowed. - ** தாக்க** (string) - The exchange rate. #### Error Response (422) - **error** (string) - Error code (e.g., `VALIDATION_ERROR`, `QUOTE_OVER_LIMIT`, `AMOUNT_TOO_LOW`, `UNSUPPORTED_FROM_TOKEN`, `UNSUPPORTED_TO_TOKEN`, `TO_AND_FROM_CANNOT_BE_THE_SAME`, `UNSUPPORTED_ANON_TOKEN`, `SWAP_AMOUNT_IS_OUT_OF_BOUNDS`, `XMR_SWAP_AMOUNT_IS_OUT_OF_BOUNDS`). - **message** (string) - Description of the error. - **fields** (object) - Object containing details about validation errors, if applicable. #### Error Response (429) - **error** (string) - `RATE_LIMIT_EXCEEDED`. - **message** (string) - Rate limit information, including tier, limit, window, and retryAfter seconds. - **meta** (object) - Additional metadata about the rate limit. #### Error Response (503) - **error** (string) - `PRICE_QUOTES_NOT_RETRIEVED` or `ANONYMOUS_DISABLED`. - **message** (string) - Description of the service unavailability. #### Error Response (500) - **error** (string) - `INTERNAL_SERVER_ERROR`. - **message** (string) - Generic internal server error message. ### Request Example ```json { "from": "ETH", "to": "USDC", "amount": "1000000000000000000" } ``` ### Response Example (Success) ```json { "data": { "toAmount": "1500000000000000000", "fromAmount": "1000000000000000000", "quoteId": "q_abc123xyz", "provider": "Uniswap", "estimatedGas": "50000000000000", "swapType": "direct", "allowPartialFill": false, "rate": "1.5" } } ``` ### Response Example (Validation Error) ```json { "error": "VALIDATION_ERROR", "message": "Validation Failed", "fields": { "amount": "Amount is required." } } ``` ``` -------------------------------- ### Create an Order Source: https://docs.houdiniswap.com/developer-hub/swap-flows/standard-swap Submit a quote ID and destination address to initiate an exchange. Requires user-specific headers for IP, user agent, and timezone. ```javascript const response = await fetch('https://api-partner.houdiniswap.com/v2/exchanges', { method: 'POST', headers: { 'Authorization': `${API_KEY}:${API_SECRET}`, 'Content-Type': 'application/json', 'x-user-ip': userIp, 'x-user-agent': userAgent, 'x-user-timezone': userTimezone }, body: JSON.stringify({ quoteId: '694cd4ef6ca7023b5e00a288', // from /quotes addressTo: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e' }) }); const order = await response.json(); console.log('Order ID:', order.houdiniId); console.log('Deposit to:', order.depositAddress); console.log('Send amount:', order.inAmount, order.inSymbol); console.log('Expires:', order.expires); ``` -------------------------------- ### GET /orders/{houdiniId} - Monitor Order Status Source: https://docs.houdiniswap.com/developer-hub/swap-flows/standard-swap Polls the API to get the current status of an order using its unique Houdini ID. This is crucial for tracking the swap progress. ```APIDOC ## GET /orders/{houdiniId} ### Description Polls the API to track the progress of an order. It is recommended to poll every 30 seconds. ### Method GET ### Endpoint `https://api-partner.houdiniswap.com/v2/orders/{houdiniId}` ### Parameters #### Path Parameters - **houdiniId** (string) - Required - The unique identifier for the order. ### Response #### Success Response (200) - **statusLabel** (string) - Human-readable order status. Possible values include: WAITING, CONFIRMING, EXCHANGING, FINISHED, FAILED, EXPIRED, REFUNDED. #### Response Example ```json { "houdiniId": "iBQMRX3xvXrFMGQi71ogo9", "created": "2025-12-25T06:13:46.673Z", "expires": "2025-12-25T06:43:46.673Z", "depositAddress": "0x7364a0b6c55004427a4a7c26355ce9c75ef56194", "receiverAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", "anonymous": false, "status": -1, "statusLabel": "NEW", "inAmount": 1, "inSymbol": "ETH", "inStatus": 0, "inStatusLabel": "NEW", "outAmount": 2456.78, "outSymbol": "USDC", "outStatus": 0, "outStatusLabel": "NEW", "eta": 3, "inAmountUsd": 2937, "swapName": "Changelly", "inToken": { "id": "6689b73ec90e45f3b3e51566", "symbol": "ETH", "name": "Ethereum", "decimals": 18, "chain": "ethereum" }, "outToken": { "id": "6689b73ec90e45f3b3e51558", "symbol": "USDC", "name": "USD Coin", "decimals": 6, "chain": "ethereum" } } ``` ``` -------------------------------- ### Get Partner Weekly Volume Stats (cURL) Source: https://docs.houdiniswap.com/api-reference/stats/get-partner-weekly-volume-stats Use this cURL command to make a GET request to the API endpoint for weekly volume statistics. Ensure you replace '' with your actual API key for authorization. ```bash curl --request GET \ --url https://api-partner.houdiniswap.com/v2/stats/weeklyVolume \ --header 'Authorization: ' ``` -------------------------------- ### GET /v2/orders Source: https://docs.houdiniswap.com/developer-hub/troubleshooting/error-codes-and-troubleshooting Retrieves order information from the HoudiniSwap platform. ```APIDOC ## GET /v2/orders ### Description Retrieves a list of orders or specific order details. ### Method GET ### Endpoint /v2/orders /v2/orders/{houdiniId} ### Parameters #### Path Parameters - **houdiniId** (string) - Optional - The unique identifier for the order. ### Response #### Success Response (200) - **order** (object) - The requested order details. #### Error Responses - **404 (NOT_FOUND)** - Order doesn't exist or belongs to a different partner. - **422 (VALIDATION_ERROR)** - Invalid query parameters. - **429 (RATE_LIMIT_EXCEEDED)** - Rate limit exceeded. - **500 (INTERNAL_SERVER_ERROR)** - Internal server error. ```