npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

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

FTX.us Documentation

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

FTX.us Documentation

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

FTX.us Documentation

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