### Installation and Import Source: https://github.com/binance/binance-connector-go Instructions on how to install the Binance Spot Go Connector library using go get and how to import it into your Go projects. ```go go get github.com/binance/binance-connector-go import ( "github.com/binance/binance-connector-go" ) ``` -------------------------------- ### Binance API Postman Setup Guide Source: https://github.com/binance-exchange/binance-api-postman Instructions for importing and configuring Binance API Postman Collections and Environments. This process allows users to quickly start using Binance's RESTful APIs by leveraging pre-configured Postman files, requiring only the setup of API and secret keys. ```APIDOC Binance API Postman Collections: Description: Binance provides Postman Collections and Environment files (JSON) to facilitate the use of its RESTful APIs. Users can import these files into Postman to streamline API interactions. Setup Process: 1. Download the 'binance-api-postman' repository. 2. In Postman, click the 'Import' button. 3. Select the root folder of the downloaded repository. 4. Choose the specific collections and environments to import. 5. Click the 'Import' button to complete the setup. Configuration: After importing, users need to configure their API and secret keys within the Postman environment to authenticate requests to the Binance API. ``` -------------------------------- ### Binance API Postman Setup Guide Source: https://github.com/binance/binance-api-postman Instructions for importing and configuring Binance API Postman Collections and Environments. This process allows users to quickly start using Binance's RESTful APIs by leveraging pre-configured Postman files, requiring only the setup of API and secret keys. ```APIDOC Binance API Postman Collections: Description: Binance provides Postman Collections and Environment files (JSON) to facilitate the use of its RESTful APIs. Users can import these files into Postman to streamline API interactions. Setup Process: 1. Download the 'binance-api-postman' repository. 2. In Postman, click the 'Import' button. 3. Select the root folder of the downloaded repository. 4. Choose the specific collections and environments to import. 5. Click the 'Import' button to complete the setup. Configuration: After importing, users need to configure their API and secret keys within the Postman environment to authenticate requests to the Binance API. ``` -------------------------------- ### Install Binance Connector Go Source: https://github.com/binance/binance-connector-go Command to install the Binance Connector Go library using go get. This is the first step to integrate Binance API functionality into your Go projects. ```shell go get github.com/binance/binance-connector-go ``` -------------------------------- ### Install Binance SDK with All Features Source: https://github.com/binance/binance-spot-connector-rust Example of adding the binance-sdk to Cargo.toml, enabling all available connectors using the 'all' feature. This is useful for projects requiring comprehensive access to Binance functionalities. ```toml [dependencies] binance-sdk = { version = "1.0.0", features = ["all"] } ``` -------------------------------- ### Websocket Connection Example (Ruby) Source: https://github.com/binance/binance-connector-ruby Demonstrates a basic websocket connection setup in Ruby for Binance, specifying interval and callback functions. More examples are available in the 'examples' folder. ```ruby client.websocket.user_data( listen_key: listen_key, id: 1, params: { interval: '30m', callbacks: callbacks } ) end ``` -------------------------------- ### Start Local Swagger UI Instance Source: https://github.com/binance/binance-api-swagger Instructions to run a local instance of the Binance API Swagger UI using Docker. This involves installing Docker and executing a provided script. ```shell ./start.sh ``` -------------------------------- ### Install Binance SDK with Specific Features Source: https://github.com/binance/binance-spot-connector-rust Example of adding the binance-sdk to Cargo.toml, enabling specific features like Spot and USDS-M Futures. This allows for a more tailored dependency graph. ```toml [dependencies] binance-sdk = { version = "1.0.0", features = ["derivatives_trading_usds_futures", "spot"] } ``` -------------------------------- ### Install Rust Binance SDK with Features Source: https://github.com/binance/binance-spot-connector-rust Add the binance-sdk crate to your Cargo.toml, specifying desired features for module inclusion. This example includes Spot and USDS-M Futures modules. ```toml [dependencies] binance-sdk = { version = "1.0.0", features = ["derivatives_trading_usds_futures", "spot"] } ``` ```toml [dependencies] binance-sdk = { version = "1.0.0", features = ["all"] } ``` -------------------------------- ### Initialize Binance Go Client Source: https://github.com/binance/binance-connector-go Demonstrates how to create a new Binance client instance using API keys and a base URL. It also shows how to enable debug mode and set a time offset for request timestamps. ```go client := binance_connector.NewClient("yourApiKey", "yourSecretKey", "https://api.binance.com") // Debug Mode client.Debug = true // TimeOffset (in milliseconds) - used to adjust the request timestamp by subtracting/adding the current time with it: client.TimeOffset = -1000 // implies adding: request timestamp = current time - (-1000) ``` -------------------------------- ### Start User Data Stream Response Example Source: https://developers.binance.com/docs/derivatives/option/user-data-streams/Start-User-Data-Stream Example JSON response when successfully starting a user data stream on Binance. It contains the unique listenKey required for subsequent stream operations. ```json { "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1" } ``` -------------------------------- ### REST API: Create Order Example Source: https://github.com/binance/binance-connector-go A complete Go example demonstrating how to create a new market order using the Binance Spot Go Connector. It includes client initialization, setting order parameters, and handling the response. ```go package main import ( "context" "fmt" binance_connector "github.com/binance/binance-connector-go" ) func main() { apiKey := "yourApiKey" secretKey := "yourSecretKey" baseURL := "https://testnet.binance.vision" // Initialise the client client := binance_connector.NewClient(apiKey, secretKey, baseURL) // Create new order newOrder, err := client.NewCreateOrderService().Symbol("BTCUSDT"). Side("BUY").Type("MARKET").Quantity(0.001). Do(context.Background()) if err != nil { fmt.Println(err) return } fmt.Println(binance_connector.PrettyPrint(newOrder)) } ``` -------------------------------- ### Start User Data Stream Response Example Source: https://developers.binance.com/docs/derivatives/option/user-data-streams/Start-User-Data-Stream/ Example JSON response when successfully starting a user data stream on Binance. It contains the unique listenKey required for subsequent stream operations. ```json { "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1" } ``` -------------------------------- ### Python WebSocket Client Setup Source: https://github.com/binance/binance-sbe-java-sample-app Instructions for setting up a Python environment to run WebSocket client scripts. It highlights the necessity of the 'websocket-client' package and its 'create_connection' function for establishing WebSocket connections. ```python Note: To run websocket_send.py, your Python 3 environment should include the websocket-client package with the integrated create_connection function. ``` -------------------------------- ### Start User Data Stream Response Example Source: https://context7_llms Example response for starting a user data stream on Binance derivatives. It includes the listenKey required for subsequent WebSocket connections. ```JSON { "listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1" } ``` -------------------------------- ### Binance API Client Initialization Example Source: https://github.com/binance/binance-futures-connector-python Demonstrates initializing a Binance API client with private keys and optional parameters. It shows how to call the account information method. ```python client = Client(api_key="api_key", api_secret="api_secret", private_key="private_key", private_key_passphrase="private_key_passphrase") print(client.account()) ``` -------------------------------- ### Client Initialization Source: https://github.com/binance/binance-connector-go Demonstrates how to initialize the Binance API client with API keys and an optional base URL. The base URL defaults to 'https://api.binance.com' if not provided. ```go // The Client can be initiated with apiKey, secretKey and baseURL. // The baseURL is optional. If not specified, it will default to "https://api.binance.com". client := binance_connector.NewClient("yourApiKey", "yourSecretKey") // Example with a specific baseURL client := binance_connector.NewClient("yourApiKey", "yourSecretKey", "https://api.binance.com") ``` -------------------------------- ### Binance WebSocket Streams Setup Source: https://github.com/binance/binance-connector-java Demonstrates how to configure and initialize the SpotWebSocketStreams client for Binance. It shows setting up client configuration, enabling connection pooling, and creating an instance of the API client. ```java // Basic client config ClientConfiguration clientConfiguration = SpotWebSocketStreamsUtil.getClientConfiguration(); // set usePool flag to true clientConfiguration.setUsePool(true); // Use the api SpotWebSocketStreams api = new SpotWebSocketStreams(clientConfiguration); ``` -------------------------------- ### Get OCO History via Binance Websocket API (Go) Source: https://github.com/binance/binance-connector-go This Go example demonstrates how to initialize the Binance Websocket API client, connect to the service, and retrieve the account's OCO history. It includes error handling and prints the formatted response. Ensure you have the necessary API keys and the binance-connector library installed. ```go func OCOHistoryExample() { // Initialise Websocket API Client client := binance_connector.NewWebsocketAPIClient("api_key", "secret_key") // Connect to Websocket API err := client.Connect() if err != nil { log.Printf("Error: %v", err) return } defer client.Close() // Send request to Websocket API response, err := client.NewAccountOCOHistoryService().Do(context.Background()) if err != nil { log.Printf("Error: %v", err) return } // Print the response fmt.Println(binance_connector.PrettyPrint(response)) client.WaitForCloseSignal() } ``` -------------------------------- ### Get Market Maker Protection Config Response Example Source: https://context7_llms Provides an example JSON response structure for the Get Market Maker Protection Config endpoint, detailing parameters like underlyingId, underlying, windowTimeInMilliseconds, frozenTimeInMilliseconds, qtyLimit, deltaLimit, and lastTriggerTime. ```APIDOC GET /eapi/v1/mmp Response Example: { "underlyingId": 2, "underlying": "BTCUSDT", "windowTimeInMilliseconds": 3000, "frozenTimeInMilliseconds": 300000, "qtyLimit": "2", "deltaLimit": "2.3", "lastTriggerTime": 0 } ``` -------------------------------- ### Install Binance SDK Connectors Source: https://github.com/binance/binance-connector-python Demonstrates how to install individual or multiple Binance SDK connectors using pip and poetry package managers. ```shell pip install binance-sdk-spot ``` ```shell poetry add binance-sdk-spot ``` ```shell pip install binance-sdk-spot binance-sdk-margin-trading binance-sdk-staking ``` ```shell poetry add binance-sdk-spot binance-sdk-margin-trading binance-sdk-staking ``` -------------------------------- ### Binance Get Auto-repay Futures Status Response Example Source: https://context7_llms Example JSON response for the API endpoint that retrieves the auto-repay futures status. It indicates whether auto-repay is enabled or disabled. ```json { "autoRepay": true // "true" for turn on the auto-repay futures; "false" for turn off the auto-repay futures } ``` -------------------------------- ### Get Download Id For Futures Order History API Source: https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Order-History Retrieves a download ID for futures order history. This API endpoint requires start and end timestamps and has specific request limitations. ```APIDOC GET /fapi/v1/order/asyn Request Weight: 1000 Parameters: startTime (LONG, MANDATORY): Timestamp in milliseconds. endTime (LONG, MANDATORY): Timestamp in milliseconds. recvWindow (LONG, OPTIONAL): The time between `startTime` and `endTime` can not be longer than 1 year. timestamp (LONG, MANDATORY): Request timestamp. Limitations: - Request Limitation is 10 times per month, shared by front end download page and rest api. - The time between `startTime` and `endTime` can not be longer than 1 year. Response Example: { "avgCostTimestampOfLast30d": 7241837, "downloadId": "546975389218332672" } Related Methods: - Get Futures Transaction History Download Link By Id - Get Futures Order History Download Link By Id ``` -------------------------------- ### Install Binance Spot Connector Source: https://github.com/binance/binance-connector-js Demonstrates how to install the Binance Spot Trading connector package using npm. This is a common installation pattern for all available connectors. ```bash npm install @binance/spot ``` -------------------------------- ### Get Download Id For Futures Order History API Source: https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Order-History/ Retrieves a download ID for futures order history. This API endpoint requires start and end timestamps and has specific request limitations. ```APIDOC GET /fapi/v1/order/asyn Request Weight: 1000 Parameters: startTime (LONG, MANDATORY): Timestamp in milliseconds. endTime (LONG, MANDATORY): Timestamp in milliseconds. recvWindow (LONG, OPTIONAL): The time between `startTime` and `endTime` can not be longer than 1 year. timestamp (LONG, MANDATORY): Request timestamp. Limitations: - Request Limitation is 10 times per month, shared by front end download page and rest api. - The time between `startTime` and `endTime` can not be longer than 1 year. Response Example: { "avgCostTimestampOfLast30d": 7241837, "downloadId": "546975389218332672" } Related Methods: - Get Futures Transaction History Download Link By Id - Get Futures Order History Download Link By Id ``` -------------------------------- ### Client Initialization Options Source: https://github.com/binance/binance-connector-ruby Illustrates various options for initializing the Binance Spot API client, including setting a custom base URL for testnet or alternative production URLs, specifying a timeout duration, and enabling response weight usage logging. ```Ruby # Default base URL is 'api.binance.com' # For testnet: client_testnet = Binance::Spot.new(base_url: 'https://testnet.binance.vision') # Using alternative production URLs: # client_alt_url = Binance::Spot.new(base_url: 'https://api1.binance.com') # Setting a timeout (in seconds): client_timeout = Binance::Spot.new(timeout: 2) # Enabling response weight usage logging: client_weight_usage = Binance::Spot.new(show_weight_usage: true) # Example response structure when show_weight_usage is true: # {:data=>{:serverTime=>1589860878546}, :weight_usage=>{"x-mbx-used-weight"=>"1", "x-mbx-used-weight-1m"=>"1"}} # Enabling header logging for debugging: client_header = Binance::Spot.new(show_header: true) # Example response structure when show_header is true: # {:data=>{:serverTime=>1589863539220}, :header=>{"content-type"=>"application/json;charset=utf-8",...}} ``` -------------------------------- ### Using Binance Testnet Source: https://github.com/binance/binance-connector-dotnet Shows how to initialize the Binance Spot client to interact with the Spot Testnet environment. This is useful for testing API integrations without affecting live trading. ```C# using Binance.Spot; Wallet wallet = new Wallet(baseUrl: "https://testnet.binance.vision"); ``` -------------------------------- ### Binance Funding Rate History Response Example Source: https://context7_llms Example JSON response structure for the Get Funding Rate History of Perpetual Futures API endpoint. It details the symbol, funding time, and funding rate for each entry. ```JSON [ { "symbol": "BTCUSD_PERP", "fundingTime": 1596038400000, "fundingRate": "-0.00300000" }, { "symbol": "BTCUSD_PERP", "fundingTime": 1596067200000, "fundingRate": "-0.00300000" } ] ``` -------------------------------- ### Binance UM Position Mode Response Example Source: https://context7_llms Provides an example JSON response for the Get UM Current Position Mode API endpoint. It indicates whether the account is in Hedge Mode (dualSidePosition: true) or One-way Mode (dualSidePosition: false). ```APIDOC API: Get UM Current Position Mode Request Parameters: recvWindow (LONG, Optional): The request is valid for this many milliseconds. timestamp (LONG, Required): UTC timestamp in milliseconds. Response Example: ```json { "dualSidePosition": true // "true": Hedge Mode; "false": One-way Mode } ``` Related Links: - API Description: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode#api-description - HTTP Request: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode#http-request - Request Weight: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode#request-weight - Request Parameters: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode#request-parameters - Response Example: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Current-Position-Mode#response-example ``` -------------------------------- ### Binance UM Futures Transaction History Response Example Source: https://context7_llms Example JSON response structure for the Get Download ID for UM Futures Transaction History API endpoint. It includes the average cost timestamp for the last 30 days and the generated download ID. ```JSON { "avgCostTimestampOfLast30d":7241837, // Average time taken for data download in the past 30 days "downloadId":"546975389218332672" } ``` -------------------------------- ### PHP Binance Client Setup with Proxies Source: https://github.com/binance/binance-connector-php Demonstrates how to initialize the Binance SpotRestApi client in PHP, including configuring proxy settings for network requests. ```PHP $configurationBuilder = SpotRestApiUtil::getConfigurationBuilder(); // define the proxies $proxies = [ 'http' => 'http://localhost:8080', 'https' => 'http://localhost:8080', ]; $configurationBuilder->setProxy($proxies); $api = new SpotRestApi($configurationBuilder->build()); ``` -------------------------------- ### Binance .NET SDK Logging Integration Example Source: https://github.com/binance/binance-connector-dotnet Demonstrates how to set up logging for the Binance .NET SDK by creating a BinanceLoggingHandler and using it with an HttpClient. This example shows how to make a call to the SystemStatus endpoint. ```cs using System; using System.Net; using System.Net.Http; using Binance.Spot; public async Task LoggingExample(ILogger logger) { BinanceLoggingHandler loggingHandler = new BinanceLoggingHandler(logger: logger); HttpClient httpClient = new HttpClient(handler: loggingHandler); Wallet wallet = new Wallet(httpClient: httpClient); await wallet.SystemStatus(); } ``` -------------------------------- ### Get BNB Burn Status API Source: https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-BNB-Burn-Status Retrieves the user's BNB Fee Discount status (Fee Discount On or Fee Discount Off) for Binance Futures. It details the HTTP GET request, parameters like `recvWindow` and `timestamp`, and provides an example response indicating the `feeBurn` status. ```APIDOC Get BNB Burn Status (USER_DATA) ================================ API Description: Get user's BNB Fee Discount (Fee Discount On or Fee Discount Off ) HTTP Request: GET /fapi/v1/feeBurn Request Weight: 30 Request Parameters: Name Type Mandatory Description recvWindow LONG NO timestamp LONG YES Response Example: { "feeBurn": true } // "true": Fee Discount On; "false": Fee Discount Off ``` -------------------------------- ### Initialize HttpClient and Wallet Source: https://github.com/binance/binance-connector-dotnet Demonstrates how to initialize an HttpClient with a logging handler and then create a Wallet instance using this client. This setup is typically required before making API calls. ```csharp var logger = new LoggingHandler(); var httpClient = new HttpClient(handler: logger); var wallet = new Wallet(httpClient: httpClient); await wallet.SystemStatus(); ``` -------------------------------- ### Initialize Binance Connector Client Source: https://github.com/binance/binance-connector-go Example of initializing the Binance Connector client with API key and secret key. The base URL is optional and defaults to 'https://api.binance.com'. ```go // The Client can be initiated with apiKey, secretKey and baseURL. // The baseURL is optional. If not specified, it will default to "https://api.binance.com". client := binance_connector.NewClient("yourApiKey", "yourSecretKey") ``` -------------------------------- ### Get BNB Burn Status API Source: https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Get-BNB-Burn-Status/ Retrieves the user's BNB Fee Discount status (Fee Discount On or Fee Discount Off) for Binance Futures. It details the HTTP GET request, parameters like `recvWindow` and `timestamp`, and provides an example response indicating the `feeBurn` status. ```APIDOC Get BNB Burn Status (USER_DATA) ================================ API Description: Get user's BNB Fee Discount (Fee Discount On or Fee Discount Off ) HTTP Request: GET /fapi/v1/feeBurn Request Weight: 30 Request Parameters: Name Type Mandatory Description recvWindow LONG NO timestamp LONG YES Response Example: { "feeBurn": true } // "true": Fee Discount On; "false": Fee Discount Off ``` -------------------------------- ### Initialize Binance Spot Client with Headers Source: https://github.com/binance/binance-connector-ruby Shows how to initialize the Binance::Spot client in Ruby with the `show_header: true` option. This enables the client to print all response headers, which is useful for debugging. ```ruby client = Binance::Spot.new(show_header: true) ``` -------------------------------- ### Binance Futures Connector Python Examples Source: https://github.com/binance/binance-futures-connector-python Demonstrates how to use the Binance Futures Connector in Python. Includes examples for fetching server time, retrieving account information (requires API keys), and placing a new order. ```python from binance.cm_futures import CMFutures cm_futures_client = CMFutures() # get server time print(cm_futures_client.time()) cm_futures_client = CMFutures(key='', secret='') # Get account information print(cm_futures_client.account()) # Post a new order params = { 'symbol': 'BTCUSDT', 'side': 'SELL', 'type': 'LIMIT', 'timeInForce': 'GTC', 'quantity': 0.002, 'price': 59808 } response = cm_futures_client.new_order(**params) print(response) ``` -------------------------------- ### Basic Websocket Streams Client Configuration Source: https://github.com/binance/binance-connector-java Configures a basic client for Websocket Streams. This example shows how to get the client configuration and enable connection pooling by setting usePool to true. ```Java // Basic client config WebSocketClientConfiguration clientConfiguration = SpotWebSocketStreamsUtil.getClientConfiguration(); // set usePool flag to true clientConfiguration.setUsePool(true); // Use the api SpotWebSocketStreams api = new SpotWebSocketStreams(clientConfiguration); ``` -------------------------------- ### Binance API: Get UM Futures Trade Download Link Response Source: https://context7_llms Provides example JSON responses for the Get UM Futures Trade Download Link by Id API endpoint. It shows the structure for both completed and processing statuses, including download ID, status, and URL information. ```JSON { "downloadId":"545923594199212032", "status":"completed", // Enum:completed,processing "url":"www.binance.com", // The link is mapped to download id "s3Link": null, "notified":true, // ignore "expirationTimestamp":1645009771000, // The link would expire after this timestamp "isExpired":null } ``` ```JSON { "downloadId":"545923594199212032", "status":"processing", "url":"", "s3Link": null, "notified":false, "expirationTimestamp":-1, "isExpired":null } ``` -------------------------------- ### Binance API: Get Futures Transaction History Download ID Source: https://context7_llms Retrieves a download ID for asynchronous futures transaction history. This API requires start and end timestamps and is limited to 5 requests per month. The time range between start and end times cannot exceed one year. ```APIDOC API: Get Download Id For Futures Transaction History (USER_DATA) HTTP Request: GET /fapi/v1/income/asyn Request Weight: 1000 Parameters: - startTime (LONG, YES): Timestamp in ms. - endTime (LONG, YES): Timestamp in ms. - recvWindow (LONG, NO): Optional receive window. - timestamp (LONG, YES): Request timestamp. Limitations: - Request Limitation: 5 times per month (shared by front-end download page and REST API). - Time Range: The time between `startTime` and `endTime` cannot be longer than 1 year. Response Example: { "avgCostTimestampOfLast30d":7241837, "downloadId":"546975389218332672" } ```