ftx-us
v1.0.5
Published
FTX US API client
Downloads
2
Readme
FTX US JavaScript Client
An API Client for FTX.us.
Motivation
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.
Installation
npm i ftx-us
Example Usage
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);
})();
Methods
Wallet
getCoins()
await FTXUS.Wallet.getCoins();
getBalances()
await FTXUS.Wallet.getBalances();
getDepositAddress()
await FTXUS.Wallet.getDepositAddress();
getDepositHistory()
await FTXUS.Wallet.getDepositHistory();
getWithdrawlHistory()
await FTXUS.Wallet.getWithdrawalHistory();
requestWithdrawl()
await FTXUS.Wallet.requestWithdrawal();
Markets
list() (Get markets)
await FTXUS.Markets.list();
get() (Get single market)
// Get market data for a given coin
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.BTC.USD; // 'BTC/USD'
await FTXUS.Markets.get(marketName);
getOrderBook()
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.ETH.USDT; // 'ETH/USDT'
await FTXUS.Markets.getOrderBook(marketName);
getTrades()
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);
Orders
getOpenOrders()
await FTXUS.Orders.getOpenOrders();
getHistory()
const { currencyPairs } = require('ftx-us');
const marketName = currencyPairs.BTC.USD;
const opts = { startTime: 1559881511, endTime: 1559901511, limit: 100 }
await FTXUS.Orders.getHistory(marketName, opts);
canelAllOrders()
await FTXUS.Orders.cancelAllOrders();
Troubleshooting
Can't authorize
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.
TODO
Currently the client uses Axios.js to make HTTP requests. I will be replacing this with the native Node.js HTTP client