### Install dependencies Source: https://docs.xrocket.exchange/api/exchange/guides/tutorials/trading-bot-tutorial Install the required requests library for API interaction. ```bash pip install requests ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-account-balances Example command to fetch balances using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/funding/balances' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-asset-controller-get-assets Example command to fetch assets using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/assets' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/app-controller-get-app Example command to fetch application information using cURL. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/app-info' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/transfer-controller-get-list-transfers Example command to fetch transfers using cURL. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/transfers' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/rate-controller-get-rates Example command to fetch rates using cURL. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/rates?assets=BTC%2CETH%2CXROCK' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/transfer-controller-get-transfer Example command to retrieve transfer information via the API. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/transfer' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/currencies-controller-get-currencies Example command to fetch currencies using cURL. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/currencies' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-asset-controller-get-asset Example command to fetch asset details using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/assets/:asset' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-orderbook Example command to retrieve the orderbook using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/orderbook' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/withdrawal-controller-get-withdrawals Example command to retrieve withdrawals using cURL. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/withdrawals' \ -H 'Accept: application/json' ``` -------------------------------- ### cURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-candles Example command to fetch candle data from the exchange API. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/candles' \ -H 'Accept: application/json' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-account-controller-get-account-balances Example command to fetch account balances using cURL with Bearer token authentication. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/trading/balances' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-symbols Example command to fetch symbols using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/symbols' \ -H 'Accept: application/json' ``` -------------------------------- ### Get Rates Success Response Source: https://docs.xrocket.exchange/api/pay/reference/http/rate-controller-get-rates Example JSON response returned when the request is successful. ```json [ { "currency": "TONCOIN", "rate": "291.87" } ] ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-order-controller-get-orders-history Example command to retrieve order history using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/orders/history' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Subscription Push Examples Source: https://docs.xrocket.exchange/api/exchange/websocket/private-balances Examples of push notifications received when balance data updates, showing both single and multiple asset scenarios. ```json { "method": "subscription", "params": { "channel": "balances", "data": { "balances": [ { "asset": "BTC", "balance": "1.23456789", "available": "1.00000000", "holds": "0.23456789" } ] } } } ``` ```json { "method": "subscription", "params": { "channel": "balances", "data": { "balances": [ { "asset": "BTC", "balance": "1.23456789", "available": "1.00000000", "holds": "0.23456789" }, { "asset": "USDT", "balance": "5678.90", "available": "5000.00", "holds": "678.90" } ] } } } ``` -------------------------------- ### Subscription Push Example Source: https://docs.xrocket.exchange/api/exchange/websocket/public-trades Example of the real-time data push received when a trade occurs for the subscribed symbol. ```json { "method": "subscription", "params": { "channel": "trades", "symbol": "BTC-USDT", "data": { "trades": [ { "tradeId": "3262786978", "price": "51200.00", "side": "buy", "time": "2024-12-19T10:44:17.347Z", "size": "0.15000000" } ] } } } ``` -------------------------------- ### CURL Request Example Source: https://docs.xrocket.exchange/api/pay/reference/http/invoice-pay-controller-pay-invoice Example command to perform the PUT request using cURL. ```bash curl -L -X PUT 'https://pay.api.xrocket.exchange/api/v1/invoices/pay' ``` -------------------------------- ### Get Withdrawal Quotas via cURL Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawal-quotas Example request to fetch withdrawal quotas using the cURL command-line tool. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawal-quotas' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Get Trade Fees cURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-account-controller-get-trade-fees Example command to retrieve trade fees for specific symbols using the cURL utility. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/trade-fees?symbols=BTC-USDT%2CXROCK-USDT' \ -H 'Accept: application/json' ``` -------------------------------- ### Successful Assets Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-asset-controller-get-assets Example JSON response body for a successful 200 OK request. ```json { "assets": [ { "asset": "BTC", "precision": 6 } ] } ``` -------------------------------- ### Transfer Request Examples Source: https://docs.xrocket.exchange/api/pay/reference/http/transfer-controller-transfer Examples of how to structure a transfer request using cURL or raw JSON body. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/transfers' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -d '{ "clientTransferId": "abc-def", "target": "87209764", "targetType": "telegram_user_id", "asset": "TONCOIN", "amount": "1.23", "description": "You are awesome!" }' ``` ```json { "clientTransferId": "abc-def", "target": "87209764", "targetType": "telegram_user_id", "asset": "TONCOIN", "amount": "1.23", "description": "You are awesome!" } ``` -------------------------------- ### Get Cheque cURL Request Source: https://docs.xrocket.exchange/api/pay/reference/http/cheque-controller-get-cheque Example command to retrieve cheque information using the cURL utility. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/cheque' \ -H 'Accept: application/json' ``` -------------------------------- ### Get Transfers cURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-transfer-controller-get-transfers Example cURL command to retrieve account transfers filtered by asset. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/transfers?assets=XROCK' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### cURL Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-transfer-controller-get-transfer-by-transfer-id Example command to perform a transfer request using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/transfer' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Get Active Orders cURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-order-controller-get-active-orders Example command to retrieve active orders using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/orders/active' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Subscription Push Example Source: https://docs.xrocket.exchange/api/exchange/websocket/public-ticker Example of the data payload pushed to the client when a ticker update occurs. ```json { "method": "subscription", "params": { "channel": "ticker", "interval": "1day", "symbol": "BTC-USDT", "data": { "ticker": { "symbol": "BTC-USDT", "startTime": "2024-12-19T10:44:17.347Z", "endTime": "2024-12-20T10:44:17.347Z", "open": "50000.00", "close": "51200.00", "high": "51500.00", "low": "49800.00", "changeRate": "0.024", "changePrice": "1200.00", "baseVolume": "1234.56789", "quoteVolume": "62500000.00", "last": "51200.00" } } } } ``` -------------------------------- ### Subscription push data example Source: https://docs.xrocket.exchange/api/exchange/websocket/public-all-tickers Example of the data payload pushed by the server for the allTickers channel. ```json { "method": "subscription", "params": { "channel": "allTickers", "interval": "1day", "data": { "tickers": [ { "symbol": "BTC-USDT", "startTime": "2024-12-19T10:44:17.347Z", "endTime": "2024-12-20T10:44:17.347Z", "open": "50000.00", "close": "51200.00", "high": "51500.00", "low": "49800.00", "changeRate": "0.024", "changePrice": "1200.00", "baseVolume": "1234.56789", "quoteVolume": "62500000.00", "last": "51200.00" } ] } } } ``` -------------------------------- ### Transfer response example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-transfer-controller-transfer Example JSON response returned upon a successful transfer request. ```json { "asset": "XROCK", "amount": "123.456", "from": "funding", "to": "trading", "clientTransferId": "12345", "transferId": "2355231", "status": "pending" } ``` -------------------------------- ### Mass Transfer Response Example Source: https://docs.xrocket.exchange/api/pay/reference/http/mass-transfers-controller-create-mass-transfers Example JSON response showing both successful and failed transfers. ```json { "successTransfers": [ { "transferId": "abc-def", "clientTransferId": "abc-def", "target": "87209764", "targetType": "telegram_user_id", "asset": "TONCOIN", "amount": "1.23", "description": "You are awesome!" } ], "errorTransfers": [ { "target": "87209764", "targetType": "telegram_user_id", "amount": "1.23", "clientTransferId": "abc-def", "description": "Monthly payroll", "reason": { "type": "/api/problems/symbol_not_found", "title": "Symbol not found", "status": 400, "detail": "The requested symbol could not be found", "instance": "/api/problems/instances/ada06f0c-8ca8-457a-9906-4feb8c999169", "kind": "validation" } } ] } ``` -------------------------------- ### Symbols Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-symbols Example JSON response body containing the list of trading symbols. ```json { "symbols": [ { "symbol": "BTC-USDT", "baseAsset": "BTC", "quoteAsset": "USDT", "baseMinSize": "0.1", "quoteMinSize": "0.01", "baseMaxSize": "10000000000", "quoteMaxSize": "99999999", "minPrice": "0.0000001", "maxPrice": "99999999", "baseIncrement": "0.0001", "priceIncrement": "0.01", "enableTrading": true, "openTime": "2024-12-19T10:44:17.347Z", "precisions": [ "0.0001", "0.001", "0.01", "0.1", "1" ], "labels": [ "new" ] } ] } ``` -------------------------------- ### GET /api/v1/app-info Source: https://docs.xrocket.exchange/api/pay/reference/http/app-controller-get-app Retrieves information about the current application. ```APIDOC ## GET https://pay.api.xrocket.exchange/api/v1/app-info ### Description Retrieves information about the current application, including its unique identifier and name. ### Method GET ### Endpoint https://pay.api.xrocket.exchange/api/v1/app-info ### Response #### Success Response (200) - **id** (string) - The unique identifier of the application. - **name** (string) - The name of the current application. #### Response Example { "id": "string", "name": "My App" } #### Error Response (401) - **type** (string) - Error type identifier. - **title** (string) - Error title. - **status** (number) - HTTP status code (401). - **detail** (string) - Detailed error message. - **instance** (string) - Error instance path. - **kind** (string) - Error category. #### Error Response (500) - **type** (string) - Error type identifier. - **title** (string) - Error title. - **status** (number) - HTTP status code (500). - **detail** (string) - Detailed error message. - **instance** (string) - Error instance path. - **kind** (string) - Error category. ``` -------------------------------- ### Successful Response Schema Example Source: https://docs.xrocket.exchange/api/pay/reference/http/cheque-controller-get-cheques Example JSON response body for a successful request returning a list of cheques. ```json { "items": [ { "chequeId": "string", "clientChequeId": "string", "asset": "TONCOIN", "description": "This cheque is the best", "targetType": "telegram_user_id", "target": "123", "links": { "telegramBotLink": "https://t.me/xRocket?start=mc_qwerty123", "telegramMiniAppLink": "https://t.me/xRocket?start=mc_qwerty123", "webLink": "https://t.me/xRocket?start=mc_qwerty123" } } ], "pagination": { "total": 0, "next": "string" } } ``` -------------------------------- ### Successful Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-transfer-controller-get-transfer-by-transfer-id The JSON structure returned upon a successful request. ```json { "asset": "XROCK", "amount": "123.456", "from": "funding", "to": "trading", "clientTransferId": "12345", "transferId": "2355231", "status": "pending", "createdAt": "2024-12-05T12:51:20.917Z", "updatedAt": "2024-12-05T12:51:20.917Z" } ``` -------------------------------- ### Authentication Responses Source: https://docs.xrocket.exchange/api/exchange/websocket Examples of successful and error responses received after an authentication attempt. ```json { "id": "1", "result": { "success": true } } ``` ```json { "id": "1", "error": { "code": -32034, "message": "User Blocked", "data": { "detail": "Invalid authentication" } } } ``` -------------------------------- ### GET Balances Endpoint Source: https://docs.xrocket.exchange/api/pay/reference/http/app-controller-get-app-balances The base URL and path for retrieving application balances. ```http GET ## https://pay.api.xrocket.exchange/api/v1/balances ``` -------------------------------- ### Initialize trading bot configuration and helper Source: https://docs.xrocket.exchange/api/exchange/guides/tutorials/trading-bot-tutorial Set up the environment, API token, and a helper function for authenticated requests. ```python import requests import os import json import time # --- Configuration --- # Get your token from environment variables (RECOMMENDED) # You would set this in your terminal: export XROCKET_TOKEN="" API_TOKEN = os.environ.get("XROCKET_TOKEN", "YOUR_FALLBACK_TOKEN") # Use the Testnet environment for testing https://docs.xrocket.exchange = "https://exchange.api.testnet.xrocket.exchange" # Define the trading pair SYMBOL = 'TON-USDT' # xRocket symbol format: BASE-QUOTE (hyphen-separated) def make_authenticated_request(method, endpoint, data=None): """Helper function to make API requests with Bearer Token auth.""" headers = { 'Accept': 'application/json', 'Authorization': f'Bearer {API_TOKEN}', 'Content-Type': 'application/json' } url = f"{https://docs.xrocket.exchange}{endpoint}" # Send the request try: if method in ['POST', 'PUT']: response = requests.request(method, url, headers=headers, data=json.dumps(data)) else: response = requests.request(method, url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx) return response.json() except requests.exceptions.HTTPError as e: print(f"HTTP error occurred: {e.response.text}") except requests.exceptions.RequestException as e: print(f"An error occurred: {e}") return None ``` -------------------------------- ### Get Withdrawals cURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawals Example cURL command to retrieve withdrawal records with asset filtering. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawals?assets=XROCK' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### GET Assets Endpoint URL Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-asset-controller-get-assets The base endpoint for retrieving the list of assets. ```http GET ## https://exchange.api.xrocket.exchange/api/v1/assets ``` -------------------------------- ### Successful Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-rates-controller-get-rates JSON structure returned upon a successful request, containing rates and 24-hour percentage changes for requested assets. ```json { "BTC": { "rate": "10314902.74486", "rateChangePercent24h": "2.31" }, "ETH": { "rate": "328063.449165", "rateChangePercent24h": "-8.09" }, "USDT": { "rate": "99.50966063", "rateChangePercent24h": "0.52" } } ``` -------------------------------- ### Successful Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-account-controller-get-account-balances JSON structure returned upon a successful request, containing an array of asset balances. ```json { "balances": [ { "asset": "BTC", "balance": "123.29", "available": "99.55", "holds": "23.74" } ] } ``` -------------------------------- ### Subscription Request and Notification Source: https://docs.xrocket.exchange/api/exchange/websocket Example of a subscription request and the corresponding push notification format. ```json { "id": "request_id", "method": "subscribe", "params": { "channel": "ticker", "symbol": "BTC-USDT", "interval": "1day" } } ``` ```json { "method": "subscription", "params": { "channel": "ticker", "symbol": "BTC-USDT", "interval": "1day", "data": { // channel-specific data } } } ``` -------------------------------- ### Place Order CURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-order-controller-place-order Example command to place a limit order using the CURL utility. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/orders' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' \ -d '{ "symbol": "BTC-USDT", "side": "buy", "clientOrderId": "string", "type": "limit", "size": "123.456", "price": "123.456", "timeInForce": "GTC" }' ``` -------------------------------- ### Create Mass Transfers CURL Request Source: https://docs.xrocket.exchange/api/pay/reference/http/mass-transfers-controller-create-mass-transfers Example of how to initiate a mass transfer using the CURL command line tool. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/mass-transfers' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -d '{ "asset": "TONCOIN", "transfers": [ { "target": "87209764", "targetType": "telegram_user_id", "amount": "1.23", "clientTransferId": "abc-def", "description": "Monthly payroll" } ] }' ``` -------------------------------- ### Retrieve Invoices via cURL Source: https://docs.xrocket.exchange/api/pay/reference/http/invoice-controller-get-invoices Example request to fetch invoices using the cURL command-line tool. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/invoices' \ -H 'Accept: application/json' ``` -------------------------------- ### Place a Market Order with Python Source: https://docs.xrocket.exchange/api/exchange/guides/tutorials/trading-bot-tutorial Uses the make_authenticated_request helper to send a POST request to the orders endpoint. Requires the quantity to be passed as a string. ```python def place_market_order(symbol, side, amount): """Function to place a market order.""" order_endpoint = "/api/v1/orders" order_data = { 'symbol': symbol, 'side': side, # 'buy' or 'sell' 'type': 'market', 'size': str(amount), # Quantity must be a string in the payload 'timeInForce': 'IOC' } response = make_authenticated_request("POST", order_endpoint, data=order_data) if response: print("Order placed successfully:") print(json.dumps(response, indent=4)) return response else: print("Failed to place order.") return None # --- Call the functions based on our strategy --- if current_price is not None: if current_price < buy_threshold: # Buy 5 TON on the Testnet place_market_order(SYMBOL, 'buy', 5) elif current_price > sell_threshold: # Sell 5 TON on the Testnet place_market_order(SYMBOL, 'sell', 5) ``` -------------------------------- ### Authorize a request with cURL Source: https://docs.xrocket.exchange/api/exchange/guides/getting-started/account-setup Use this command to verify authentication by checking trading balances. Replace with your actual Bearer token. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/trading/balances' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Estimate Order JSON Request Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-order-estimate-controller-estimate-order A sample JSON payload for estimating a limit order. ```json { "symbol": "BTC-USDT", "side": "buy", "fee": "1.82", "feeAsset": "USDT", "timeInForce": "GTC", "type": "limit", "size": "109.34", "funds": "72.319", "price": "291.87" } ``` -------------------------------- ### Successful Symbol Response Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-symbol Example JSON response containing trading parameters and metadata for a valid symbol. ```json { "symbol": "BTC-USDT", "baseAsset": "BTC", "quoteAsset": "USDT", "baseMinSize": "0.1", "quoteMinSize": "0.01", "baseMaxSize": "10000000000", "quoteMaxSize": "99999999", "minPrice": "0.0000001", "maxPrice": "99999999", "baseIncrement": "0.0001", "priceIncrement": "0.01", "enableTrading": true, "openTime": "2024-12-19T10:44:17.347Z", "precisions": [ "0.0001", "0.001", "0.01", "0.1", "1" ], "labels": [ "new" ] } ``` -------------------------------- ### Get Withdrawal cURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawal Executes a GET request to retrieve withdrawal data using a bearer token for authentication. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawal' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Retrieve Exchange Rates via cURL Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-rates-controller-get-rates Example request to fetch exchange rates for specific assets using cURL. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/rates?assets=BTC%2CETH%2CXROCK' \ -H 'Accept: application/json' ``` -------------------------------- ### GET /api/v1/transfer Source: https://docs.xrocket.exchange/api/pay/reference/http/transfer-controller-get-transfer Retrieves the details of a transfer by its ID. ```APIDOC ## GET /api/v1/transfer ### Description Retrieves the details of a specific transfer. You can query by transferId or clientTransferId. ### Method GET ### Endpoint https://pay.api.xrocket.exchange/api/v1/transfer ### Parameters #### Query Parameters - **transferId** (string) - Optional - The unique ID of the transfer. - **clientTransferId** (string) - Optional - The unique transfer ID in your system. ### Response #### Success Response (200) - **transferId** (string) - Transfer ID - **clientTransferId** (string) - Unique transfer ID in your system - **target** (string) - Target identifier - **targetType** (string) - Target type (user_id, telegram_user_id, telegram_username) - **asset** (string) - Asset of transfer - **amount** (string) - Transfer amount - **description** (string) - Transfer description #### Response Example { "transferId": "abc-def", "clientTransferId": "abc-def", "target": "87209764", "targetType": "telegram_user_id", "asset": "TONCOIN", "amount": "1.23", "description": "You are awesome!" } ``` -------------------------------- ### Implement trading strategy logic Source: https://docs.xrocket.exchange/api/exchange/guides/tutorials/trading-bot-tutorial Define basic price thresholds to determine whether to trigger a buy or sell action. ```python # Simple price thresholds for our strategy buy_threshold = 2.00 # For Testnet TON sell_threshold = 2.50 # For Testnet TON if current_price is not None: if current_price < buy_threshold: print(f"Price is low ({current_price}), considering a BUY order.") # We would place an order here elif current_price > sell_threshold: print(f"Price is high ({current_price}), considering a SELL order.") # We would place an order here else: print("Price is within our comfort zone. No action.") ``` -------------------------------- ### Successful Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-account-controller-get-trade-fees A successful response returns an array of fee objects containing the symbol and its associated taker and maker rates. ```json { "fees": [ { "symbol": "BTC-USDT", "standard": { "taker": "0.01", "maker": "0.01" } } ] } ``` -------------------------------- ### GET /api/v1/accounts/transfer Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-transfer-controller-get-transfer-by-transfer-id Retrieves the details of a specific exchange transfer. ```APIDOC ## GET /api/v1/accounts/transfer ### Description Retrieves the details of an exchange transfer. Users can specify the transfer using either the system-generated transferId or a client-provided clientTransferId. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/accounts/transfer ### Parameters #### Query Parameters - **transferId** (string) - Optional - The unique identifier of the transfer. - **clientTransferId** (string) - Optional - The client-provided identifier of the transfer. ### Request Example ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/transfer?transferId=example_id' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` ``` -------------------------------- ### GET /api/v1/trades Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-trades Retrieves trade data for a specified symbol. ```APIDOC ## GET /api/v1/trades ### Description Retrieves a list of trades for a given market symbol. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/trades ### Parameters #### Query Parameters - **symbol** (string) - Required - The market symbol to retrieve trades for. ``` -------------------------------- ### GET /api/v1/trade-fees Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-account-controller-get-trade-fees Retrieves the trade fees for the specified symbols. ```APIDOC ## GET /api/v1/trade-fees ### Description Retrieves trade fee information for the provided list of symbols. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/trade-fees ### Parameters #### Query Parameters - **symbols** (string) - Optional - A comma-separated list of symbols to retrieve fees for (e.g., BTC-USDT,XROCK-USDT). ``` -------------------------------- ### GET https://pay.api.xrocket.exchange/api/v1/withdrawal Source: https://docs.xrocket.exchange/api/pay/reference/http/withdrawal-controller-get-withdrawal Retrieves details for a specific withdrawal request. ```APIDOC ## GET https://pay.api.xrocket.exchange/api/v1/withdrawal ### Description Retrieves the details of an application withdrawal using either the system withdrawal ID or the client-provided withdrawal ID. ### Method GET ### Endpoint https://pay.api.xrocket.exchange/api/v1/withdrawal ### Parameters #### Query Parameters - **withdrawalId** (string) - Optional - Withdrawal ID - **clientWithdrawalId** (string) - Optional - Unique withdrawal ID in your system to prevent double spends ### Response #### Success Response (200) - **withdrawalId** (string) - Unique withdrawal ID in your system - **network** (string) - Network code (TON, BSC, ETH, BTC, TRX, SOL) - **address** (string) - Withdrawal address - **asset** (string) - Asset code - **amount** (string) - Withdrawal amount - **status** (string) - Withdrawal status (CREATED, COMPLETED, FAIL) - **comment** (string) - Withdrawal comment - **txHash** (string) - Withdrawal TX hash - **txLink** (string) - Withdrawal TX link #### Response Example { "withdrawalId": "abc-def", "network": "TON", "address": "EQB1cmpxb3R-YLA3HLDV01Rx6OHpMQA_7MOglhqL2CwJx_dz", "asset": "TONCOIN", "amount": "1.23", "status": "COMPLETED", "comment": "You are awesome!", "txHash": "string", "txLink": "string" } ``` -------------------------------- ### GET /api/v1/accounts/funding/withdrawal Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawal Retrieves the status and details of a specific withdrawal request. ```APIDOC ## GET /api/v1/accounts/funding/withdrawal ### Description Retrieves details for a specific withdrawal request using either the system withdrawal ID or the client-provided withdrawal ID. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawal ### Parameters #### Query Parameters - **withdrawalId** (string) - Optional - The unique identifier for the withdrawal in the system. - **clientWithdrawalId** (string) - Optional - The unique identifier provided by the client for the withdrawal. ### Request Example curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawal' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### GET https://pay.api.xrocket.exchange/api/v1/balances Source: https://docs.xrocket.exchange/api/pay/reference/http/app-controller-get-app-balances Retrieves the list of balances for the authenticated application. ```APIDOC ## GET https://pay.api.xrocket.exchange/api/v1/balances ### Description Retrieves the current balances for your application, including asset names and their respective available and held amounts. ### Method GET ### Endpoint https://pay.api.xrocket.exchange/api/v1/balances ### Response #### Success Response (200) - **balances** (array) - List of balance objects - **asset** (string) - Balance asset - **balance** (string) - Total asset balance - **available** (string) - Available balance - **holds** (string) - Holds balance #### Response Example { "balances": [ { "asset": "XROCK", "balance": "123.29", "available": "99.55", "holds": "23.74" } ] } ``` -------------------------------- ### Retrieve Invoice via cURL Source: https://docs.xrocket.exchange/api/pay/reference/http/invoice-controller-get-invoice Example request to retrieve an invoice using the cURL command-line tool. ```bash curl -L 'https://pay.api.xrocket.exchange/api/v1/invoice' \ -H 'Accept: application/json' ``` -------------------------------- ### GET /api/v1/accounts/funding/withdrawal-quotas Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawal-quotas Retrieves the withdrawal quotas for a specific asset and network. ```APIDOC ## GET /api/v1/accounts/funding/withdrawal-quotas ### Description Retrieves the withdrawal quotas for a specific asset on a given network. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawal-quotas ### Parameters #### Query Parameters - **network** (string) - Required - The network to query (e.g., TON, BSC, ETH, BTC, TRX, SOL) - **asset** (string) - Required - The asset to query ### Request Example ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawal-quotas?network=TON&asset=USDT' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` ``` -------------------------------- ### Endpoint URL Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawals The base URL for the GET request to retrieve withdrawals. ```http GET ## https://exchange.api.xrocket.exchange/api/v1/accounts/funding/withdrawals ``` -------------------------------- ### Candle Data Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-candles A sample JSON response structure for a successful candle data request. ```json { "candles": [ [ "2024-12-23T12:50:15.570Z", "0.058", "0.049", "0.058", "0.049", "0.018" ] ] } ``` -------------------------------- ### GET /api/v1/symbols/:symbol Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-symbol Retrieves information for a specific trading symbol. ```APIDOC ## GET /api/v1/symbols/:symbol ### Description Retrieves details for a specific trading symbol from the exchange. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/symbols/:symbol ### Parameters #### Path Parameters - **symbol** (string) - Required - The identifier of the symbol to retrieve. ``` -------------------------------- ### GET https://exchange.api.xrocket.exchange/api/v1/trades Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-trades Retrieves the last trades for a specified symbol. ```APIDOC ## GET https://exchange.api.xrocket.exchange/api/v1/trades ### Description Returns the last trades for a given symbol. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/trades ### Parameters #### Query Parameters - **symbol** (string) - Required - Symbol ### Response #### Success Response (200) - **trades** (object[]) - List of trades - **tradeId** (string) - Trade ID - **price** (string) - Filled price - **side** (string) - Side of an order (buy, sell) - **time** (string) - Transaction time - **size** (string) - Filled amount #### Response Example { "trades": [ { "tradeId": "3262786978", "price": "0.07", "side": "buy", "time": "2024-12-19T10:44:17.347Z", "size": "0.004" } ] } ``` -------------------------------- ### Asset and Currency Not Found Error Responses Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-rates-controller-get-rates JSON response structures returned when an asset or currency cannot be located. ```json { "type": "/api/problems/asset_not_found", "title": "Asset not found", "status": 404, "detail": "Asset not found", "instance": "/api/problems/instances/ada06f0c-8ca8-457a-9906-4feb8c999169", "kind": "not_found" } ``` ```json { "type": "/api/problems/currency_not_found", "title": "Currency not found", "status": 404, "detail": "Currency not found", "instance": "/api/problems/instances/ada06f0c-8ca8-457a-9906-4feb8c999169", "kind": "not_found" } ``` -------------------------------- ### GET /api/v1/orders/active Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-order-controller-get-active-orders Retrieves the list of active orders for the authenticated user. ```APIDOC ## GET /api/v1/orders/active ### Description Retrieves the list of active orders for the authenticated user. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/orders/active ### Authorization - **Type**: Bearer Token (JWT) ``` -------------------------------- ### Withdrawals Response Example Source: https://docs.xrocket.exchange/api/exchange/reference/http/wallet-funding-controller-get-withdrawals A successful response containing a list of withdrawal objects and pagination metadata. ```json { "withdrawals": [ { "withdrawalId": "1234324", "clientWithdrawalId": "abc-def", "network": "TON", "address": "EQB1cmpxb3R-YLA3HLDV01Rx6OHpMQA_7MOglhqL2CwJx_dz", "asset": "BTC", "amount": "12.00034", "comment": "1919537769", "status": "pending", "txHash": "ba8218ed019c8dab8f6e0ac7dc34bcc39938edee5d1f97f", "txLink": "https://tonviewer.com/transaction/ba8218ed019c8dab8f6e0ac7dc34bcc39938edee5d1f97f", "fee": "0.003", "feeAsset": "TONCOIN", "createdAt": "2024-12-05T12:51:20.917Z", "updatedAt": "2024-12-05T12:51:20.917Z" } ], "currentPage": 2, "pageSize": 50, "totalNum": 26, "totalPage": 2 } ``` -------------------------------- ### GET /api/v1/orderbook Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-orderbook Retrieves the current orderbook for a specified trading symbol. ```APIDOC ## GET /api/v1/orderbook ### Description Retrieves the orderbook data for a given trading symbol. Supports optional depth and precision parameters. ### Method GET ### Endpoint https://exchange.api.xrocket.exchange/api/v1/orderbook ### Parameters #### Query Parameters - **symbol** (string) - Required - The trading symbol to retrieve the orderbook for. - **depth** (number) - Optional - The depth of the orderbook (e.g., 5, 10, 20, 50, 100, 200, 500). - **precision** (number) - Optional - The precision level for the orderbook data. ### Request Example curl -L 'https://exchange.api.xrocket.exchange/api/v1/orderbook?symbol=BTCUSDT' \ -H 'Accept: application/json' ``` -------------------------------- ### Retrieve Ticker Data via cURL Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-market-data-controller-get-ticker Example request to fetch ticker data for specific symbols using the cURL command-line tool. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/ticker/:tickerType?symbols=BTC-USDT%2CXROCK-USDT' \ -H 'Accept: application/json' ``` -------------------------------- ### Delete Cheque Request Source: https://docs.xrocket.exchange/api/pay/reference/http/cheque-controller-delete-cheque Example of a cURL command to perform the DELETE request. ```bash curl -L -X DELETE 'https://pay.api.xrocket.exchange/api/v1/cheques' ``` -------------------------------- ### Retrieve Order cURL Request Source: https://docs.xrocket.exchange/api/exchange/reference/http/exchange-order-controller-get-order Example cURL command to fetch order details using a Bearer token. ```bash curl -L 'https://exchange.api.xrocket.exchange/api/v1/order' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### GET /api/v1/withdrawal Source: https://docs.xrocket.exchange/api/pay/reference/http/withdrawal-controller-get-withdrawal Retrieves withdrawal information based on the provided query parameters. ```APIDOC ## GET /api/v1/withdrawal ### Description Retrieves the details of a withdrawal. You can specify the withdrawal using either the system-generated withdrawalId or the clientWithdrawalId. ### Method GET ### Endpoint https://pay.api.xrocket.exchange/api/v1/withdrawal ### Parameters #### Query Parameters - **withdrawalId** (string) - Optional - The unique identifier for the withdrawal. - **clientWithdrawalId** (string) - Optional - The client-provided identifier for the withdrawal. ```