Skip to content

Latest commit

 

History

History
341 lines (228 loc) · 26.2 KB

File metadata and controls

341 lines (228 loc) · 26.2 KB

AssetswapApi

All URIs are relative to https://api.gateio.ws/api/v4

Method HTTP request Description
listAssetSwapAssets GET /asset-swap/asset/list Portfolio optimization — currency list
getAssetSwapConfig GET /asset-swap/config Portfolio optimization — configuration
evaluateAssetSwap GET /asset-swap/evaluate Portfolio optimization — valuation
createAssetSwapOrderV1 POST /asset-swap/order/create Portfolio optimization — place order
listAssetSwapOrdersV1 GET /asset-swap/order/list Portfolio optimization — order list
previewAssetSwapOrderV1 POST /asset-swap/order/preview Portfolio optimization — preview
getAssetSwapOrderV1 GET /asset-swap/order/{order_id} Portfolio optimization — query order

listAssetSwapAssets

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapListAssets; }> listAssetSwapAssets()

Portfolio optimization — currency list

Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
api.listAssetSwapAssets()
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapListAssets; }> ApiResponseAssetSwapListAssets

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getAssetSwapConfig

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapConfig; }> getAssetSwapConfig()

Portfolio optimization — configuration

Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
api.getAssetSwapConfig()
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapConfig; }> ApiResponseAssetSwapConfig

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

evaluateAssetSwap

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapEvaluate; }> evaluateAssetSwap(opts)

Portfolio optimization — valuation

Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
const opts = {
  'maxEvaluateValue': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'cursor': "cursor_example", // string | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'size': 56 // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
};
api.evaluateAssetSwap(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
maxEvaluateValue number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
cursor string Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
size number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapEvaluate; }> ApiResponseAssetSwapEvaluate

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

createAssetSwapOrderV1

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapOrderCreateV1; }> createAssetSwapOrderV1(orderCreateV1Req)

Portfolio optimization — place order

将账户内若干源币种按指定数量换入目标币种侧配置,正式下单前强烈建议先调用 `POST /asset-swap/order/preview` 且 `code=0` 后再用一致的语义提交本接口请求体不含 `ratio` - 本接口 `OrderCreateV1Req` 仅含 `from` / `to`,且数组元素均为 `CreateParam`( `asset` + `amount`)。请勿在下单 JSON 中传入 `ratio`;比例字段 `ratio` 只存在于预览接口 `OrderPreviewV1Req.to`(`PreviewToParam`)。 与预览接口的关键差异(易错点) - 本接口 `to` 数组元素为 `CreateParam`:`asset` + `amount`(目标侧数量,十进制字符串)。 - 预览接口 `to` 为 `asset` + `ratio`(比例字符串)二者不可混用:不要把预览里的 `ratio` 原样填到下单的 `amount`,也不要把下单的 `amount` 当成预览的 `ratio`。 推荐调用顺序 1. `GET /asset-swap/asset/list`:确认币种支持。 2. `GET /asset-swap/config`:读取 `recommend` / `recommend_v2`(如 `recommend_v2.market` 下某策略的 `schemes`,将 `scheme.name` 作为目标 `asset`、`scheme.ratio` 仅用于 preview 的 `to[].ratio`)。 3. `GET /asset-swap/evaluate`(可选):参考可卖数量。 4. `POST /asset-swap/order/preview`:`from` 与 `to`(比例)构造询价。 5. 预览成功后,按产品/服务端约定将预览结果映射为下单的 `from`/`to`(均为 amount)再调用本接口。 字段约定 - `from`:卖出侧,每项为 `asset` + `amount`(字符串,十进制,表示该币种卖出数量)。 - `to`:买入/目标侧,每项为 `asset` + `amount`(字符串,十进制,表示该目标币种侧数量;语义与预览的 `ratio` 不同)。 - 本接口仅校验上述 `amount` 的精度与范围;不满足时返回非 0 `code` 及 `message`。预览侧 `to[].ratio` 的校验规则见 `POST /asset-swap/order/preview` 文档。

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
const orderCreateV1Req = new OrderCreateV1Req(); // OrderCreateV1Req | Order request body (`OrderCreateV1Req`). **No `ratio` field**; `from`/`to` items are only `asset` + `amount`. `to` uses the target side **amount** `amount`, which is different from the **ratio** (ratio) semantics of `to` in preview, do not mix them.
api.createAssetSwapOrderV1(orderCreateV1Req)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderCreateV1Req OrderCreateV1Req Order request body (`OrderCreateV1Req`). No `ratio` field; `from`/`to` items are only `asset` + `amount`. `to` uses the target side amount `amount`, which is different from the ratio (ratio) semantics of `to` in preview, do not mix them.

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapOrderCreateV1; }> ApiResponseAssetSwapOrderCreateV1

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

listAssetSwapOrdersV1

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapOrderListV1; }> listAssetSwapOrdersV1(opts)

Portfolio optimization — order list

Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
const opts = {
  'from': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'to': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'status': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'offset': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'size': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'sortMode': 56, // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
  'orderBy': 56 // number | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
};
api.listAssetSwapOrdersV1(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
from number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
to number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
status number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
offset number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
size number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
sortMode number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]
orderBy number Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapOrderListV1; }> ApiResponseAssetSwapOrderListV1

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

previewAssetSwapOrderV1

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapOrderPreviewV1; }> previewAssetSwapOrderV1(orderPreviewV1Req)

Portfolio optimization — preview

根据卖出币种数量与目标分配比例估算成交与费用,不写入订单。`code=0` 时 `data` 含预估 `order` 与 `transaction_fee`。 与下单接口的关键差异(易错点) - 本接口 `to` 数组元素为 `PreviewToParam`:`asset` + `ratio`(比例,十进制字符串),表示目标币种在组合中的权重/占比。 - 下单接口 `POST /asset-swap/order/create` 的 `to` 为 `asset` + `amount`(绝对数量)不是 `ratio`。调用方切勿把两套字段混用。 如何构造 `to`(ratio) - 优先从 `GET /asset-swap/config` 的 `data.recommend_v2` 取值:按分组键(如 `market`、`faith`、`conservative`)找到策略列表中的某条 `RecommendV2Strategy`(如 `name` 为 `top2`),将其 `schemes` 映射为预览请求: - `to[].asset` ← `scheme.name`(目标币种符号) - `to[].ratio` ← `scheme.ratio`(与配置一致的比例字符串) - 亦可使用 `recommend` 下扁平 map(币种 → 比例字符串)自行展开为多元素 `to`(每项一个 `asset` + `ratio`)。 - 多目标时各 `ratio` 建议与前端/运营配置一致;是否需加总为 1 以服务端校验为准。 `from`(卖出侧) - 每项为 `asset` + `amount`(字符串,十进制),表示本次参与换出的该币种数量。币种应在 `GET /asset-swap/asset/list` 支持范围内;数量级过小或市场深度不足时可能返回非 0 `code`(如无法询价)。 与下单的衔接 - 预览成功后,将业务允许的预览结果转换为下单所需的 `from`/`to` 全为 amount 的请求体再调用 create(具体映射规则以产品文档或服务端约定为准)。

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
const orderPreviewV1Req = new OrderPreviewV1Req(); // OrderPreviewV1Req | Preview the request body. `to` must be **ratio**; unlike create\'s **amount** semantics.
api.previewAssetSwapOrderV1(orderPreviewV1Req)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderPreviewV1Req OrderPreviewV1Req Preview the request body. `to` must be ratio; unlike create&#39;s amount semantics.

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapOrderPreviewV1; }> ApiResponseAssetSwapOrderPreviewV1

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

getAssetSwapOrderV1

Promise<{ response: http.IncomingMessage; body: ApiResponseAssetSwapOrderQueryV1; }> getAssetSwapOrderV1(orderId)

Portfolio optimization — query order

Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.AssetswapApi(client);
const orderId = "orderId_example"; // string | Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 
api.getAssetSwapOrderV1(orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string Project-Id-Version: GateApiTools 1.0.0 Report-Msgid-Bugs-To: EMAIL@ADDRESS POT-Creation-Date: 2025-11-12 18:14+0800 PO-Revision-Date: 2019-01-02 17:30+0800 Last-Translator: FULL NAME <EMAIL@ADDRESS> Language: en Language-Team: en <L@li.org> Plural-Forms: nplurals=2; plural=(n !=1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Generated-By: Babel 2.8.0 [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: ApiResponseAssetSwapOrderQueryV1; }> ApiResponseAssetSwapOrderQueryV1

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json