An API Client for FTX.us.
I haven't seen many Node.js implementations of the FTX API client and wanted to build one that worked specifically with FTX.us. I haven't looked into it yet, but I assume that both FTX APIs are equivalent so you should be able to switch the client URL and HTTP headers to the regular FTX values and it will work the same. At some pont there will be an option to simply point this client at either address.
npm i ftx-us
const { FTXUS } = require('ftx-us');
// Retrieve secrets if authenticating
const apiKey = process.env.FTX_API_KEY;
const apiSecret = process.env.FTX_API_SECRET;
const ftxUS = new FTXUS({ key: apiKey, secret: apiSecret });
(async () => {
// Get all markets
const markets = await ftxUS.Markets.list();
console.log(markets);
})();
await FTXUS.Wallet.getCoins();
await FTXUS.Wallet.getBalances();
await FTXUS.Wallet.getDepositAddress();
await FTXUS.Wallet.getDepositHistory();
await FTXUS.Wallet.getWithdrawalHistory();
await FTXUS.Wallet.requestWithdrawal();
await FTXUS.Markets.list();
// Get market data for a given coin
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.BTC.USD; // 'BTC/USD'
await FTXUS.Markets.get(marketName);
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.ETH.USDT; // 'ETH/USDT'
await FTXUS.Markets.getOrderBook(marketName);
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.BTC.USD; // 'BTC/USD'
const optionalParameters = {
startTime: '1559881511',
endTime: '1559881711',
limit: 50
};
await FTXUS.Markets.getTrades(marketName, optionalParameters);
await FTXUS.Orders.getOpenOrders();
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.BTC.USD;
const opts = { startTime: 1559881511, endTime: 1559901511, limit: 100 }
await FTXUS.Orders.getHistory(marketName, opts);
await FTXUS.Orders.cancelAllOrders();
If you cannot authorize, you should ensure that you're api key and secret is correct. You should also make sure that your computer clock is synced correctly. If you're computer clock is out of sync, the timestamp created for the signature header will be incorrect.
Currently the client uses Axios.js to make HTTP requests. I will be replacing this with the native Node.js HTTP client