Skip to content

Commit

Permalink
feat(): added new endpoints, updated existing endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Cro committed Oct 3, 2024
1 parent 5edf4f2 commit 82b0f70
Showing 5 changed files with 99 additions and 15 deletions.
21 changes: 9 additions & 12 deletions docs/endpointFunctionList.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@

# Endpoint maps

<p align="center">
<a href="https://www.npmjs.com/package/bitmart-api">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/tiagosiebler/bitmart-api/blob/master/docs/images/logoDarkMode2.svg?raw=true#gh-dark-mode-only">
<img alt="SDK Logo" src="https://github.com/tiagosiebler/bitmart-api/blob/master/docs/images/logoBrightMode2.svg?raw=true#gh-light-mode-only">
</picture>
</a>
</p>
[![connector logo](https://github.com/tiagosiebler/bitmart-api/blob/master/docs/images/logo1.png?raw=true)][1]

Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.
Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.

The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.

@@ -45,7 +38,7 @@ Table consists of 4 parts:

# RestClient.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [RestClient.ts](/src/RestClient.ts).
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [RestClient.ts](/src/RestClient.ts).

| Function | AUTH | HTTP Method | Endpoint |
| -------- | :------: | :------: | -------- |
@@ -138,7 +131,7 @@ This table includes all endpoints from the official Exchange API docs and corres

# FuturesClientV2.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [FuturesClientV2.ts](/src/FuturesClientV2.ts).
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in [FuturesClientV2.ts](/src/FuturesClientV2.ts).

| Function | AUTH | HTTP Method | Endpoint |
| -------- | :------: | :------: | -------- |
@@ -165,11 +158,15 @@ This table includes all endpoints from the official Exchange API docs and corres
| `cancelFuturesPlanOrder()` | :closed_lock_with_key: | POST | `contract/private/cancel-plan-order` |
| `submitFuturesTransfer()` | :closed_lock_with_key: | POST | `account/v1/transfer-contract` |
| `setFuturesLeverage()` | :closed_lock_with_key: | POST | `contract/private/submit-leverage` |
| `submitFuturesTPSLOrder()` | :closed_lock_with_key: | POST | `contract/private/submit-tp-sl-order` |
| `updateFuturesPlanOrder()` | :closed_lock_with_key: | POST | `contract/private/modify-plan-order` |
| `updateFuturesPresetPlanOrder()` | :closed_lock_with_key: | POST | `contract/private/modify-preset-plan-order` |
| `updateFuturesTPSLOrder()` | :closed_lock_with_key: | POST | `contract/private/modify-tp-sl-order` |
| `submitFuturesSubToMainTransferFromMain()` | :closed_lock_with_key: | POST | `account/contract/sub-account/main/v1/sub-to-main` |
| `submitFuturesMainToSubTransferFromMain()` | :closed_lock_with_key: | POST | `account/contract/sub-account/main/v1/main-to-sub` |
| `submitFuturesSubToMainSubFromSub()` | :closed_lock_with_key: | POST | `account/contract/sub-account/sub/v1/sub-to-main` |
| `getFuturesSubWallet()` | :closed_lock_with_key: | GET | `account/contract/sub-account/main/v1/wallet` |
| `getFuturesSubTransfers()` | :closed_lock_with_key: | GET | `account/contract/sub-account/main/v1/transfer-list` |
| `getFuturesSubTransferHistory()` | :closed_lock_with_key: | GET | `account/contract/sub-account/v1/transfer-history` |
| `getFuturesAffiliateRebates()` | :closed_lock_with_key: | GET | `contract/private/affiliate/rebate-list` |
| `getFuturesAffiliateTrades()` | :closed_lock_with_key: | GET | `contract/private/affiliate/trade-list` |
| `getFuturesAffiliateTrades()` | :closed_lock_with_key: | GET | `contract/private/affiliate/trade-list` |
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitmart-api",
"version": "2.1.4",
"version": "2.1.5",
"description": "Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.",
"scripts": {
"clean": "rm -rf dist/*",
42 changes: 42 additions & 0 deletions src/FuturesClientV2.ts
Original file line number Diff line number Diff line change
@@ -22,8 +22,12 @@ import {
SubmitFuturesOrderRequest,
SubmitFuturesPlanOrderRequest,
SubmitFuturesSubToMainSubFromSubRequest,
SubmitFuturesTPSLOrderRequest,
SubmitFuturesTransferRequest,
TransferFuturesAssetsRequest,
UpdateFuturesPlanOrderRequest,
UpdateFuturesPresetPlanOrderRequest,
UpdateFuturesTPSLOrderRequest,
} from './types/request/futures.types.js';
import {
FuturesAccountAsset,
@@ -241,6 +245,44 @@ export class FuturesClientV2 extends BaseRestClient {
return this.postPrivate('contract/private/submit-leverage', params);
}

submitFuturesTPSLOrder(params: SubmitFuturesTPSLOrderRequest): Promise<
APIResponse<{
order_id: string;
client_order_id?: string;
}>
> {
return this.postPrivate('contract/private/submit-tp-sl-order', params);
}

updateFuturesPlanOrder(params: UpdateFuturesPlanOrderRequest): Promise<
APIResponse<{
order_id: string;
}>
> {
return this.postPrivate('contract/private/modify-plan-order', params);
}

updateFuturesPresetPlanOrder(
params: UpdateFuturesPresetPlanOrderRequest,
): Promise<
APIResponse<{
order_id: string;
}>
> {
return this.postPrivate(
'contract/private/modify-preset-plan-order',
params,
);
}

updateFuturesTPSLOrder(params: UpdateFuturesTPSLOrderRequest): Promise<
APIResponse<{
order_id: string;
}>
> {
return this.postPrivate('contract/private/modify-tp-sl-order', params);
}

/**
*
* Futures Sub-Account Endpoints
45 changes: 45 additions & 0 deletions src/types/request/futures.types.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ export interface FuturesKlinesRequest {
export interface FuturesAccountOrderRequest {
symbol: string;
order_id: string;
client_order_id?: string;
}

export interface FuturesAccountHistoricOrderRequest {
@@ -27,6 +28,7 @@ export interface FuturesAccountPlanOrdersRequest {
symbol?: string;
type?: 'limit' | 'market';
limit?: number;
plan_type?: 'plan' | 'profit_loss';
}

export interface FuturesAccountTradesRequest {
@@ -137,3 +139,46 @@ export interface FuturesAffiliateTradesRequest {
start_time: number;
end_time: number;
}

export interface SubmitFuturesTPSLOrderRequest {
symbol: string;
type: 'take_profit' | 'stop_loss';
side: 2 | 3;
size?: number;
trigger_price: string;
executive_price: string;
price_type: 1 | 2;
plan_category?: 1 | 2;
client_order_id?: string;
category?: 'limit' | 'market';
}

export interface UpdateFuturesPlanOrderRequest {
symbol: string;
order_id?: string;
client_order_id?: string;
trigger_price: string;
executive_price?: string;
price_type: 1 | 2;
type: 'limit' | 'market';
}

export interface UpdateFuturesPresetPlanOrderRequest {
order_id: string;
symbol: string;
preset_take_profit_price_type?: 1 | 2;
preset_stop_loss_price_type?: 1 | 2;
preset_take_profit_price?: string;
preset_stop_loss_price?: string;
}

export interface UpdateFuturesTPSLOrderRequest {
symbol: string;
order_id?: string;
client_order_id?: string;
trigger_price: string;
executive_price?: string;
price_type: 1 | 2;
plan_category?: 1 | 2;
category?: 'limit' | 'market';
}

0 comments on commit 82b0f70

Please sign in to comment.