Skip to content
No description, website, or topics provided.
JavaScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


GateApi - JavaScript client for gate-api APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 4.7.3
  • Package version: 4.7.3
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen For more information, please visit


For Node.js


To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install gate-api --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your gate-api from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('gate-api') in javascript files from the directory you ran the last command above from.


If the library is hosted at a git repository, e.g. then install it via:

    npm install gateio/gateapi-javascript --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
      parser: {
        amd: false

Getting Started

Please follow the installation instruction and execute the following JS code:

var GateApi = require('gate-api');

var client = GateApi.ApiClient.instance;
client.key = "YOUR API KEY";
client.secret = "YOUR API SECRET";
// uncomment the next line if you are using the API with other host
// client.basePath = "https://some-other-hosts";

var api = new GateApi.FuturesApi()
var orderId = "12345"; // {String} ID returned on order successfully being created

var callback = function(error, data, response) {
  if (error) {
  } else {
    console.log('API called successfully. Returned data: ' + data);
api.cancelFuturesOrder(orderId, callback);

Documentation for API Endpoints

All URIs are relative to

Class Method HTTP request Description
GateApi.FuturesApi cancelFuturesOrder DELETE /futures/orders/{order_id} Cancel a single order
GateApi.FuturesApi cancelFuturesOrders DELETE /futures/orders Cancel all `open` orders matched
GateApi.FuturesApi cancelPriceTriggeredOrder DELETE /futures/price_orders/{order_id} Cancel a single order
GateApi.FuturesApi cancelPriceTriggeredOrderList DELETE /futures/price_orders Cancel all open orders
GateApi.FuturesApi createFuturesOrder POST /futures/orders Create a futures order
GateApi.FuturesApi createPriceTriggeredOrder POST /futures/price_orders Create a price-triggered order
GateApi.FuturesApi getFuturesContract GET /futures/contracts/{contract} Get a single contract
GateApi.FuturesApi getFuturesOrder GET /futures/orders/{order_id} Get a single order
GateApi.FuturesApi getMyTrades GET /futures/my_trades List personal trading history
GateApi.FuturesApi getPosition GET /futures/positions/{contract} Get single position
GateApi.FuturesApi getPriceTriggeredOrder GET /futures/price_orders/{order_id} Get a single order
GateApi.FuturesApi listFuturesAccountBook GET /futures/account_book Query account book
GateApi.FuturesApi listFuturesAccounts GET /futures/accounts Query futures account
GateApi.FuturesApi listFuturesCandlesticks GET /futures/candlesticks Get futures candlesticks
GateApi.FuturesApi listFuturesContracts GET /futures/contracts List all futures contracts
GateApi.FuturesApi listFuturesFundingRateHistory GET /futures/funding_rate Funding rate history
GateApi.FuturesApi listFuturesInsuranceLedger GET /futures/insurance Futures insurance balance history
GateApi.FuturesApi listFuturesOrderBook GET /futures/order_book Futures order book
GateApi.FuturesApi listFuturesOrders GET /futures/orders List futures orders
GateApi.FuturesApi listFuturesTickers GET /futures/tickers List futures tickers
GateApi.FuturesApi listFuturesTrades GET /futures/trades Futures trading history
GateApi.FuturesApi listLiquidates GET /futures/liquidates List liquidation history
GateApi.FuturesApi listPositionClose GET /futures/position_close List position close history
GateApi.FuturesApi listPositions GET /futures/positions List all positions of a user
GateApi.FuturesApi listPriceTriggeredOrders GET /futures/price_orders List all auto orders
GateApi.FuturesApi updatePositionLeverage POST /futures/positions/{contract}/leverage Update position leverage
GateApi.FuturesApi updatePositionMargin POST /futures/positions/{contract}/margin Update position margin
GateApi.FuturesApi updatePositionRiskLimit POST /futures/positions/{contract}/risk_limit Update position risk limit
GateApi.MarginApi cancelLoan DELETE /margin/loans/{loan_id} Cancel lending loan
GateApi.MarginApi createLoan POST /margin/loans Lend or borrow
GateApi.MarginApi getLoan GET /margin/loans/{loan_id} Retrieve one single loan detail
GateApi.MarginApi getLoanRecord GET /margin/loan_records/{loan_record_id} Get one single loan record
GateApi.MarginApi listFundingAccounts GET /margin/funding_accounts Funding account list
GateApi.MarginApi listFundingBook GET /margin/funding_book Order book of lending loans
GateApi.MarginApi listLoanRecords GET /margin/loan_records List repayment records of specified loan
GateApi.MarginApi listLoanRepayments GET /margin/loans/{loan_id}/repayment List loan repayment records
GateApi.MarginApi listLoans GET /margin/loans List all loans
GateApi.MarginApi listMarginAccounts GET /margin/accounts Margin account list
GateApi.MarginApi listMarginCurrencyPairs GET /margin/currency_pairs List all supported currency pairs supported in margin trading
GateApi.MarginApi mergeLoans POST /margin/merged_loans Merge multiple lending loans
GateApi.MarginApi repayLoan POST /margin/loans/{loan_id}/repayment Repay a loan
GateApi.MarginApi updateLoan PATCH /margin/loans/{loan_id} Modify a loan
GateApi.MarginApi updateLoanRecord PATCH /margin/loan_records/{loan_record_id} Modify a loan record
GateApi.SpotApi cancelOrder DELETE /spot/orders/{order_id} Cancel a single order
GateApi.SpotApi cancelOrders DELETE /spot/orders Cancel all `open` orders in specified currency pair
GateApi.SpotApi createOrder POST /spot/orders Create an order
GateApi.SpotApi getCurrencyPair GET /spot/currency_pairs/{currency_pair} Get detail of one single order
GateApi.SpotApi getOrder GET /spot/orders/{order_id} Get a single order
GateApi.SpotApi listCandlesticks GET /spot/candlesticks Market candlesticks
GateApi.SpotApi listCurrencyPairs GET /spot/currency_pairs List all currency pairs supported
GateApi.SpotApi listMyTrades GET /spot/my_trades List personal trading history
GateApi.SpotApi listOrderBook GET /spot/order_book Retrieve order book
GateApi.SpotApi listOrders GET /spot/orders List orders
GateApi.SpotApi listSpotAccounts GET /spot/accounts List spot accounts
GateApi.SpotApi listTickers GET /spot/tickers Retrieve ticker information
GateApi.SpotApi listTrades GET /spot/trades Retrieve market trades
GateApi.WalletApi transfer POST /wallet/transfers Transfer between accounts

Documentation for Models

You can’t perform that action at this time.