gtapi

1.1.3 • Public • Published

About

Simple Gate.io api for Node.js to access Gate.io REST API.

Usage example 1 (api class)

const api = require('gtapi')
let ac = new api(<apiKey>, <secret>);

async function test(){
  let r = await ac.get('/account/detail')
  console.log(r) // {user_id: 21521911,..}
}
test()

Usage example 2 (call function)

const {call} = require('gtapi')
let apiKey = <apiKey>;
let secret = <secret>;

async function test(){
  let data = ''
  let r = await call('/unified/accounts', {data, apiKey, secret})
  console.log(r) // {balances:{BTC:{available: '0',..},..},..}
}
test()

Installation


npm i gtapi

Parameters (call function)

function call(path, {data, apiKey, secret, method, testnet} )

  • path = eg: "/account/detail" ref
  • apiKey = Gate.io apiKey
  • secret = Gate.io api secret
  • optional
    • data = params to be passed in, can be object {symbol:'BTC_USDT'} or query string (symbol=BTCUSDT&key=value)
    • method = "GET" (default) OR "POST"
    • testnet = 0 (default) | 1 (to use testnet)

Parameters (api function)


api.get(path[, data][, {testnet}])
api.post(path[, data][, {testnet}])

  • data (optional) = refer above

return

return object (result from Gate.io api)

global variables

global.gtLimit = global.gateLimit = global["x-gate-ratelimit-requests-remain"];

global.gtLimitMax = global.gateLimitMax = global["x-gate-ratelimit-limit"];

global.gtLimits = global.gateLimits = {
  gateLimit: global.gateLimit,
  gateLimitMax: global.gateLimitMax,
};

/gtapi/

    Package Sidebar

    Install

    npm i gtapi

    Weekly Downloads

    5

    Version

    1.1.3

    License

    none

    Unpacked Size

    8.56 kB

    Total Files

    4

    Last publish

    Collaborators

    • jydev