0.1.0 • Published 7 months ago

exmo-ts-api v0.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Installation

$ npm install exmo-ts-api

Set Up

import {ExmoApi} from "exmo-ts-api";

const credentials = {
    publicKey: '*your public key*',
    secretKey: '*your secret key*',
}

const api = new ExmoApi(credentials)

If you don't need Authenticagted API for your tasks, you can use it without credentials

import {ExmoApi} from "exmo-ts-api";

const api = new ExmoApi()

Usage

The library implements all endpoints from the official Exmo documentation that are Public Api or Authenticated Api.

Official Exmo documentation used to build this project: Exmo API

Public API methods:

  • trades
const pair = 'BTC_USD' // or ['BTC_USD', 'USDT_USD']
api.trades(pair).then((response) => {
// response example :  {
//     "BTC_USD": [
//         {
//             "trade_id": 3,
//             "type": "sell",
//             "price": "100",
//             "quantity": "1",
//             "amount": "100",
//             "date": 1435488248
//         }
//     ]
// }
})
  • order_book
const pair = 'BTC_USD' // or ['BTC_USD', 'USDT_USD']
api.orderBook(pair, limit).then((response) => {
    // limit  is the number of displayed positions (default: 100, max: 1000)
})
  • ticker
const pair = 'BTC_USD' // or ['BTC_USD', 'USDT_USD']
api.ticker(pair).then((response) => {

})
  • pair_settings
const pair = 'BTC_USD' // or ['BTC_USD', 'USDT_USD']
api.pairSettings(pair).then((response) => {

})
  • currency
api.currency().then((response) => {

})
  • currency_list_extended
api.currencyListExtended().then((response) => {

})
  • required_amount
api.requiredAmount(pair, quantity).then((response) => {
    //quantity to buy/sell (first currancy in pair)

})
  • candles_history
const time = Math.round(Date.now() / 1000) // time in seconds (NOT in ms like usually)
const from = time.toString()
const to = (time + 3600).toString() // from + 1 hour
api.candlesHistory(pair, from, to, resolution).then((response) => {
    //resolution default = 30

})
  • payments_providers_crypto_list
api.paymentProviderCryptoList().then((response) => {

})

Authenticated API methods:

  • user_info
api.userInfo().then((response) => {

})
  • order_create
const request = {
    pair: 'BTC_USD',
    quantity: 3,
    price: '40499.2',
    type: "buy",
    client_id: 100500
}
api.orderCreate(request).then((response) => {

})
  • order_cancel
const orderId = 10525
api.orderCancel(orderId).then((response) => {

})
  • stop_market_order_create
const request = {
    pair: 'BTC_USD',
    quantity: '10.1',
    trigger_price: '85000',
    type: 'sell',
    client_id: 100500
}
api.stopMarketOrderCreate(request).then((response) => {

})
  • stop_market_order_cancel
const parentOrderId = 507056272792275327
api.stopMarketOrderCancel(parentOrderId).then((response) => {

})
  • user_open_orders
const pair = 'BTC_USD'
api.userOpenOrders(pair).then((response) => {

})
  • user_trades
const pair = 'BTC_USD';
const limit = 100; //the number of returned deals (default: 100, maximum: 100)
const offset = 0; //last deal offset (default: 0)
api.userTrades(pair, limit, offset).then((response) => {

})
  • user_cancelled_orders
const limit = 100; //the number of returned deals (default: 100, maximum: 10 000)
const offset = 0; //last deal offset (default: 0)
api.userCancelledOrders(limit, offset).then((response) => {

})
  • order_trades
const orderId = 12345
api.orderTrades(orderId).then((response) => {

})

Features

  • async-await

All methods return plain promises, so you can use the await keyword in async functions if needed, for example :

async function yourFunction() {
    const response = await api.currency()
    //your code
}
  • error-throwing

Throws error, when the response is 200, but contains result : false. This eliminates the need to make unnecessary checks on the content of the response, allows you to catch such requests through .catch block

api.orderCancel(100).then((response) => {
//do something
}).catch((e) => {
    // error response example : {
    //     "result": false,
    //     "error": "Error 40003: Authorization error, http header 'Key' not specified"
    // }
})
  • handling nonce error

If you send a large number of requests at the same time, you may encounter the following error: "Error: 40009: The nonce parameter is less or equal than what was used before "1675941974570" ". This happens when multiple requests are sent within 1ms, or if the request that was sent later is processed by the server before the request that was sent before it.

You can set parameter requestSchedule to true, Requests will be sent sequentially. Each subsequent request will be sent only after the previous one has been completed

api.requestsScheduleOn(true) // only effects Authenticated API methods
0.1.1

7 months ago

0.0.20

1 year ago

0.1.0

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago