Skip to content

Commit 85b1419

Browse files
authored
Merge branch 'master' into snyk-upgrade-333a1872421e1c336a5456cca9c74648
2 parents 17bb4d9 + 22e670d commit 85b1419

18 files changed

+1489
-1118
lines changed

docs/endpointFunctionList.md

Lines changed: 345 additions & 338 deletions
Large diffs are not rendered by default.

examples/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Examples
22

33
These samples can be executed using `ts-node`:
4+
45
```
56
ts-node ./examples/rest-spot-public.ts
67
```
78

89
Samples that require authentication can be edited directly but also support environmental variables. E.g. on mac/unix:
10+
911
```
1012
API_KEY_COM='yourkeyhere' API_SECRET_COM='yoursecrethere' API_PASS_COM='yourapipasshere' ts-node examples/rest-trade-futures.ts
1113
```
@@ -19,7 +21,7 @@ These newer examples are for Bitget's V3 APIs and WebSockets. They can be found
1921
Refer to the V3 / UTA API documentation for more information on the V3 APIs:
2022
https://www.bitget.com/api-doc/uta/intro
2123

22-
These APIs require your account to be permanently upgraded to the Unified Trading Account, if you plan on using the account-level REST APIs and WebSockets. Once upgraded, the V2 APIs are no longer available to you.
24+
These APIs require your account to be upgraded to the Unified Trading Account, if you plan on using the account-level REST APIs and WebSockets. Once upgraded, the V2 APIs are no longer available to you, unless you revert back to Classic Account mode.
2325

2426
### WebSocket API (WS API)
2527

@@ -34,21 +36,19 @@ This integration looks & feels like a REST API client, but uses WebSockets, via
3436
This is the recommended approach to easily start sending orders via an automatically persisted WebSocket connection. A simple example is below, but for a more thorough example, check the example here: [./V3/ws-api-client-trade.ts](./V3/ws-api-client-trade.ts)
3537

3638
```typescript
37-
import { WebsocketAPIClient } from "bitget-api";
39+
import { WebsocketAPIClient } from 'bitget-api';
3840
// or if you prefer require:
3941
// const { WebsocketAPIClient } = require("bitget-api");
4042

4143
// Make an instance of the WS API Client class with your API keys
42-
const wsClient = new WebsocketAPIClient(
43-
{
44-
apiKey: API_KEY,
45-
apiSecret: API_SECRET,
46-
apiPass: API_PASS,
47-
48-
// Whether to use the demo trading wss connection
49-
// demoTrading: true,
50-
}
51-
);
44+
const wsClient = new WebsocketAPIClient({
45+
apiKey: API_KEY,
46+
apiSecret: API_SECRET,
47+
apiPass: API_PASS,
48+
49+
// Whether to use the demo trading wss connection
50+
// demoTrading: true,
51+
});
5252

5353
async function start() {
5454
// Start using it like a REST API. All actions are sent via a persisted WebSocket connection.
@@ -73,7 +73,7 @@ async function start() {
7373
}
7474
}
7575

76-
start().catch(e => console.error("Exception in example: ". e));
76+
start().catch((e) => console.error('Exception in example: '.e));
7777
```
7878

7979
#### ws.sendWSAPIRequest(wsKey, command, category, operation)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV2 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV2 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v2/spot/account/upgrade-status
9+
// METHOD: GET
10+
// PUBLIC: NO
11+
12+
const client = new RestClientV2({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.getUnifiedAccountSwitchStatus(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV2 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV2 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v2/spot/account/upgrade
9+
// METHOD: POST
10+
// PUBLIC: NO
11+
12+
const client = new RestClientV2({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.upgradeToUnifiedAccount(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV3 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV3 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v3/account/switch
9+
// METHOD: POST
10+
// PUBLIC: NO
11+
12+
const client = new RestClientV3({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.downgradeAccountToClassic(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV3 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV3 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v3/position/adlRank
9+
// METHOD: GET
10+
// PUBLIC: NO
11+
12+
const client = new RestClientV3({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.getPositionAdlRank(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV3 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV3 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v3/market/proof-of-reserves
9+
// METHOD: GET
10+
// PUBLIC: YES
11+
12+
const client = new RestClientV3({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.getProofOfReserves(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV3 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV3 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v3/account/switch-status
9+
// METHOD: GET
10+
// PUBLIC: NO
11+
12+
const client = new RestClientV3({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.getUnifiedAccountSwitchStatus(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});

examples/apidoc/RestClientV3/getWithdrawRecords.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RestClientV3 } from 'bitget-api';
55

66
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
77
// This Bitget API SDK is available on npm via "npm install bitget-api"
8-
// ENDPOINT: /api/v3/account/withdrawl-records
8+
// ENDPOINT: /api/v3/account/withdrawal-records
99
// METHOD: GET
1010
// PUBLIC: NO
1111

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RestClientV3 } from 'bitget-api';
2+
// or if you want to use the require syntax
3+
// const { RestClientV3 } = require('bitget-api');
4+
5+
6+
// This example shows how to call this Bitget API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "bitget-api" for Bitget exchange
7+
// This Bitget API SDK is available on npm via "npm install bitget-api"
8+
// ENDPOINT: /api/v3/account/deposit-account
9+
// METHOD: POST
10+
// PUBLIC: NO
11+
12+
const client = new RestClientV3({
13+
apiKey: 'insert_api_key_here',
14+
apiSecret: 'insert_api_secret_here',
15+
apiPass: 'insert_api_pass_here',
16+
});
17+
18+
client.setDepositAccount(params)
19+
.then((response) => {
20+
console.log(response);
21+
})
22+
.catch((error) => {
23+
console.error(error);
24+
});

0 commit comments

Comments
 (0)