### Installing Foxbit API Package - Bash Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This snippet shows the command-line instruction to install the foxbit-api package into your project using npm. The '--save' flag adds the package as a dependency in your package.json file. ```bash npm i foxbit-api --save ``` -------------------------------- ### Fetching All Products after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This example demonstrates fetching a list of all registered products (currencies) using the `GetProducts` method. The call is triggered by the `Connected` event, and the array of products is logged upon receiving the `GetProducts` event. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetProducts. foxbit.GetProducts(); }); // Evento disparado quando o GetProducts foi efetuado. foxbit.eventEmitter.on("GetProducts", res => { console.log(res); }); ``` -------------------------------- ### Connecting to Foxbit WebSocket API - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This example illustrates how to initiate a connection to the Foxbit WebSocket API using the 'Connect' function. It also includes setting up an event listener for the 'Connected' event to confirm successful connection. ```javascript // Variáveis das suas credenciais // Necessárias somente para métodos privados. let user = ""; let password = ""; // Dispara chamada para conectar com o WebSocket. foxbit.Connect(user, password); // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { console.log(res); }); ``` -------------------------------- ### Importing Foxbit API Package - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This code demonstrates how to import the installed 'foxbit-api' package into your JavaScript application using the 'require' function, making its functions available for use. ```javascript const foxbit = require("foxbit-api"); ``` -------------------------------- ### GetAccountInfo - Foxbit WebSocket API - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Retrieves information about the logged-in user's account. The example shows how to call the method after the WebSocket is ready and listen for the response event. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada CancelOrder. foxbit.GetAccountInfo(); }); // Evento disparado quando o GetAccountInfo foi efetuado. foxbit.eventEmitter.on("GetAccountInfo", res => { console.log(res); }); ``` -------------------------------- ### GetAccountPositions - Foxbit WebSocket API - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Retrieves an array containing the user's balance information. The example shows how to call the method after the WebSocket is ready and listen for the response event. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada GetAccountPositions. foxbit.GetAccountPositions(); }); // Evento disparado quando o GetAccountPositions foi efetuado. foxbit.eventEmitter.on("GetAccountPositions", res => { console.log(res); }); ``` -------------------------------- ### Fetching All Instruments after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This example shows how to retrieve a list of all registered currency pairs using the `GetInstruments` method after the WebSocket connection is active. It sets up listeners for both the connection event and the `GetInstruments` response event to log the array of instruments. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetInstruments. foxbit.GetInstruments(); }); // Evento disparado quando o GetInstruments foi efetuado. foxbit.eventEmitter.on("GetInstruments", res => { console.log(res); }); ``` -------------------------------- ### Getting User Config Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Demonstrates how to fetch user-defined configurations via the Foxbit API WebSocket. This private method is called when the WebSocket is 'Ready' (connected and user info received), and the response is processed by the 'GetUserConfig' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada GetUserConfig. foxbit.GetUserConfig(); }); // Evento disparado quando o GetUserConfig foi efetuado. foxbit.eventEmitter.on("GetUserConfig", res => { console.log(res); }); ``` -------------------------------- ### GetAccountTransactions - Foxbit WebSocket API - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Retrieves an array containing the user's open transaction history. The example shows how to call the method after the WebSocket is ready and listen for the response event. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada GetAccountTransactions. foxbit.GetAccountTransactions(); }); // Evento disparado quando o GetAccountTransactions foi efetuado. foxbit.eventEmitter.on("GetAccountTransactions", res => { console.log(res); }); ``` -------------------------------- ### Subscribing to Trade Updates after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This example demonstrates subscribing to real-time trade updates using the `SubscribeTrades` method. The subscription is initiated upon successful WebSocket connection. It logs the subscription confirmation via `SubscribeTrades` and logs individual trade events via the `TradeDataUpdateEvent`. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada SubscribeTrades. foxbit.SubscribeTrades(); }); // Evento disparado quando o SubscribeTrades foi efetuado. foxbit.eventEmitter.on("SubscribeTrades", res => { console.log(res); }); // Evento disparado quando alguma Trade foi efetuada. foxbit.eventEmitter.on("TradeDataUpdateEvent", res => { console.log(res); }); ``` -------------------------------- ### GetAccountTrades - Foxbit WebSocket API - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Retrieves an array containing the user's executed order history. The example shows how to call the method after the WebSocket is ready and listen for the response event. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada GetAccountTrades. foxbit.GetAccountTrades(); }); // Evento disparado quando o GetAccountTrades foi efetuado. foxbit.eventEmitter.on("GetAccountTrades", res => { console.log(res); }); ``` -------------------------------- ### Fetching Ticker History after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This example demonstrates fetching historical ticker data for a specified duration (60 minutes) using the `GetTickerHistory` method. The call is made upon successful connection, and the historical data is logged when the `GetTickerHistory` event is triggered. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { //Variável de parametrização let lastMinutes = 60; // Dispara chamada GetTickerHistory. foxbit.GetTickerHistory(lastMinutes); }); // Evento disparado quando o GetTickerHistory foi efetuado. foxbit.eventEmitter.on("GetTickerHistory", res => { console.log(res); }); ``` -------------------------------- ### Getting User Permissions Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Shows how to retrieve the permissions associated with the authenticated user on the Foxbit API WebSocket. The call is made upon the 'Ready' event and the result is handled by the 'GetUserPermissions' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada GetUserPermissions(); foxbit.GetUserPermissions(); }); // Evento disparado quando o GetUserPermissions foi efetuado. foxbit.eventEmitter.on("GetUserPermissions", res => { console.log(res); }); ``` -------------------------------- ### Getting Orders History Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Explains how to retrieve the historical list of orders for the authenticated user via the Foxbit API WebSocket. This private method is invoked when the WebSocket is 'Ready', and the historical data is received through the 'GetOrdersHistory' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada GetOrdersHistory. foxbit.GetOrdersHistory(); }); // Evento disparado quando o GetOrdersHistory foi efetuado. foxbit.eventEmitter.on("GetOrdersHistory", res => { console.log(res); }); ``` -------------------------------- ### Getting User Info Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Explains how to retrieve user information using the Foxbit API WebSocket. This private method call is typically made after the WebSocket is connected, triggered by the 'Connected' event, and the result is handled by the 'GetUserInfo' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetUserInfo. foxbit.GetUserInfo(); }); // Evento disparado quando o GetUserInfo foi efetuado. foxbit.eventEmitter.on("GetUserInfo", res => { console.log(res); }); ``` -------------------------------- ### Sending Order Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Demonstrates how to place a new buy or sell order (e.g., Limit, Market) on the Foxbit API WebSocket. This private method requires parameters like side, type, quantity, and price, is called on the 'Ready' event, and the order confirmation is received via the 'SendOrder' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Variáveis de parametrização let Side = "Sell"; // Buy, Sell // Market, Limit, StopMarket, StopLimit, TralingStopMarket, TrailingStopLimit, BlockTrade let OrderType = "Limit"; let Quantity = 0.0001; // BTC let Price = 40000; // BRL // Dispara chamada SendOrder. foxbit.SendOrder(Side, OrderType, Quantity, Price); }); // Evento disparado quando o SendOrder foi efetuado. foxbit.eventEmitter.on("SendOrder", res => { console.log(res); }); ``` -------------------------------- ### Calling GetProducts after Connection (under GetOpenOrders heading) - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Presented under the 'GetOpenOrders' heading, this code snippet actually demonstrates calling the `GetProducts` method after the WebSocket connection is established. It listens for the `Connected` event to initiate the call and the `GetProducts` event to log the returned product data. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetProducts. foxbit.GetProducts(); }); // Evento disparado quando o GetProducts foi efetuado. foxbit.eventEmitter.on("GetProducts", res => { console.log(res); }); ``` -------------------------------- ### Fetching Product Data by ID after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This snippet illustrates how to fetch details for a specific product (currency) by its ID using the `GetProduct` method. The call is made upon successful WebSocket connection, and the response for the specified product ID (1 in this case) is logged when the `GetProduct` event occurs. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetProduct. foxbit.GetProduct(1); }); // Evento disparado quando o GetProduct foi efetuado. foxbit.eventEmitter.on("GetProduct", res => { console.log(res); }); ``` -------------------------------- ### Fetching Instrument Data after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This snippet demonstrates how to call the `GetInstrument` method on the Foxbit WebSocket client after a successful connection is established. It listens for the `Connected` event to trigger the call and the `GetInstrument` event to log the returned instrument data. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetInstrument. foxbit.GetInstrument(); }); // Evento disparado quando o GetInstrument foi efetuado. foxbit.eventEmitter.on("GetInstrument", res => { console.log(res); }); ``` -------------------------------- ### Subscribing to Ticker Updates after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This snippet shows how to subscribe to real-time ticker updates for a specific instrument (ID 1) using the `SubscribeTicker` method. It listens for the `Connected` event to subscribe, logs the subscription confirmation via `SubscribeTicker`, and logs subsequent updates via the `TickerDataUpdateEvent`. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada SubscribeTicker. foxbit.SubscribeTicker(1); }); // Evento disparado quando o SubscribeTicker foi efetuado. foxbit.eventEmitter.on("SubscribeTicker", res => { console.log(res); }); // Evento disparado quando o Ticker é atualizado. foxbit.eventEmitter.on("TickerDataUpdateEvent", res => { console.log(res); }); ``` -------------------------------- ### Canceling All Orders Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Shows how to cancel all open orders for the authenticated user using the Foxbit API WebSocket. This private method is triggered by the 'Ready' event, and the confirmation is received via the 'CancelAllOrders' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Dispara chamada CancelAllOrders. foxbit.CancelAllOrders(); }); // Evento disparado quando o CancelAllOrders foi efetuado. foxbit.eventEmitter.on("CancelAllOrders", res => { console.log(res); }); ``` -------------------------------- ### Fetching Orderbook Snapshot after Connection - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This snippet shows how to request a snapshot of the order book (Level 2 data) for a specific instrument (ID 100) using the `GetL2Snapshot` method. The request is sent after the WebSocket connects, and the snapshot data is logged when the `GetL2Snapshot` event is received. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada GetL2Snapshot. foxbit.GetL2Snapshot(100); }); // Evento disparado quando o GetL2Snapshot foi efetuado. foxbit.eventEmitter.on("GetL2Snapshot", res => { console.log(res); }); ``` -------------------------------- ### Canceling Specific Order Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Explains how to cancel a specific open order using its ClientOrderId or orderId via the Foxbit API WebSocket. This private method requires order identifiers, is called on the 'Ready' event, and the cancellation confirmation is received via the 'CancelOrder' event. Requires authentication. ```javascript // Evento disparado quando o WebSocket foi conectado // e recebeu as informações do usuário. foxbit.eventEmitter.on("Ready", res => { // Variáveis de Parametrização let ClientOrderId = 11111; let orderId = 9999; // Dispara chamada CancelOrder. foxbit.CancelOrder(ClientOrderId, orderId); }); // Evento disparado quando o CancelOrder foi efetuado. foxbit.eventEmitter.on("CancelOrder", res => { console.log(res); }); ``` -------------------------------- ### Unsubscribing Trades Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Shows how to unsubscribe from the Trades feed via the Foxbit API WebSocket. The process is initiated upon the 'Connected' event and confirmed by the 'UnsubscribeTrades' event. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada UnsubscribeTrades. foxbit.UnsubscribeTrades(); }); // Evento disparado quando o UnsubscribeTrades foi efetuado. foxbit.eventEmitter.on("UnsubscribeTrades", res => { console.log(res); }); ``` -------------------------------- ### Logging Out from Foxbit WebSocket API - JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md This snippet shows how to terminate the WebSocket connection using the 'LogOut' function. It also includes an event listener for the 'LogOut' event, which is triggered upon successful disconnection. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada LogOut. foxbit.LogOut(); }); // Evento disparado quando o LogOut foi efetuado. foxbit.eventEmitter.on("LogOut", res => { console.log(res); }); ``` -------------------------------- ### Unsubscribing Ticker Foxbit API JavaScript Source: https://github.com/foxbit-group/foxbit-api/blob/master/README.md Demonstrates how to unsubscribe from the Ticker feed on the Foxbit API WebSocket. This action is triggered by the 'Connected' event and confirmed by the 'UnsubscribeTicker' event. ```javascript // Evento disparado quando o WebSocket foi conectado. foxbit.eventEmitter.on("Connected", res => { // Dispara chamada UnsubscribeTicker. foxbit.UnsubscribeTicker(); }); // Evento disparado quando o UnsubscribeTicker foi efetuado. foxbit.eventEmitter.on("UnsubscribeTicker", res => { console.log(res); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.