### Example Request to Query Kline Data Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/kline/index.html This example demonstrates how to make a GET request to the `/v1/spot/kline` endpoint using curl. It includes a sample payload, though the actual parameters are typically passed as query parameters in the URL for GET requests. ```bash curl -d /v1/spot/kline ``` -------------------------------- ### Code Examples Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/index.html Provides links to example code implementations for interacting with the Websea Open API. ```APIDOC ## Code Examples ### Description This section provides links to code examples demonstrating how to integrate with the Websea Open API. ### Examples * [Python 2 Examples](demo/python2/) * [Python 3 Examples](demo/python3/) ``` -------------------------------- ### Subscribe to Kline Data (JSON Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-market/ws-kline/index.html This example demonstrates how to structure a subscription message to receive real-time kline data for a specific trading pair. It specifies the operation, channel, and symbol. ```json { "op": "sub", "channel": "kline1min", "symbol": "BTC-USDT" } ``` -------------------------------- ### Query Spot Market Trades (Bash Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/trade/index.html Example of how to query spot market trades using a curl command in Bash. This demonstrates the basic structure for making a GET request to the `/v1/spot/trade` endpoint. ```bash curl -d /v1/spot/trade ``` -------------------------------- ### Get Open Futures Orders (JSON Response Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-trade/order/index.html This snippet shows an example JSON response for the /v1/futures/orders/open endpoint. It includes details for a single open order, such as its ID, symbol, price, amount, and status. This response format is consistent across successful requests to this endpoint. ```json [ { "order_id": "BG5000181583375122413SZXEIX", "ctime": 1576746253, "symbol": "ETH-USDT", "price": "1", "price_avg": "0", "lever_rate": 10, "amount": "10", "deal_amount": "0", "type": "buy-limit", "status": 1, "contract_type": "open", "trigger_price": "1", "stop_profit_price": "15", "stop_loss_price": "10" } ] ``` -------------------------------- ### Query Historical Orders (GET Request Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-trade/order-history/index.html This snippet demonstrates how to make a GET request to the /v1/futures/orders/history endpoint to retrieve historical order data. It includes common query parameters for filtering and pagination. No specific programming language is dictated, as this is a general API interaction. ```bash GET /v1/futures/orders/history?symbol=EOS-USDT&from=122&direct=prev&limit=20&is_full=1 HTTP/1.1 Host: api.websea.com Content-Type: application/json ``` -------------------------------- ### Query Spot Trading Fee Rates (Bash Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/rate/index.html Example of how to query spot trading fee rates using a curl command in Bash. This demonstrates the request to the `/v1/spot/order/rate` endpoint. ```bash curl -d /v1/spot/order/rate ``` -------------------------------- ### Subscribe Kline WebSocket - Python Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/ws-kline/index.html This Python code snippet demonstrates how to establish a WebSocket connection and subscribe to Kline data. It includes setting up the connection, sending subscription messages, and handling incoming data. Ensure you have the 'websocket-client' library installed. ```python import websocket import json ws_url = "wss://ws.websea.com/ws" def on_message(ws, message): print(message) def on_error(ws, error): print(error) def on_close(ws, close_status_code, close_msg): print("### closed ###") def on_open(ws): print("Opened connection") # Subscribe to Kline data for BTC/USDT, 1-minute interval subscribe_message = { "event": "subscribe", "params": { "channel": "market.btcusdt.kline_1min" } } ws.send(json.dumps(subscribe_message)) if __name__ == "__main__": websocket.enableTrace(True) ws = websocket.WebSocketApp(ws_url, on_open=on_open, on_message=on_message, on_error=on_error, on_close=on_close) ws.run_forever() ``` -------------------------------- ### Real-time Kline Data Push Example (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-market/ws-kline/index.html This is an example of the data structure received when subscribing to kline data. It includes details like channel, symbol, kline ID, open, close, high, low, amount, count, and volume. ```json { "channel": "kline1min", "symbol": "BTC-USDT", "id": 1499184000, "amount": "37593", "count": 1, "open": "1935.2000", "close": "1879.0000", "low": "1856.0000", "high": "1940.0000", "vol": "71031537.978665" } ``` -------------------------------- ### Get Spot Trading Pair Precision (JSON Response Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/precision/index.html This snippet demonstrates the expected JSON response structure for the `/v1/spot/symbol_precision` endpoint when requesting trading pair precision and limits. It includes status codes, messages, and detailed precision/limit data for a specific trading pair like BTC-USDT. ```json { "errno": 0, "errmsg": "success", "result": { "BTC-USDT": { "amount": "3", "minQuantity": "0.01", "maxQuantity": "100000000", "price": "2", "minPrice": "0.000001", "maxPrice": "100000" } } } ``` -------------------------------- ### Query 24-Hour Ticker List - cURL Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/24kline-list/index.html Example of how to query the 24-hour ticker list using cURL. This demonstrates making a GET request to the API endpoint, optionally including the 'symbol' parameter to filter trading pairs. The response will be in JSON format. ```bash curl -X GET "https://api.websea.com/v1/spot/24kline_list?symbol=BTC-USDT,ETH-USDT" ``` -------------------------------- ### Spot Depth Response Example (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/orderbook/index.html This is a successful response example in JSON format for the /v1/spot/depth API endpoint. It includes status codes, messages, and detailed 'asks' and 'bids' arrays, each containing price and amount for trading orders. ```json { "errno": 0, "errmsg": "success", "result": { "symbol": "EOS-USDT", "ts": 1499223904680, "bids": [ [7964, 0.0678], [7963, 0.9162], [7961, 0.1] ], "asks": [ [7979, 0.0736], [7980, 1.0292], [7981, 5.5652] ] } } ``` -------------------------------- ### Create Futures Order (JSON Request Example) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-trade/create/index.html This snippet demonstrates how to construct a JSON request to create a futures order. It includes essential parameters like contract type, order type, leverage rate, amount, and symbol. The example shows parameters for opening a buy limit order. ```json { "contract_type": "open", "type": "buy-limit", "lever_rate": 10, "price": 1, "amount": 100, "symbol": "ETH-USDT" } ``` -------------------------------- ### Python 3 Example for Order Fills Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/order-trade/index.html Shows how to query order fills using Python 3. This example would involve using libraries like `requests` for HTTP communication and handling the API response. ```Python import requests import json def query_order_fills(api_key, secret_key, symbol, order_id): base_url = "https://api.websea.com" endpoint = "/api/v1/order/fills" params = { 'symbol': symbol, 'order_id': order_id, 'limit': 100, 'page': 1 } # Signature generation would be needed here headers = { 'X-MBX-APIKEY': api_key } # Example of making the request (actual signature implementation needed) # response = requests.get(base_url + endpoint, params=params, headers=headers) # response.raise_for_status() # Raise an exception for bad status codes # return response.json() print(f"Querying order fills for symbol: {symbol}, order_id: {order_id}") pass # Example usage: # fills = query_order_fills('YOUR_API_KEY', 'YOUR_SECRET_KEY', 'BTC-USDT', '123456789') ``` -------------------------------- ### Signature Generation - Python Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/about/auth/index.html Example code in Python demonstrating how to generate the request signature. ```APIDOC ## Signature Generation - Python Example ### Description This Python function generates a signature required for API requests. ### Method N/A (Helper function) ### Endpoint N/A (Helper function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Function Parameters - **Nonce** (string) - Required - The nonce value for the request. - **data** (dict) - Optional - A dictionary containing request parameters (POST/GET data). ### Request Example ```python import hashlib # Assume TOKEN and SECRET are defined globally or passed as arguments # TOKEN = "your_token" # SECRET = "your_secret_key" def sign(Nonce, data=dict()): tmp = list() tmp.append(TOKEN) tmp.append(SECRET) tmp.append(Nonce) for d, x in data.items(): tmp.append(str(d) + "=" + str(x)) return hashlib.sha1(''.join(sorted(tmp))).hexdigest() # Example usage: # api_nonce = "1534927978_ab43c" # post_data = {"symbol": "BTCUSDT", "amount": 100} # signature = sign(api_nonce, post_data) # print(signature) ``` ### Response #### Success Response (200) N/A (This is a client-side function) #### Response Example N/A ``` -------------------------------- ### Signature Generation - PHP Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/about/auth/index.html Example code in PHP demonstrating how to generate the request signature. ```APIDOC ## Signature Generation - PHP Example ### Description This PHP function generates a signature required for API requests. ### Method N/A (Helper function) ### Endpoint N/A (Helper function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Function Parameters - **nonce** (string) - Required - The nonce value for the request. ### Request Example ```php $v){ $tmpArr[] = $k . "=" . $v; } // Add POST parameters foreach($_POST as $k => $v){ $tmpArr[] = $k . "=" . $v; } sort($tmpArr, SORT_STRING); $tmpStr = implode($tmpArr); $signature = sha1($tmpStr); return $signature; } // Example usage: // $_GET = ["symbol" => "BTCUSDT"]; // $_POST = ["amount" => 100]; // $api_nonce = "1534927978_ab43c"; // $signature = signature($api_nonce); // echo $signature; ?> ``` ### Response #### Success Response (200) N/A (This is a client-side function) #### Response Example N/A ``` -------------------------------- ### API Request Headers Example (Python) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/about/auth/index.html Example demonstrating how to set the Nonce, Token, and Signature headers for an API request using Python's curl_setopt. These headers are mandatory for client requests to trading APIs. ```python $header[] = 'Nonce: 1534927978_ab43c'; $header[] = 'Token: 57ba172a6be125cca2f449826f9980ca'; $header[] = 'Signature: v490hupi0s0bckcp6ivb69p921'; curl_setopt($ch, CURLOPT_HTTPHEADER, $header); ``` -------------------------------- ### Real-time Trade Data Push Example (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-market/ws-trade/index.html An example of the JSON payload received when a trade occurs. This push message contains details about a single trade, including the channel, symbol, trade ID, quantity, price, direction (buy/sell), and timestamp. ```json { "channel": "trade", "symbol": "BTC-USDT", "id": 17592256642623, "amount": "0.04", "deal_amount": "0.04", "price": 1997, "direction": "buy", "ts": 1502448920106 } ``` -------------------------------- ### Python 2 Example for Order Fills Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/order-trade/index.html Demonstrates how to use Python 2 to query order fills from the Websea Open Interface. This example would typically involve making HTTP requests and handling JSON responses. ```Python import urllib import httplib import json def query_order_fills(api_key, secret_key, symbol, order_id): # Implementation for signing the request and making the HTTP call # This is a placeholder and requires actual implementation details print "Querying order fills for symbol: %s, order_id: %s" % (symbol, order_id) # return json.loads(response.read()) pass # Example usage: # query_order_fills('YOUR_API_KEY', 'YOUR_SECRET_KEY', 'BTC-USDT', '123456789') ``` -------------------------------- ### Signature Generation Examples Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/about/auth/index.html Provides code examples for generating API signatures in various programming languages, essential for making authenticated calls to the Websea Open Interface. ```APIDOC ## Code Examples for Generating Signature ### Description This section offers practical code examples to help developers generate the necessary signatures for API requests using different programming languages. ### Python Example ```python # Placeholder for Python signature generation code print 'Python signature example' ``` ### PHP Example ```php ``` ### Java Example ```java // Placeholder for Java signature generation code System.out.println("Java signature example"); ``` ``` -------------------------------- ### Response Example for Recent Trades Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-market/trade/index.html A JSON formatted example of the response received when querying recent trades. This illustrates the structure of the returned data, including status codes, messages, and trade details. ```json { "errno": 0, "errmsg": "success", "result": { "symbol": "EOS-USDT", "ts": "1499223904680", "data": [ { "id": 17592256642623, "amount": "0.04", "price": "1997", "direction": "buy", "ts": 1502448920106 }, { "id": 17592256642622, "amount": "0.04", "price": "1997", "direction": "sell", "ts": 1502448920105 } ] } } ``` -------------------------------- ### Spot Order Creation Response Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/create/index.html This is an example of a successful JSON response when creating a spot trading order. It includes a status code ('errno'), a status message ('errmsg'), and a 'result' object containing the unique order serial number ('order_sn') and order ID ('order_id'). ```json { "errno": 0, "errmsg": "success", "result": { "order_sn": "BL786401542840282676", "order_id": 1231 } } ``` -------------------------------- ### Response Example for Spot Trading Fee Rates (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/rate/index.html A JSON example of the response received when querying spot trading fee rates. It includes status codes, messages, and the fee rates for makers and takers. ```json { "errno": 0, "errmsg": "success", "result": { "maker_fee": 0.00025, "taker_fee": 0.00026 } } ``` -------------------------------- ### 24-Hour Futures Product Ticker Response Example (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-market/24hr/index.html This is an example of the JSON response received when querying the 24-hour futures product ticker. It includes a status code, message, and a detailed 'result' array containing information for each trading pair, such as symbol, prices, volumes, and funding rates. ```json { "errno": 0, "errmsg": "success", "result": [ { "symbol": "BTC-USDT", "base_ccy": "BTC", "quote_ccy": "USDT", "last_price": "38987", "base_vol": "100", "quote_vol": "10000", "bid": "37990", "ask": "38000", "high": "40000", "low": "37000", "product_type": "futures", "open_interest": "19999", "open_interest_usd": "19999", "index_price": "38000", "funding_rate": "23", "next_funding_rate_times": 1701417600 } ] } ``` -------------------------------- ### Python 3 Example for Trading Fee Rate Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/rate/index.html This Python 3 code snippet demonstrates how to fetch trading fee rates from the Websea Open Interface. It utilizes the `requests` library to make a GET request to the API endpoint. Ensure you have the `requests` library installed (`pip install requests`). ```python import requests api_url = "https://api.websea.com/v1/trading/fee-rate" try: response = requests.get(api_url) response.raise_for_status() # Raise an exception for bad status codes data = response.json() print(data) except requests.exceptions.RequestException as e: print(f"Error fetching trading fee rates: {e}") ``` -------------------------------- ### Python 3 Code Example for Trading Pair List Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/symbol-list/index.html This Python 3 code snippet demonstrates how to fetch the trading pair list from the Websea Open Interface API. It utilizes the `requests` library to make an HTTP GET request and handles the JSON response. Ensure you have the `requests` library installed (`pip install requests`). ```python import requests url = "https://api.websea.com/v1/common/symbols" try: response = requests.get(url) response.raise_for_status() # Raise an exception for bad status codes data = response.json() print(data) except requests.exceptions.RequestException as e: print(f"Error fetching trading pairs: {e}") ``` -------------------------------- ### Place Spot Order using Curl Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/create/index.html This snippet demonstrates how to place a spot trading order using the `curl` command-line tool. It sends a POST request to the `/v1/spot/order/create` endpoint with form data representing the order details. Ensure all required parameters such as 'symbol', 'type', and 'amount' are correctly provided. ```bash curl -d "symbol=BTC-USDT&type=buy-limit&amount=1.343432&price=32.3232145" http://api.webseaex.com/v1/spot/order/create ``` -------------------------------- ### Query Current Plan Orders Response Example (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-trade/plan/index.html This snippet shows an example JSON response when successfully querying current plan orders. It includes order details such as order ID, creation time, trading pair, price, leverage, amount, order type, and trigger/stop-loss prices. The 'result' field contains an array of order objects. ```json [ { "order_id": "BG5000181583375122413SZXEIX", "ctime": 1576746253, "symbol": "ETH-USDT", "price": "1", "lever_rate": 10, "amount": "10", "type": "buy-limit", "trigger_status": 0, "trigger_sign": "0", "trigger_price": "10", "stop_profit_price": "15", "stop_loss_price": "10" } ] ``` -------------------------------- ### Python SDK Integration - Trading Example Source: https://context7.com/webseaex/webseaex.github.io/llms.txt Demonstrates how to use the Python SDK to make authenticated API requests for placing orders and querying wallet balances. ```APIDOC ## Python SDK Integration ### Complete Trading Example This example shows how to set up and use a Python script to interact with the Websea API, including authentication, order placement, and wallet balance retrieval. ### Request Example ```python #!/usr/bin/env python3 import sys import json import time import hashlib import requests import random import string TOKEN = "57ba172a6be125cca2f449826f9980ca" SECRET = "hkyavn13ybc1qunp4rpb" HOST = "https://api.websea.com" def generate_nonce(): """Generate nonce in format: timestamp_randomString""" timestamp = str(int(time.time())) random_str = ''.join(random.choices(string.ascii_lowercase + string.digits, k=5)) return f"{timestamp}_{random_str}" def sign(nonce, data=dict()): """Generate SHA1 signature from token, secret, nonce, and parameters""" tmp = list() tmp.append(TOKEN) tmp.append(SECRET) tmp.append(nonce) for key, value in data.items(): tmp.append(str(key) + "=" + str(value)) return hashlib.sha1(''.join(sorted(tmp)).encode()).hexdigest() def make_request(endpoint, method='GET', params=None): """Make authenticated API request""" if params is None: params = {} nonce = generate_nonce() signature = sign(nonce, params) headers = { 'Nonce': nonce, 'Token': TOKEN, 'Signature': signature, 'user-agent': 'Mozilla/5.0 (compatible; WebseaBot/1.0)' } url = f"{HOST}{endpoint}" try: if method == 'GET': response = requests.get(url, params=params, headers=headers, timeout=30) elif method == 'POST': response = requests.post(url, data=params, headers=headers, timeout=30) return response.json() except requests.RequestException as e: return {"errno": -1, "errmsg": f"Request failed: {str(e)}"} # Example 1: Place a limit buy order order_params = { "symbol": "BTC-USDT", "type": "buy-limit", "amount": "0.1", "price": "50000" } result = make_request("/v1/spot/order/create", method='POST', params=order_params) print("Order created:", json.dumps(result, indent=2)) # Example 2: Query wallet balances wallet_result = make_request("/v1/wallet/list", method='GET') print("Wallet balances:", json.dumps(wallet_result, indent=2)) ``` ### Description This Python script provides utility functions to generate nonces, create signatures, and make authenticated requests to the Websea API. It includes examples for placing a spot order and querying wallet balances. ``` -------------------------------- ### Python Example for Recent Trades Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/trade/index.html This Python code snippet provides an example of how to retrieve recent trade data from the Websea Open Interface. It utilizes the `requests` library to make an HTTP GET request to the API endpoint for trades, specifying the trading symbol. ```python import requests api_url = "https://api.websea.com/v1/trades" params = { "symbol": "ETHBTC" } try: response = requests.get(api_url, params=params) response.raise_for_status() # Raise an exception for bad status codes trades = response.json() print(trades) except requests.exceptions.RequestException as e: print(f"Error fetching trades: {e}") ``` -------------------------------- ### POST /v1/spot/order/create Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/demo/python2/index.html Places a new spot order on the exchange. ```APIDOC ## POST /v1/spot/order/create ### Description Submits a new order to buy or sell a specified amount of a trading pair at a given price. ### Method POST ### Endpoint `/v1/spot/order/create` ### Parameters #### Request Body - **symbol** (string) - Required - The trading pair (e.g., "BTC-USDT"). - **type** (string) - Required - The order type (e.g., "buy-limit", "sell-limit", "buy-market", "sell-market"). - **amount** (number) - Required - The quantity of the asset to trade. - **price** (number) - Required for limit orders - The price at which to place the order. ### Request Example ```json { "url": "HOST + '/v1/spot/order/create'", "method": "POST", "data": { "symbol": "BTC-USDT", "type": "buy-limit", "amount": 1.343432, "price": 500.323214 } } ``` ### Response #### Success Response (200) - **content** (string) - A JSON string containing the details of the created order. ``` -------------------------------- ### Fetch 24h Ticker Data - Python 2 Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/24kline/index.html This Python 2 code snippet demonstrates how to fetch 24-hour ticker data from the Websea Open Interface. It utilizes the 'requests' library to make a GET request to the appropriate API endpoint. The response, typically in JSON format, contains trading volume, price changes, and other relevant market data for the last 24 hours. ```python import requests def get_24h_ticker(): url = "https://api.websea.com/api/v1/ticker/24hr" try: response = requests.get(url) response.raise_for_status() # Raise an exception for bad status codes data = response.json() return data except requests.exceptions.RequestException as e: print(f"Error fetching data: {e}") return None if __name__ == "__main__": ticker_data = get_24h_ticker() if ticker_data: print(ticker_data) ``` -------------------------------- ### Example Wallet Withdrawal Request (Bash) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/wallet/withdraw/index.html This code snippet demonstrates how to initiate a wallet withdrawal using a cURL command. It requires the endpoint URL and will send withdrawal details via POST. ```bash curl -d /v1/wallet/withdraw ``` -------------------------------- ### Python Delegate Order Placement on Webseaex API Source: https://github.com/webseaex/webseaex.github.io/blob/main/openapi_en.html This example demonstrates how to place a delegate order (e.g., a limit buy order) on the Webseaex platform. It constructs the request arguments, specifying the URL, method (POST), and detailed data parameters such as symbol, order type, amount, and price. The response is processed, printing the decoded content upon success or the error details otherwise. ```python # Delegate Order Placing args = dict() args['url'] = HOST + '/openApi/entrust/add' args['method'] = 'POST' args['data'] = dict() args['data']['symbol'] = "BTC-USDT" args['data']['type'] = "buy-limit" args['data']['amount'] = 1.343432 args['data']['price'] = 500.323214 result = request(args) if result['code']==200: print(result['content'].decode("utf8")) else: print(result) ``` -------------------------------- ### Example API Interactions (Python) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/demo/python2/index.html This main execution block demonstrates practical usage of the Websea API functions. It includes examples for querying Kline data for BTC-USDT, retrieving account assets for BTC, and placing a buy limit order for BTC-USDT. Error handling is included to print results or error messages. ```python if __name__ == '__main__': # Query Kline data args = dict() args['url'] = HOST + '/v1/spot/kline' args['method'] = 'GET' args['data'] = dict() args['data']['symbol'] = "BTC-USDT" args['data']['period'] = "1min" args['data']['size'] = 2000 result = request(args) if result['code'] == 200: print result['content'] else: print result print '-' * 100 # Query account assets args = dict() args['url'] = HOST + '/v1/wallet/list' args['method'] = 'GET' args['data'] = dict() args['data']['currency'] = "BTC" result = request(args) if result['code'] == 200: print result['content'] else: print result print '-' * 100 # Place order args = dict() args['url'] = HOST + '/v1/spot/order/create' args['method'] = 'POST' args['data'] = dict() args['data']['symbol'] = "BTC-USDT" args['data']['type'] = "buy-limit" args['data']['amount'] = 1.343432 args['data']['price'] = 500.323214 result = request(args) if result['code'] == 200: print result['content'] else: print result ``` -------------------------------- ### Close All Futures Positions Response Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-trade/close/index.html An example JSON response from the /v1/futures/close_all endpoint, indicating the success and failure counts of the position closure operation. ```json { "errno": 0, "errmsg": "success", "result": { "failed": 0, "success": 1 } } ``` -------------------------------- ### GET /v1/futures/index_price Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-market/index-price/index.html Fetches the index price for futures trading pairs. You can specify a 'symbol' to get data for a particular pair, or omit it to retrieve data for all symbols. ```APIDOC ## GET /v1/futures/index_price ### Description Retrieves the index price for futures trading pairs. If a `symbol` is provided, data for that specific trading pair is returned. If `symbol` is omitted, data for all trading pairs is returned. ### Method GET ### Endpoint /v1/futures/index_price ### Query Parameters - **symbol** (string) - Optional - Trading pair. If omitted, data for all trading pairs will be returned. ### Request Example ```bash curl -G /v1/futures/index_price -d "symbol=BTC-USDT" ``` ### Response #### Success Response (200) - **errno** (int) - Status code. - **errmsg** (string) - Status message. - **result** (array) - Result list containing index price data. - **symbol** (string) - Trading pair. - **price** (string) - Index price. - **ts** (long) - Timestamp. #### Response Example ```json { "errno": 0, "errmsg": "success", "result": [ { "symbol": "BTC-USDT", "price": "7865.23", "ts": 1587925500000 } ] } ``` ``` -------------------------------- ### Close All Futures Positions Request Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/futures-trade/close/index.html An example of a POST request to the /v1/futures/close_all endpoint to close all futures positions. It includes optional parameters for symbol and margin mode. ```bash curl -X POST https://api.webseaex.com/v1/futures/close_all \ -H "Content-Type: application/json" \ -d '{ "symbol": "EOS-USDT", "is_full": 1 }' ``` -------------------------------- ### Query Spot Order Details - Bash Example Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/order-detail/index.html This snippet demonstrates how to query the details of a spot trading order using a cURL command in Bash. It requires the order serial number as a parameter. ```bash curl -d /v1/spot/order/detail ``` -------------------------------- ### Spot Order Channel Push Example (JSON) Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-trade/ws-order/index.html This JSON example illustrates the structure of a push message received from the 'order' channel for spot trading on WebseaEx. It contains details about a trade event, including symbol, order ID, side, order type, amount, price, and event status. ```json { "channel": "order", "ts": 1710208544, "order": { "symbol": "ETH-USDT", "side": "BUY", "amount": "", "last_price": "", "last_fee": "", "last_amount": "", "price": "3800", "event": "NEW", "order_id": "BL2217102085443303CZQ2P", "order_type": "LIMIT", "status": "NEW", "ts": "" } } ``` -------------------------------- ### GET /api/v1/ticker Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/spot-market/24kline/index.html Fetches the 24-hour ticker information for all available trading pairs. This endpoint is useful for getting a quick overview of market activity. ```APIDOC ## GET /api/v1/ticker ### Description Retrieves the 24-hour ticker information for all available trading pairs. ### Method GET ### Endpoint /api/v1/ticker ### Query Parameters #### Parameters - **symbol** (string) - Optional - The trading pair symbol (e.g., "BTC_USDT"). If not provided, tickers for all symbols will be returned. ### Request Example ```json { "request": "GET /api/v1/ticker?symbol=BTC_USDT" } ``` ### Response #### Success Response (200) - **symbol** (string) - The trading pair symbol. - **buy** (string) - The highest buy price. - **sell** (string) - The lowest sell price. - **high** (string) - The highest price in the last 24 hours. - **low** (string) - The lowest price in the last 24 hours. - **last** (string) - The last traded price. - **vol** (string) - The trading volume in the last 24 hours. - **rose** (string) - The price change in the last 24 hours. - **time** (integer) - The timestamp of the response. #### Response Example ```json { "code": 0, "msg": "Succeess", "data": [ { "symbol": "BTC_USDT", "buy": "60000.00", "sell": "60001.00", "high": "61000.00", "low": "59000.00", "last": "60000.50", "vol": "1000.50", "rose": "1.50", "time": 1678886400 } ] } ``` ``` -------------------------------- ### Example JSON Response for Deposit Address Query Source: https://github.com/webseaex/webseaex.github.io/blob/main/en/wallet/address/index.html This is an example of the JSON response received after a successful deposit address query. It includes status information and the deposit address. ```json { "errno": 0, "errmsg": "success", "result": { "address": "0x9930ec70ca65b979c35d08f33036b926cc94582d" } } ``` -------------------------------- ### JSON Example: Asset Status Source: https://github.com/webseaex/webseaex.github.io/blob/main/zh/wallet/curency-token/index.html This JSON structure details the deposit and withdrawal status for different cryptocurrency assets across various chains. It includes fields like 'chain', 'withdrawEnable', and 'depositEnable' for each asset. ```json { "errno": 0, "errmsg": "success", "result": { "BTC": [ { "chain": "BTC", "withdrawEnable": false, "depositEnable": false } ], "ETH": [ { "chain": "ERC20", "withdrawEnable": true, "depositEnable": true } ], "USDT": [ { "chain": "ERC20", "withdrawEnable": true, "depositEnable": true }, { "chain": "TRC20", "withdrawEnable": true, "depositEnable": true }, { "chain": "BEP20", "withdrawEnable": false, "depositEnable": false } ] } } ```