Skip to content

Conversation

bennycode
Copy link
Contributor

Here is my PR with an initial definition for the methods accountInfo, order, prices & time to kick-off TypeScript support. To make sure that the definitions are correct, I checked original payload responses as well as the official Rest API for Binance (2017-12-01).

To be consistent with other Binance APIs, I synchronized the naming of the defined types with Binance's Java API:

The only thing were I have been unsure are the parameters used for price, stopPrice and icebergQty. The documentation here says that these are numbers (https://github.com/HyperCubeProject/binance-api-node#authenticated-rest-endpoints) but all other clients treat them as strings. I also guess these should be strings?

Here is an example on how this library can now be used with TypeScript:

import Binance, {Account, AssetBalance} from 'binance-api-node';

const client = Binance({
  apiKey: '...',
  apiSecret: '...',
});

client.accountInfo().then((info: Account) => {
  const balances: Array<AssetBalance> = info.balances;
  console.log(`Your account trades ${balances.length} assets.`);
});

Best from Berlin,
Benny

@coveralls
Copy link

Coverage Status

Coverage decreased (-17.6%) to 75.676% when pulling 1cf300f on bennyn:type-definitions into 6c1607b on HyperCubeProject:master.

@balthazar balthazar merged commit 80e42e4 into balthazar:master Jan 8, 2018
@balthazar
Copy link
Owner

This looks really good, thanks! Yeah I'm quite unsure about the price and stopPrice, this is what the binance docs were saying that I followed. Maybe even passing a sting is fine since they might do the casting on their side too. Merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants