### GET /v5/pre-upgrade/execution/list Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/pre-upgrade/execution.mdx This example demonstrates a GET request to the /v5/pre-upgrade/execution/list endpoint. It includes common headers and query parameters for fetching execution data for a specific category, limit, and execution type. ```http GET /v5/pre-upgrade/execution/list?category=linear&limit=1&execType=Funding&symbol=BTCUSDT HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1682580752432 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### GET /v5/pre-upgrade/account/transaction-log Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/pre-upgrade/transaction-log.mdx This example demonstrates how to make an HTTP GET request to retrieve transaction logs for options from the pre-upgrade account. Ensure to include necessary authentication headers. ```http GET /v5/pre-upgrade/account/transaction-log?category=option HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1686808288265 X-BAPI-RECV-WINDOW: 5000 Content-Type: application/json ``` -------------------------------- ### GET /v5/earn/advance/product Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/advanced-earn/discount-buy/product-info.mdx This example demonstrates how to make an HTTP GET request to retrieve Discount Buy product information, filtering by underlying asset BTC. Ensure you use the correct API endpoint and include the category parameter. ```http GET /v5/earn/advance/product?category=DiscountBuy&coin=BTC HTTP/1.1 Host: api-testnet.bybit.com ``` -------------------------------- ### GET /v5/earn/pwm/investment-plan/order Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/pwm/investment-plan/order.mdx Example of an HTTP GET request to retrieve investment plan orders, specifying a plan ID and limit. ```http GET /v5/earn/pwm/investment-plan/order?planId=10001&limit=20 HTTP/1.1 Host: api.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1741651200000 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### HTTP Request Example (GET) Source: https://github.com/bybit-exchange/docs/blob/master/docs/p2p/guide.mdx This is an example of a GET request to the Bybit API, including necessary headers such as X-BAPI-SIGN, X-BAPI-API-KEY, X-BAPI-TIMESTAMP, and X-BAPI-RECV-WINDOW. ```http GET /v5/order/realtime?category=option&symbol=BTC-29JUL22-25000-C HTTP/1.1 Host: api-testnet.bybit.com -H 'X-BAPI-SIGN: XXXXXXXXXX' \ -H 'X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx' \ -H 'X-BAPI-TIMESTAMP: 1658384431891' \ -H 'X-BAPI-RECV-WINDOW: 5000' ``` -------------------------------- ### Get Investment Plans Response Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/pwm/asset-manager/get-investment-plan.mdx Example JSON response for the get investment plan endpoint, showing a list of active investment plans with their details and distribution. ```json { "retCode": 0, "retMsg": "success", "result": { "list": [ { "planId": "10001", "planName": "Conservative Growth Plan", "planType": "stable", "status": "Active", "source": "institution", "subscriptionUid": "12323434", "currentAssetUsd": "200137.50", "accumulateYieldUsd": "2137.50", "investmentDistribution": [ { "category": "equityFund", "productId": "431", "coin": "USDT", "currentAmount": "50000.00" } ], "createdTime": "1700000000000" } ], "nextPageCursor": "" } } ``` -------------------------------- ### HTTP Request Examples Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/guide.mdx Examples of making GET and POST requests to the Bybit API, including necessary headers for authentication and signing. ```APIDOC ## HTTP Request Examples ### GET Request Example ```http GET /v5/order/realtime?category=option&symbol=BTC-29JUL22-25000-C HTTP/1.1 Host: api-testnet.bybit.com -H 'X-BAPI-SIGN: XXXXXXXXXX' \ -H 'X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx' \ -H 'X-BAPI-TIMESTAMP: 1658384431891' \ -H 'X-BAPI-RECV-WINDOW: 5000' ``` ### POST Request Example ```http POST /v5/order/create HTTP/1.1 Host: api-testnet.bybit.com -H 'X-Referer: XXXXXXXXXX' [the header for broker users only] \ -H 'X-BAPI-SIGN: XXXXXXXXXX' \ -H 'X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx' \ -H 'X-BAPI-TIMESTAMP: 1658385589135' \ -H 'X-BAPI-RECV-WINDOW: 5000' \ -H 'Content-Type: application/json' \ -d '{"category": "option"}' ``` ``` -------------------------------- ### Get Fixed-Rate Borrow Order Quote (Python) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/spot-margin-uta/fixedborrow-order-quote.mdx This Python example demonstrates how to use the `pybit` library to get fixed-rate borrow order quotes. Ensure you have the library installed and your API credentials configured. ```python from pybit.unified_trading import HTTP session = HTTP( testnet=True, api_key="xxxxxxxxxxxxxxxxxx", api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ) print(session.spot_margin_trade_get_fixed_borrow_order_quote( orderCurrency="ETH", orderBy="apy", limit=10 )) ``` -------------------------------- ### Place Batch Orders (Go) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/batch-place.mdx This Go example shows how to place batch orders for options trading. It utilizes the Bybit Go SDK and requires API keys and secrets for authentication. Note the specific parameters for options orders. ```go import ( "context" "fmt" bybit "https://github.com/bybit-exchange/bybit.go.api") client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET)) params := map[string]interface{}{"category": "option", "request": []map[string]interface{}{ { "category": "option", "symbol": "BTC-10FEB23-24000-C", "orderType": "Limit", "side": "Buy", "qty": "0.1", "price": "5", "orderIv": "0.1", "timeInForce": "GTC", "orderLinkId": "9b381bb1-401", "mmp": false, "reduceOnly": false, }, { "category": "option", "symbol": "BTC-10FEB23-24000-C", "orderType": "Limit", "side": "Buy", "qty": "0.1", "price": "5", "orderIv": "0.1", "timeInForce": "GTC", "orderLinkId": "82ee86dd-001", "mmp": false, "reduceOnly": false, }, }, } client.NewUtaBybitServiceWithParams(params).PlaceBatchOrder(context.Background()) ``` -------------------------------- ### Python SDK Example for Pre Check Order Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/pre-check-order.mdx Shows how to use the pybit library to perform a pre-order check for a spot limit order with take profit and stop loss settings. ```python from pybit.unified_trading import HTTP session = HTTP( testnet=True, api_key="xxxxxxxxxxxxxxxxxx", api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ) print(session.pre_check_order( category="spot", symbol="BTCUSDT", side="Buy", orderType="Limit", qty="0.1", price="28000", timeInForce="PostOnly", takeProfit="35000", stopLoss="27000", tpOrderType="Market", slOrderType="Market", )) ``` -------------------------------- ### Get Loan Orders (Node.js) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/otc/loan-info.mdx This Node.js example shows how to use the RestClientV5 to fetch loan orders. It includes basic error handling for the API call. Make sure the bybit-api library is installed. ```javascript const { RestClientV5 } = require('bybit-api'); const client = new RestClientV5({ testnet: true, key: 'xxxxxxxxxxxxxxxxxx', secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', }); client .getInstitutionalLendingLoanOrders({ limit: 10, }) .then((response) => { console.log(response); }) .catch((error) => { console.error(error); }); ``` -------------------------------- ### Get Risk Limit (Python) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/market/risk-limit.mdx Retrieve risk limit data using the Bybit Python SDK. Ensure you have the `pybit` library installed. This example demonstrates fetching data for the inverse category and BTCUSD symbol. ```python from pybit.unified_trading import HTTP session = HTTP(testnet=True) print(session.get_risk_limit( category="inverse", symbol="BTCUSD", )) ``` -------------------------------- ### Place Batch Orders (Java) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/batch-place.mdx This Java example demonstrates placing batch orders for options using the Bybit Java SDK. It requires API keys and secrets and shows how to construct the order requests using the provided domain objects. ```java import com.bybit.api.client.restApi.BybitApiAsyncTradeRestClient; import com.bybit.api.client.domain.ProductType; import com.bybit.api.client.domain.TradeOrderType; import com.bybit.api.client.domain.trade.*; import com.bybit.api.client.service.BybitApiClientFactory; import java.util.Arrays; BybitApiClientFactory factory = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET"); BybitApiAsyncTradeRestClient client = factory.newAsyncTradeRestClient(); var orderRequests = Arrays.asList(TradeOrderRequest.builder().category(ProductType.OPTION).symbol("BTC-10FEB23-24000-C").side(Side.BUY).orderType(TradeOrderType.LIMIT).qty("0.1") .price("5").orderIv("0.1").timeInForce(TimeInForce.GOOD_TILL_CANCEL).orderLinkId("9b381bb1-401").mmp(false).reduceOnly(false).build(), TradeOrderRequest.builder().category(ProductType.OPTION).symbol("BTC-10FEB23-24000-C").side(Side.BUY).orderType(TradeOrderType.LIMIT).qty("0.1") .price("5").orderIv("0.1").timeInForce(TimeInForce.GOOD_TILL_CANCEL).orderLinkId("82ee86dd-001").mmp(false).reduceOnly(false).build()); var createBatchOrders = BatchOrderRequest.builder().category(ProductType.OPTION).request(orderRequests).build(); client.createBatchOrder(createBatchOrders, System.out::println); ``` -------------------------------- ### GET /v5/lending/history-order Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/abandon/order-record.mdx Example of an HTTP GET request to retrieve lending history orders. Ensure to include necessary authentication headers. ```http GET /v5/lending/history-order?orderNo=1403517113428086272 HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1682049395799 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### POST /v5/lending/purchase Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/abandon/deposit.mdx This example demonstrates how to make a POST request to the /v5/lending/purchase endpoint to deposit funds. Ensure correct headers and a JSON body with coin, quantity, and an optional serialNo are provided. ```http POST /v5/lending/purchase HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1682046368938 X-BAPI-RECV-WINDOW: 5000 Content-Type: application/json { "coin": "USDC", "quantity": "20.00005", "serialNo": "test-00007" } ``` -------------------------------- ### Get NAV Chart Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/rwa/nav-chart.mdx Example of an HTTP GET request to retrieve the NAV chart for a product. Authentication is not required. Ensure the productId is valid. ```http GET /v5/earn/rwa/nav-chart?productId=1001 HTTP/1.1 Host: api.bybit.com ``` -------------------------------- ### Upgrade to Unified Account Pro (.Net) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/account/upgrade-unified-account.mdx This .NET example shows how to upgrade your account to Unified Account Pro using the Bybit .NET SDK. Provide your API key and secret when initializing the service. ```csharp using bybit.net.api; using bybit.net.api.ApiServiceImp; using bybit.net.api.Models; BybitAccountService accountService = new(apiKey: "xxxxxx", apiSecret: "xxxxx"); Console.WriteLine(await accountService.UpgradeAccount()); ``` -------------------------------- ### Get LTV Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/abandon/ltv.mdx This is an example of an HTTP GET request to the /v5/ins-loan/ltv endpoint. Ensure your request includes the necessary API key, timestamp, and signature headers. ```http GET /v5/ins-loan/ltv HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1678688069538 X-BAPI-RECV-WINDOW: 5000 X-BAPI-SIGN: XXXXX ``` -------------------------------- ### Upgrade to Unified Account Pro (Go) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/account/upgrade-unified-account.mdx This Go code example shows how to trigger the upgrade to Unified Account Pro using the Bybit Go SDK. Replace placeholders with your actual API key and secret. ```go import ( "context" "fmt" bybit "github.com/bybit-exchange/bybit.go.api" ) client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET") client.NewUtaBybitServiceNoParams().UpgradeToUTA(context.Background()) ``` -------------------------------- ### Stake Order Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/advanced-earn/smart-lvg/create-order.mdx This example demonstrates how to construct a POST request to place a 'Stake' order for the Smart Leverage product. Ensure all required parameters, including `smartLeverageStakeExtra` with `initialPrice` and `breakevenPrice`, are correctly provided. ```http POST /v5/earn/advance/place-order HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1672211928338 X-BAPI-RECV-WINDOW: 5000 Content-Type: application/json { "category": "SmartLeverage", "productId": "12999", "coin": "USDT", "orderType": "Stake", "amount": "100", "accountType": "FUND", "orderLinkId": "usdt-earn-007", "smartLeverageStakeExtra": { "initialPrice": "68403", "breakevenPrice": "68650" } } ``` -------------------------------- ### Get RWA Order List Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/rwa/order.mdx This example demonstrates how to make an HTTP GET request to retrieve a list of RWA orders, filtered by order type and limit. ```http GET /v5/earn/rwa/order?orderType=Stake&limit=20 HTTP/1.1 Host: api.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1710691200000 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### Create Option Order with Java SDK Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/create-order.mdx Illustrates creating an option order using the Bybit Java SDK. This example requires API credentials and specifies order details like symbol, quantity, and price. ```java import com.bybit.api.client.restApi.BybitApiAsyncTradeRestClient; import com.bybit.api.client.domain.ProductType; import com.bybit.api.client.domain.TradeOrderType; import com.bybit.api.client.domain.trade.PositionIdx; import com.bybit.api.client.domain.trade.Side; import com.bybit.api.client.domain.trade.TimeInForce; import com.bybit.api.client.domain.trade.TradeOrderRequest; import com.bybit.api.client.service.BybitApiClientFactory; import java.util.Map; BybitApiClientFactory factory = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET"); BybitApiAsyncTradeRestClient client = factory.newAsyncTradeRestClient(); Map order =Map.of( "category", "option", "symbol", "BTC-29DEC23-10000-P", "side", "Buy", "orderType", "Limit", "orderIv", "0.1", "qty", "0.1", "price", "5", "orderLinkId", "test_orderLinkId_1" ); client.createOrder(order, System.out::println); ``` -------------------------------- ### Get Earn Order List Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/earn/byusdt/order.mdx This example demonstrates how to make an HTTP GET request to retrieve a list of Earn orders for BYUSDT. Ensure to include necessary authentication headers. ```http GET /v5/earn/token/order?coin=BYUSDT HTTP/1.1 Host: api.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1741651200000 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### Repay Flexible Crypto Loan with Collateral (Python) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/new-crypto-loan/flexible/repay-collateral.mdx This Python example demonstrates how to initiate a collateral repayment for a flexible crypto loan using the Bybit SDK. It requires initializing the HTTP client with your API credentials and then calling the `collateral_repayment_flexible_crypto_loan` method with the loan details. ```python from pybit.unified_trading import HTTP session = HTTP( testnet=True, api_key="xxxxxxxxxxxxxxxxxx", api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ) print(session.collateral_repayment_flexible_crypto_loan( loanCurrency="USDT", amount="500", collateralCoin="BTC", )) ``` -------------------------------- ### Generate Plain Text for Signing (GET) Source: https://github.com/bybit-exchange/docs/blob/master/docs/p2p/guide.mdx This example shows the rule and example values for constructing the plain text string to be signed for GET requests. Ensure all components are concatenated in the specified order. ```shell # rule: timestamp+api_key+recv_window+queryString # example values: timestamp = "1658384314791" api_key = "XXXXXXXXXX" recv_window = "5000" queryString = "category=option&symbol=BTC-29JUL22-25000-C" # resulting string that needs to be signed: "1658384314791XXXXXXXXXX5000category=option&symbol=BTC-29JUL22-25000-C" # resulting example signature for HMAC: "410e0f387bafb7afd0f1722c068515e09945610124fa11774da1da857b72f30b" ``` -------------------------------- ### Create Linear Order with Go SDK Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/create-order.mdx Demonstrates placing a linear order using the Bybit Go SDK. This example uses testnet and requires API key and secret. ```go import ( "context" "fmt" bybit "https://github.com/bybit-exchange/bybit.go.api") client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET)) params := map[string]interface{}{ "category": "linear", "symbol": "BTCUSDT", "side": "Buy", "positionIdx": 0, "orderType": "Limit", "qty": "0.001", "price": "10000", "timeInForce": "GTC", } client.NewUtaBybitServiceWithParams(params).PlaceOrder(context.Background()) ``` -------------------------------- ### Create Linear Order with .NET SDK Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/create-order.mdx Shows how to place a linear market order using the Bybit .NET SDK. This example uses provided API key and secret for authentication. ```csharp using bybit.net.api.ApiServiceImp; using bybit.net.api.Models.Trade; BybitTradeService tradeService = new(apiKey: "xxxxxxxxxxxxxx", apiSecret: "xxxxxxxxxxxxxxxxxxxxx"); var orderInfo = await tradeService.PlaceOrder(category: Category.LINEAR, symbol: "BLZUSDT", side: Side.BUY, orderType: OrderType.MARKET, qty: "15", timeInForce: TimeInForce.GTC); Console.WriteLine(orderInfo); ``` -------------------------------- ### Python SDK Example for Transferable Coin List Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/asset/transfer/transferable-coin.mdx Shows how to use the pybit library to get the transferable coin list. Initialize the HTTP client with your API credentials and testnet status. ```python from pybit.unified_trading import HTTP session = HTTP( testnet=True, api_key="xxxxxxxxxxxxxxxxxx", api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ) print(session.get_transferable_coin( fromAccountType="UNIFIED", toAccountType="CONTRACT", )) ``` -------------------------------- ### Get Order List Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/earn/fixed-saving/order.mdx This example demonstrates how to make a GET request to the /v5/earn/fixed-term/order endpoint to retrieve orders filtered by productId and category. Ensure your request includes necessary authentication headers. ```http GET /v5/earn/fixed-term/order?productId=546&category=FixedTermSaving HTTP/1.1 Host: api.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1741651200000 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### Place Batch Orders (.Net) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/batch-place.mdx This C# example shows how to place batch orders for linear futures using the Bybit .NET SDK. It defines two order requests and sends them in a single batch operation. Ensure you have the bybit.net.api library referenced. ```csharp using bybit.net.api.ApiServiceImp; using bybit.net.api.Models.Trade; var order1 = new OrderRequest { Symbol = "XRPUSDT", OrderType = "Limit", Side = "Buy", Qty = "10", Price = "0.6080", TimeInForce = "GTC" }; var order2 = new OrderRequest { Symbol = "BLZUSDT", OrderType = "Limit", Side = "Buy", Qty = "10", Price = "0.6080", TimeInForce = "GTC" }; List request = new() { order1, order2 }; var orderInfoString = await TradeService.PlaceBatchOrder(category: Category.LINEAR, request: request); Console.WriteLine(orderInfoString); ``` -------------------------------- ### Get APR History Request Example (HTTP) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/earn/easy-onchain/apr-history.mdx This example demonstrates how to make a GET request to the /v5/earn/apr-history endpoint to retrieve APR data. Ensure you replace placeholder values with actual product IDs and categories. ```http GET /v5/earn/apr-history?productId=8&category=OnChain HTTP/1.1 Host: api-testnet.bybit.com ``` -------------------------------- ### Get Option Market Instrument Info (Go) Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/market/instrument.mdx This Go example demonstrates fetching option instrument data using the Bybit Go SDK. The params map should include the category and the specific option symbol. ```go import ( "context" "fmt" bybit "github.com/bybit-exchange/bybit.go.api" ) client := bybit.NewBybitHttpClient("", "", bybit.WithBaseURL(bybit.TESTNET)) params := map[string]interface{}{"category": "option", "symbol": "ETH-3JAN23-1250-P"} client.NewUtaBybitServiceWithParams(params).GetInstrumentInfo(context.Background()) ``` -------------------------------- ### Signature Generation for GET Requests Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/guide.mdx This snippet illustrates how to construct the string to be signed for GET requests and provides an example signature. ```APIDOC ## GET Request Signature ### Description Construct the string for signing by concatenating the timestamp, API key, recv_window, and queryString. ### Method GET ### Parameters - **timestamp** (string) - The current timestamp in milliseconds. - **api_key** (string) - Your unique API key. - **recv_window** (string) - The window within which the request must be processed. - **queryString** (string) - The query parameters of the request. ### Request Example String Construction ``` timestamp + api_key + recv_window + queryString ``` ### Example Values ``` timestamp = "1658384314791" api_key = "XXXXXXXXXX" recv_window = "5000" queryString = "category=option&symbol=BTC-29JUL22-25000-C" ``` ### Resulting String to Sign ``` "1658384314791XXXXXXXXXX5000category=option&symbol=BTC-29JUL22-25000-C" ``` ### Example Signature (HMAC) ``` "410e0f387bafb7afd0f1722c068515e09945610124fa11774da1da857b72f30b" ``` ``` -------------------------------- ### Get Pay Info HTTP Request Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/account/pay-info.mdx Example of an HTTP GET request to the /v5/account/pay-info endpoint, specifying the coin parameter. ```http GET /v5/account/pay-info?coin=SOL HTTP/1.1 Host: api.bybit.com X-BAPI-SIGN: XXXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1773230920000 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### HTTP Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/affiliate/affiliate-sub-list.mdx Demonstrates how to make a GET request to the affiliate sub-affiliate list endpoint with specified parameters. ```http GET /v5/affiliate/affiliate-sub-list?cursor=&size=100&startDate=2024-01-01&endDate=2024-01-31 HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1706745600000 X-BAPI-RECV-WINDOW: 5000 X-BAPI-SIGN: xxxxxx Content-Type: application/json ``` -------------------------------- ### Create Spot Order with Python SDK Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/create-order.mdx Shows how to place a spot order using the Bybit Python SDK. Ensure you have the SDK installed and your API credentials configured. ```python from pybit.unified_trading import HTTP session = HTTP( testnet=True, api_key="xxxxxxxxxxxxxxxxxx", api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", ) print(session.place_order( category="spot", symbol="BTCUSDT", side="Buy", orderType="Limit", qty="0.1", price="15600", timeInForce="PostOnly", orderLinkId="spot-test-postonly", isLeverage=0, orderFilter="Order", )) ``` -------------------------------- ### HTTP Request Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/finance/pwm/asset-manager/all-funds.mdx Example of an HTTP GET request to the all funds endpoint. Ensure to include necessary authentication headers. ```http GET /v5/earn/pwm/asset-manager/all-funds HTTP/1.1 Host: api.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1741651200000 X-BAPI-RECV-WINDOW: 5000 ``` -------------------------------- ### HTTP Request Examples for Creating Orders Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/order/create-order.mdx Demonstrates various ways to create orders using HTTP requests, including spot and linear categories with different take-profit and stop-loss configurations. ```http POST /v5/order/create HTTP/1.1 Host: api-testnet.bybit.com X-BAPI-SIGN: XXXXX X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx X-BAPI-TIMESTAMP: 1672211928338 X-BAPI-RECV-WINDOW: 5000 Content-Type: application/json // Spot Limit order with market tp sl {"category": "spot","symbol": "BTCUSDT","side": "Buy","orderType": "Limit","qty": "0.01","price": "28000","timeInForce": "PostOnly","takeProfit": "35000","stopLoss": "27000","tpOrderType": "Market","slOrderType": "Market"} // Spot Limit order with limit tp sl {"category": "spot","symbol": "BTCUSDT","side": "Buy","orderType": "Limit","qty": "0.01","price": "28000","timeInForce": "PostOnly","takeProfit": "35000","stopLoss": "27000","tpLimitPrice": "36000","slLimitPrice": "27500","tpOrderType": "Limit","slOrderType": "Limit"} // Spot PostOnly normal order {"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"0.1","price":"15600","timeInForce":"PostOnly","orderLinkId":"spot-test-01","isLeverage":0,"orderFilter":"Order"} // Spot TP/SL order {"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"0.1","price":"15600","triggerPrice": "15000", "timeInForce":"Limit","orderLinkId":"spot-test-02","isLeverage":0,"orderFilter":"tpslOrder"} // Spot margin normal order (UTA) {"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"0.1","price":"15600","timeInForce":"GTC","orderLinkId":"spot-test-limit","isLeverage":1,"orderFilter":"Order"} // Spot Market Buy order, qty is quote currency {"category":"spot","symbol":"BTCUSDT","side":"Buy","orderType":"Market","qty":"200","timeInForce":"IOC","orderLinkId":"spot-test-04","isLeverage":0,"orderFilter":"Order"} // USDT Perp open long position (one-way mode) {"category":"linear","symbol":"BTCUSDT","side":"Buy","orderType":"Limit","qty":"1","price":"25000","timeInForce":"GTC","positionIdx":0,"orderLinkId":"usdt-test-01","reduceOnly":false,"takeProfit":"28000","stopLoss":"20000","tpslMode":"Partial","tpOrderType":"Limit","slOrderType":"Limit","tpLimitPrice":"27500","slLimitPrice":"20500"} // USDT Perp close long position (one-way mode) {"category": "linear", "symbol": "BTCUSDT", "side": "Sell", "orderType": "Limit", "qty": "1", "price": "30000", "timeInForce": "GTC", "positionIdx": 0, "orderLinkId": "usdt-test-02", "reduceOnly": true} ``` -------------------------------- ### Get Pay Info Response Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/account/pay-info.mdx Example JSON response for the /v5/account/pay-info endpoint, showing collateral and borrow information. ```json { "retCode": 0, "retMsg": "Success", "result": { "collateralInfo": { "collateralList": [ { "availableValue": "13038.369918809215134556464993", "coinScale": 4, "borrowSize": "0", "spotHedgeAmount": "0", "assetFrozen": "0", "availableSize": "13041.904274867704282417", "coin": "USDT" }, { "availableValue": "4997.9120975285472554850", "coinScale": 6, "borrowSize": "0", "spotHedgeAmount": "0", "assetFrozen": "0", "availableSize": "4997.912097528547255485", "coin": "USDC" }, { "availableValue": "0", "coinScale": 8, "borrowSize": "0.10006839", "spotHedgeAmount": "0", "assetFrozen": "0", "availableSize": "0", "coin": "SOL" }, { "availableValue": "0", "coinScale": 9, "borrowSize": "0.001000068", "spotHedgeAmount": "-0.00100006728685180109293673123005419256514869630336761474609375", "assetFrozen": "0", "availableSize": "0", "coin": "BTC" }, { "availableValue": "38488.319604591478793130841305", "coinScale": 8, "borrowSize": "0", "spotHedgeAmount": "0", "assetFrozen": "0", "availableSize": "17.867158854367695555", "coin": "ETH" } ] }, "borrowInfo": { "borrowSize": "0.100068384926503532", "assetFrozen": "0", "borrowValue": "9.172497619169950215718876", "coin": "SOL", "availableBalance": "0" } }, "retExtInfo": {}, "time": 1774344990873 } ``` -------------------------------- ### POST /v5/lending/purchase Response Example Source: https://github.com/bybit-exchange/docs/blob/master/docs/v5/abandon/deposit.mdx This is an example of a successful response from the /v5/lending/purchase endpoint, showing the details of the deposit order including status and timestamps. ```json { "retCode": 0, "retMsg": "OK", "result": { "coin": "USDC", "createdTime": "1682046369112", "orderId": "1403501100816928256", "quantity": "20.00005", "serialNo": "test-00007", "status": "0", "updatedTime": "1682046369112" }, "retExtInfo": {}, "time": 1682046369120 } ```