# exmo-ts-api

> exmo-api

Latest version **0.1.0** (published 2023-02-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install exmo-ts-api
pnpm add exmo-ts-api
yarn add exmo-ts-api
bun add exmo-ts-api
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-02-25 |
| First published | 2023-01-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 71.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | soltivka@gmail.com |
| Maintainers | soltivka |

## Links

- npm: https://www.npmjs.com/package/exmo-ts-api
- npm.io page: https://npm.io/package/exmo-ts-api

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.2.2
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.1.1

## Recent versions

- 0.1.0 (latest) — 2023-02-25
- 0.1.2 (next) — 2023-10-22
- 0.1.1 — 2023-10-22
- 0.0.20 — 2023-02-20
- 0.0.19 — 2023-02-10
- 0.0.18 — 2023-02-10
- 0.0.17 — 2023-02-10
- 0.0.15 — 2023-02-10
- 0.0.14 — 2023-02-09
- 0.0.13 — 2023-02-09
- 0.0.12 — 2023-02-09
- 0.0.11 — 2023-01-31
- 0.0.10 — 2023-01-31
- 0.0.8 — 2023-01-31
- 0.0.7 — 2023-01-31
- … 6 more at https://npm.io/package/exmo-ts-api/versions

## README

## Installation

```console
$ npm install exmo-ts-api
```

# Set Up

```js
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

```js
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
](https://documenter.getpostman.com/view/10287440/SzYXWKPi)

### Public API methods:

* trades

```js
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

```js
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

```js
const pair = 'BTC_USD' // or ['BTC_USD', 'USDT_USD']
api.ticker(pair).then((response) => {

})
```

* pair_settings

```js
const pair = 'BTC_USD' // or ['BTC_USD', 'USDT_USD']
api.pairSettings(pair).then((response) => {

})
```

* currency

```js
api.currency().then((response) => {

})
```

* currency_list_extended

```js
api.currencyListExtended().then((response) => {

})
```

* required_amount

```js
api.requiredAmount(pair, quantity).then((response) => {
    //quantity to buy/sell (first currancy in pair)

})
```

* candles_history

```js
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

```js
api.paymentProviderCryptoList().then((response) => {

})
```

### Authenticated API methods:

* user_info

```js
api.userInfo().then((response) => {

})
```

* order_create

```js
const request = {
    pair: 'BTC_USD',
    quantity: 3,
    price: '40499.2',
    type: "buy",
    client_id: 100500
}
api.orderCreate(request).then((response) => {

})
```

* order_cancel

```js
const orderId = 10525
api.orderCancel(orderId).then((response) => {

})
```

* stop_market_order_create

```js
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

```js
const parentOrderId = 507056272792275327
api.stopMarketOrderCancel(parentOrderId).then((response) => {

})
```

* user_open_orders

```js
const pair = 'BTC_USD'
api.userOpenOrders(pair).then((response) => {

})
```

* user_trades

```js
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

```js
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

```js
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 :

```js

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

```js

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

```js

api.requestsScheduleOn(true) // only effects Authenticated API methods

```

---
_Source: https://npm.io/package/exmo-ts-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
