Skip to content

Commit

Permalink
Add apiPermission method. (ViewBlock#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
krolov authored Aug 31, 2021
1 parent 0b2d142 commit c9dcba8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Following examples will use the `await` form, which requires some configuration
- [accountCoins](#accountCoins)
- [lendingAccount](#lendingAccount)
- [fundingWallet](#fundingWallet)
- [apiPermission](#apiPermission)
- [Margin](#margin)
- [marginAccountInfo](#marginAccountInfo)
- [marginLoan](#marginLoan)
Expand Down Expand Up @@ -2303,8 +2304,8 @@ console.log(await client.fundingWallet())

| Param | Type | Required | Description |
| ---------- | -------- | -------- | ------------------- |
| asset | STRING | false |
| needBtcValuation | STRING | false | 'true' or 'false'
| asset | String | false |
| needBtcValuation | String | false | 'true' or 'false'

<details>
<summary>Output</summary>
Expand All @@ -2324,6 +2325,39 @@ console.log(await client.fundingWallet())

</details>

#### apiPermission

Get API Key Permission.

```js
console.log(await client.apiPermission())
```

| Param | Type | Required | Description |
| ---------- | -------- | -------- | ------------------- |
| recvWindow | Number | false |

<details>
<summary>Output</summary>

```js
{
"ipRestrict": false,
"createTime": 1623840271000,
"enableWithdrawals": false, // This option allows you to withdraw via API. You must apply the IP Access Restriction filter in order to withdrawals
"enableInternalTransfer": true, // This option authorizes this key to transfer funds between your master account and your sub account instantly
"permitsUniversalTransfer": true, // Authorizes this key to be used for a dedicated universal transfer API to transfer multiple supported currencies. Each business's own transfer API rights are not affected by this authorization
"enableVanillaOptions": false, // Authorizes this key to Vanilla options trading
"enableReading": true,
"enableFutures": false, // API Key created before your futures account opened does not support futures API service
"enableMargin": false, // This option can be adjusted after the Cross Margin account transfer is completed
"enableSpotAndMarginTrading": false, // Spot and margin trading
"tradingAuthorityExpirationTime": 1628985600000 // Expiration time for spot and margin trading permission
}
```

</details>

### Margin

#### marginAccountInfo
Expand Down
19 changes: 17 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ declare module 'binance-api-node' {
}

export interface SetBNBBurnOptions {
spotBNBBurn: boolean
interestBNBBurn: boolean
spotBNBBurn?: boolean | booleanString
interestBNBBurn?: boolean | booleanString
recvWindow?: number
}

Expand Down Expand Up @@ -340,6 +340,20 @@ declare module 'binance-api-node' {
CROSSED = 'CROSSED',
}

export interface ApiPermission {
ipRestrict: boolean,
createTime: number,
enableWithdrawals: boolean,
enableInternalTransfer: boolean,
permitsUniversalTransfer: boolean,
enableVanillaOptions: boolean,
enableReading: boolean,
enableFutures: boolean,
enableMargin: boolean,
enableSpotAndMarginTrading: boolean,
tradingAuthorityExpirationTime: number,
}

export interface Binance {
getInfo(): GetInfo
accountInfo(options?: { useServerTime: boolean }): Promise<Account>
Expand All @@ -356,6 +370,7 @@ declare module 'binance-api-node' {
exchangeInfo(): Promise<ExchangeInfo>
lendingAccount(options?: { useServerTime: boolean }): Promise<LendingAccount>
fundingWallet(options?: { asset?: string, needBtcValuation?: booleanString, useServerTime?: boolean }): Promise<FundingWallet[]>
apiPermission(options?: {recvWindow?: number}): Promise<ApiPermission>
order(options: NewOrderSpot): Promise<Order>
orderTest(options: NewOrderSpot): Promise<Order>
orderOco(options: NewOcoOrder): Promise<OcoOrder>
Expand Down
1 change: 1 addition & 0 deletions src/http-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,5 +449,6 @@ export default opts => {
futuresIncome: payload => privCall('/fapi/v1/income', payload),
lendingAccount: payload => privCall('/sapi/v1/lending/union/account', payload),
fundingWallet: payload => privCall('/sapi/v1/asset/get-funding-asset', payload, 'POST'),
apiPermission: payload => privCall('/sapi/v1/account/apiRestrictions', payload),
}
}

0 comments on commit c9dcba8

Please sign in to comment.