Skip to content

Commit

Permalink
Add SubAccounts endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Treast committed Apr 29, 2021
1 parent babdbf3 commit 783b9e7
Show file tree
Hide file tree
Showing 11 changed files with 1,707 additions and 56 deletions.
62 changes: 32 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ An API wrapper for Binance. Build your application faster !

## Benefits

- Built with Typescript (autocomplete on request/response)
- Use native Promises
- Updated with the latest version
- Built with Typescript (autocomplete on request/response)
- Use native Promises
- Updated with the latest version

## Disclaimer

Expand All @@ -18,27 +18,28 @@ An API wrapper for Binance. Build your application faster !

## Installation

npm install binance.js --save
npm install binance.js --save

## Usage

### Node

```js
const { Binance } = require('binance.js');

const binance = new Binance.Api(API_KEY, TEST_SECRET_KEY, true); // 3rd parameter is testMode. Set explicitly to false if you want to use Live API.
const binance = new Binance.Api(API_KEY, TEST_SECRET_KEY, true); // 3rd parameter is testMode. Set explicitly to false if you want to use Live API.

binance
.spotAllOrders({
symbol: 'BTCUSDT',
})
.then((res) => {
console.log(res);
});
.spotAllOrders({
symbol: 'BTCUSDT',
})
.then((res) => {
console.log(res);
});
```

### Browser

```js
import { Binance } from 'binance.js';

Expand All @@ -58,33 +59,34 @@ binance
```
### Functions
All functions have the same name as described on the official documentation and are prefixed by the domain: [https://binance-docs.github.io/apidocs/](https://binance-docs.github.io/apidocs/).
**Example:** *Spot > New Order* becomes *spotNewOrder*
**Example:** _Spot > New Order_ becomes _spotNewOrder_
**Example:** *Savings > Purchase Fixed/Activity Project* becomes *savingsPurchaseFixedActivityProject*
**Example:** _Savings > Purchase Fixed/Activity Project_ becomes _savingsPurchaseFixedActivityProject_
### Streams
Stream functions return a *Websocket* instance from the *ws* package. A cache is set up to prevent opening a same stream twice.
Stream functions return a _Websocket_ instance from the _ws_ package. A cache is set up to prevent opening a same stream twice.
## Progress
- [x] API Structure
- [x] Wallet endpoints
- [x] Market endpoints
- [x] Spot endpoints
- [x] Margin endpoints
- [x] Saving endpoints
- [x] Futures endpoints
- [x] Streams
- [x] Mining endpoints
- [x] BLVT endpoints
- [x] BSwap endpoints
- [ ] Streams typings
- [ ] Sub-accounts endpoints
- [ ] Better error handling
- [x] API Structure
- [x] Wallet endpoints
- [x] Market endpoints
- [x] Spot endpoints
- [x] Margin endpoints
- [x] Saving endpoints
- [x] Futures endpoints
- [x] Streams
- [x] Mining endpoints
- [x] BLVT endpoints
- [x] BSwap endpoints
- [x] Sub-accounts endpoints
- [ ] Streams typings
- [ ] Better error handling
## License
[MIT License](LICENSE)
[MIT License](LICENSE)
45 changes: 45 additions & 0 deletions dist/Binance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,42 @@ export declare namespace Binance {
bSwapRequestQuote: (this: Api, params: import("./lib/BSwap").IBSwapRequestQuoteParameters) => Promise<import("./lib/BSwap").IBSwapRequestQuote>;
bSwapSwap: (this: Api, params: import("./lib/BSwap").IBSwapSwapParameters) => Promise<import("./lib/BSwap").IBSwapSwap>;
bSwapGetSwapHistory: (this: Api, params?: import("./lib/BSwap").IBSwapGetSwapHistoryParameters) => Promise<import("./lib/BSwap").IBSwapGetSwapHistory[]>;
/** SubAccounts endpoints */
subAccountsList: (this: Api) => Promise<import("./lib/SubAccount").ISubAccountsList>;
subAccountsTransferHistory: (this: Api) => Promise<import("./lib/SubAccount").ISubAccountsList>;
subAccountsAssets: (this: Api) => Promise<import("./lib/SubAccount").ISubAccountsAssets>;
subAccountsCreateVirtualSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsCreateVirtualSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsCreateVirtualSubAccount>;
subAccountsQuerySubAccountListSAPI: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountListSAPIParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountListSAPI>;
subAccountsQuerySubAccountList: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountListParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountList>;
subAccountsQuerySubAccountSpotAssetTransferHistory: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountSpotAssetTransferHistoryParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountSpotAssetTransferHistory>;
subAccountsQuerySubAccountSpotAssetTransferHistorySAPI: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountSpotAssetTransferHistorySAPIParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountSpotAssetTransferHistoryItem[]>;
subAccountsSubAccountSpotAssetTransfer: (this: Api, params: import("./lib/SubAccount").ISubAccountsSubAccountSpotAssetTransferParameters) => Promise<import("./lib/SubAccount").ISubAccountsSubAccountSpotAssetTransfer>;
subAccountsQuerySubAccountFuturesAssetTransferHistory: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountFuturesAssetTransferHistoryParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountFuturesAssetTransferHistory>;
subAccountsSubAccountFuturesAssetTransfer: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountFuturesAssetTransferHistoryParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountFuturesAssetTransferHistory>;
subAccountsQuerySubAccountsAssets: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountAssetsParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountAssets>;
subAccountsQuerySubAccountsAssetsSAPI: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountAssetsSAPIParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountAssetsSAPI>;
subAccountsQuerySubAccountSpotAssetsSummary: (this: Api, params: import("./lib/SubAccount").ISubAccountsQuerySubAccountSpotAssetsSummaryParameters) => Promise<import("./lib/SubAccount").ISubAccountsQuerySubAccountSpotAssetsSummary>;
subAccountsGetSubAccountDepositAddress: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetSubAccountDepositAddressParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetSubAccountDepositAddress>;
subAccountsGetSubAccountDepositHistory: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetSubAccountDepositAddressHistoryParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetSubAccountDepositAddressHistory[]>;
subAccountsGetSubAccountStatusMarginFutures: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetSubAccountStatusMarginFuturesParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetSubAccountStatusMarginFutures[]>;
subAccountsEnableMarginSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsEnableMarginSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsEnableMarginSubAccount>;
subAccountsGetDetailSubAccountMarginAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetDetailSubAccountMarginAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetDetailSubAccountMarginAccount>;
subAccountsGetSummarySubAccountMarginAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetSummarySubAccountMarginAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetSummarySubAccountMarginAccount>;
subAccountsEnableFuturesSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsEnableFuturesSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsEnableFuturesSubAccount>;
subAccountsGetDetailSubAccountFuturesAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetDetailSubAccountFuturesAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetDetailSubAccountFuturesAccount>;
subAccountsGetSummarySubAccountFuturesAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetSummarySubAccountFuturesAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetSummarySubAccountFuturesAccount>;
subAccountsGetFuturesPositionRiskSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetFuturesPositionRiskSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsGetFuturesPositionRiskSubAccount[]>;
subAccountsFuturesTransferSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsFuturesTransferSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsFuturesTransferSubAccount>;
subAccountsMarginTransferSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsMarginTransferSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsMarginTransferSubAccount>;
subAccountsTransferSubAccountSameMaster: (this: Api, params: import("./lib/SubAccount").ISubAccountsTransferSubAccountSameMasterParameters) => Promise<import("./lib/SubAccount").ISubAccountsTransferSubAccountSameMaster>;
subAccountsTransferToMaster: (this: Api, params: import("./lib/SubAccount").ISubAccountsTransferToMasterParameters) => Promise<import("./lib/SubAccount").ISubAccountsTransferToMaster>;
subAccountsSubAccountTransferHistory: (this: Api, params: import("./lib/SubAccount").ISubAccountsSubAccountTransferHistoryParameters) => Promise<import("./lib/SubAccount").ISubAccountsSubAccountTransferHistory[]>;
subAccountsUniversalTransfer: (this: Api) => Promise<import("./lib/SubAccount").ISubAccountsList>;
subAccountsQueryUniversalTransferHistory: (this: Api, params: import("./lib/SubAccount").ISubAccountsQueryUniversalTransferHistoryParameters) => Promise<import("./lib/SubAccount").ISubAccountsQueryUniversalTransferHistory[]>;
subAccountsGetDetailSubAccountFuturesAccountV2: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetDetailSubAccountFuturesAccountV2Parameters) => Promise<import("./lib/SubAccount").ISubAccountsGetDetailSubAccountFuturesAccountV2>;
subAccountsGetSummarySubAccountFuturesAccountV2: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetSummarySubAccountFuturesAccountV2Parameters) => Promise<import("./lib/SubAccount").ISubAccountsGetSummarySubAccountFuturesAccountV2>;
subAccountsGetFuturesPositionRiskSubAccountV2: (this: Api, params: import("./lib/SubAccount").ISubAccountsGetFuturesPositionRiskSubAccountV2Parameters) => Promise<import("./lib/SubAccount").ISubAccountsGetFuturesPositionRiskSubAccountV2>;
subAccountsEnableLeverageTokenSubAccount: (this: Api, params: import("./lib/SubAccount").ISubAccountsEnableLeverageTokenSubAccountParameters) => Promise<import("./lib/SubAccount").ISubAccountsEnableLeverageTokenSubAccount>;
}
interface IRequest {
headers: IRequestHeaders;
Expand Down Expand Up @@ -268,4 +304,13 @@ export declare namespace Binance {
FROM_SPOT_TO_COINFUTURS = 3,
FROM_COINFUTURES_TO_SPOT = 4
}
enum EAccountType {
SPOT = "SPOT",
USDT_FUTURE = "USDT_FUTURE",
COIN_FUTURE = "COIN_FUTURE"
}
enum ESubAccountFuturesType {
USDT = 1,
COIN = 2
}
}
48 changes: 48 additions & 0 deletions dist/Binance.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 783b9e7

Please sign in to comment.