Skip to content

Commit

Permalink
Merge pull request #56 from fireflies1988/feature/add-demo-trading-op…
Browse files Browse the repository at this point in the history
…tion

feat(v2.3.1): add demoTrading flag to REST Client for demo mode support
  • Loading branch information
tiagosiebler authored Feb 9, 2025
2 parents 59824c2 + 2c074b2 commit 8e35d6e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitget-api",
"version": "2.3.0",
"version": "2.3.1",
"description": "Node.js & JavaScript SDK for Bitget REST APIs & WebSockets, with TypeScript & end-to-end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/rest-client-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ export class RestClientV2 extends BaseRestClient {
}

getFuturesContractConfig(params: {
symbol: string;
symbol?: string;
productType: FuturesProductTypeV2;
}): Promise<APIResponse<FuturesContractConfigV2[]>> {
return this.get('/api/v2/mix/market/contracts', params);
Expand Down
1 change: 1 addition & 0 deletions src/util/BaseRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default abstract class BaseRestClient {
'X-CHANNEL-API-CODE': 'hbnni',
'Content-Type': 'application/json',
locale: 'en-US',
...(restOptions.demoTrading ? { paptrading: '1' } : {}),
},
};

Expand Down
7 changes: 7 additions & 0 deletions src/util/requestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export interface RestClientOptions {
/** Set to `true` to connect to testnet. Uses the live environment by default. */
// testnet?: boolean;

/**
* Set to `true` to use Bitget's demo trading: https://www.bitget.com/api-doc/common/demotrading/restapi.
*
* Disabled by default.
*/
demoTrading?: boolean;

/** Override the max size of the request window (in ms) */
recvWindow?: number;

Expand Down

0 comments on commit 8e35d6e

Please sign in to comment.