cryptomarket
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "cryptomarket", | ||
"version": "1.0.4", | ||
"description": "The CryptoMarket for Node.js", | ||
"homepage": "https://www.cryptomkt.com", | ||
"main": "./index.js", | ||
"author": "Pedro Bustamante", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cryptomkt/cryptomkt-node.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cryptomkt/cryptomkt-node/issues" | ||
}, | ||
"keywords": [ | ||
"api", | ||
"cryptomarket", | ||
"cryptomkt", | ||
"exchange", | ||
"ethereum", | ||
"ether", | ||
"bitcoin", | ||
"btc", | ||
"eos", | ||
"stellar", | ||
"xlm" | ||
], | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"http-errors": "1.7.3", | ||
"js-event-bus": "1.0.0", | ||
"jsondiffpatch": "0.4.1", | ||
"lodash": "4.17.15", | ||
"object-assign": "4.1.1", | ||
"request": "2.88.0", | ||
"socket.io-client": "2.3.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "6.7.2", | ||
"eslint-config-airbnb-base": "14.0.0", | ||
"eslint-plugin-import": "2.18.2" | ||
} | ||
"name": "cryptomarket", | ||
"version": "1.0.5", | ||
"description": "The CryptoMarket for Node.js", | ||
"homepage": "https://www.cryptomkt.com", | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"author": "Ismael Verdugo Zambra", | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cryptomkt/cryptomkt-node.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cryptomkt/cryptomkt-node/issues" | ||
}, | ||
"keywords": [ | ||
"api", | ||
"cryptomarket", | ||
"cryptomkt", | ||
"exchange", | ||
"ethereum", | ||
"ether", | ||
"bitcoin", | ||
"btc", | ||
"eos", | ||
"stellar", | ||
"xlm" | ||
], | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"bigdecimal": "^0.6.1", | ||
"crypto-js": "^4.0.0", | ||
"node-fetch": "^2.6.1", | ||
"rxjs": "^6.6.3", | ||
"ws": "^7.4.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^8.4.0" | ||
} | ||
} |
929
README.md
@@ -1,894 +0,155 @@ | ||
# cryptomkt-node | ||
# CryptoMarket-javascript | ||
[main page](https://www.cryptomkt.com/) | ||
<!--- badges --> | ||
[![NPM version](https://badge.fury.io/js/cryptomarket.svg)](https://badge.fury.io/js/cryptomarket) | ||
[![NPM dependencies](https://david-dm.org/cryptomkt/cryptomkt-node.svg)](https://david-dm.org/cryptomkt/cryptomkt-node) | ||
- [Installation](#Installation) | ||
- [Quick Start](#Quick-Start) | ||
- [API Key](#API-Key) | ||
- [Making API Calls](#Making-API-Calls) | ||
- [Public Endpoints](#Using-the-functions) | ||
- [Listing available markets](#Listing-available-markets) | ||
- [Obtain Book](#Obtain-Book) | ||
- [Obtain ticker info](#Obtain-ticker-info) | ||
- [Authenticated endpoints](#Authenticated-endpoints) | ||
- [Get account info](#Get-account-info) | ||
- [Create an order](#Create-an-order) | ||
- [Create multiple orders](#Create-multiple-orders) | ||
- [Obtain active orders](#Obtain-active-orders) | ||
- [Cancel an order](#Cancel-an-order) | ||
- [Cancel multiple orders](#Cancel-multiple-orders) | ||
- [Make a transfer](#Make-a-transfer) | ||
- [Obtain executed orders](#Obtain-executed-orders) | ||
- [Obtain order status](#Obtain-order-status) | ||
- [Obtain account balance](#Obtain-account-balance) | ||
- [Using socket](#Using-socket) | ||
- [Get socket instance](#Get-socket-instance) | ||
- [Receive socket events](#Receive-socket-events) | ||
- [Market subscription](#Market-subscription) | ||
- [Unsubscribe from market](#Unsubscribe-from-market) | ||
- [Receive open book info](#Receive-open-book-info) | ||
- [Receive Historical book info](#Receive-Historical-book-info) | ||
- [Receive candles info](#Receive-candles-info) | ||
- [Receive ticker info](#Receive-ticker-info) | ||
- [Receive balance info](#Receive-balance-info) | ||
- [Receive user orders info](#Receive-user-orders-info) | ||
- [Receive historical user orders info](#Receive-historical-user-orders-info) | ||
- [Receive User´s operated volume](#Receive-Users-operated-volume) | ||
[sign up in CryptoMarket](https://www.cryptomkt.com/account/register). | ||
## Installation | ||
`npm install cryptomarket` | ||
## Quick Start | ||
The first thing you'll need to do is [sign up for cryptomkt](https://www.cryptomkt.com). | ||
## API Key | ||
If you're writing code for your own CryptoMarket account, [enable an API key](https://www.cryptomkt.com/platform/account#api_tab). Next, create a ``Client`` object for interacting with the API: | ||
```javascript | ||
var { Client } = require('cryptomarket'); | ||
var client = new Client({'apiKey': mykey, 'apiSecret': mysecret}); | ||
# Installation | ||
To install Cryptomarket use npm | ||
``` | ||
## Making API Calls | ||
With a `client instance`, you can now make API calls. We've included some examples below. Each API method returns an ``object`` representing the JSON response from the API. | ||
[(top ↑)](#cryptomkt-node) | ||
### Public endpoints | ||
#### Using the functions | ||
```javascript | ||
async function example(){ | ||
// Method 1: standard promise (Then) | ||
client.getMarkets() | ||
.then((obj) => { | ||
const data = obj.data; | ||
console.log(data); | ||
}).catch((err) => { | ||
console.error(err); | ||
}) | ||
// Method 2: Await promise | ||
try { | ||
let result = await client.getMarkets(); | ||
console.log(result); | ||
} catch (e){ | ||
console.error(err); | ||
} | ||
// Method 3: Callback | ||
client.getMarkets(function(error, result){ | ||
if(error){ | ||
console.error(err); | ||
return; | ||
} | ||
console.log(result); | ||
}) | ||
} | ||
example(); | ||
npm install cryptomarket | ||
``` | ||
##### Expected output | ||
```javascript | ||
// Any of the 3 ways to call the function should return an output like this: | ||
# Documentation | ||
response: { | ||
status: 'success', | ||
data: [ | ||
'ETHCLP', 'ETHARS', 'ETHEUR', | ||
'ETHBRL', 'ETHMXN', 'XLMCLP', | ||
'XLMARS', 'XLMEUR', 'XLMBRL', | ||
'XLMMXN', 'BTCCLP', 'BTCARS', | ||
'BTCEUR', 'BTCBRL', 'BTCMXN', | ||
'EOSCLP', 'EOSARS', 'EOSEUR', | ||
'EOSBRL', 'EOSMXN' | ||
] | ||
} | ||
```` | ||
[(top ↑)](#cryptomkt-node) | ||
[The api documentation](https://api.exchange.cryptomkt.com) | ||
#### Listing available markets | ||
```javascript | ||
var { Client } = require('cryptomarket'); | ||
var client = new Client({'apiKey': mykey, 'apiSecret': mysecret}); | ||
client.getMarkets() | ||
.then((obj) => { | ||
const data = obj.data; | ||
console.log(data); | ||
}).catch((err) => { | ||
console.error(err); | ||
}) | ||
``` | ||
##### Expected output | ||
```javascript | ||
[ | ||
'ETHCLP', 'ETHARS', 'ETHEUR', | ||
'ETHBRL', 'ETHMXN', 'XLMCLP', | ||
'XLMARS', 'XLMEUR', 'XLMBRL', | ||
'XLMMXN', 'BTCCLP', 'BTCARS', | ||
'BTCEUR', 'BTCBRL', 'BTCMXN', | ||
'EOSCLP', 'EOSARS', 'EOSEUR', | ||
'EOSBRL', 'EOSMXN' | ||
] | ||
... | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
# Quick Start | ||
#### Obtain Book | ||
## rest client | ||
```javascript | ||
// Receives a Js object. "market" and "side" are mandatory. | ||
// Example: {"market": "XLMCLP", "side": "sell"} | ||
const { Client } = require('cryptomarket') | ||
client.getBook(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ | ||
"status": "success", | ||
"pagination": { | ||
"previous": 0, | ||
"limit": 20, | ||
"page": 0, | ||
"next": "null" | ||
}, | ||
"data": [ | ||
BaseModel { | ||
client: [Client], | ||
price: '59.8', | ||
amount: '20025.749', | ||
timestamp: '2020-02-21T04:16:07.789000' | ||
}, | ||
BaseModel { | ||
client: [Client], | ||
price: '59.8', | ||
amount: '29736.0992', | ||
timestamp: '2020-02-21T04:20:30.925000' | ||
}, | ||
BaseModel { | ||
client: [Client], | ||
price: '59.8', | ||
amount: '24229.3228', | ||
timestamp: '2020-02-21T04:32:26.686000' | ||
} | ||
... | ||
] | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
// instance a client | ||
let apiKey='AB32B3201' | ||
let api_secret='21b12401' | ||
let client = new Client(apiKey, api_secret) | ||
#### Obtain ticker info | ||
// get currencies | ||
let currencies = await client.getCurrencies() | ||
```javascript | ||
// Receives a Js object that contains the market. | ||
// Example: {"market": "XLMARS"} | ||
// get order books | ||
let orderBook = await client.getOrderBook('EOSETH') | ||
client.getTicker(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ | ||
"status": "success", | ||
"data": [ | ||
{ | ||
client: [Client], | ||
timestamp: '2020-02-21T04:52:17.416448', | ||
market: 'XLMCLP', | ||
bid: '58.2', | ||
ask: '68.4', | ||
last_price: '59.75', | ||
low: '56', | ||
high: '58.3', | ||
volume: '87572.82220768983161' | ||
} | ||
] | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
// get your account balances | ||
let accountBalance = await client.getAccountBalance() | ||
### Authenticated endpoints | ||
// get your trading balances | ||
let tradingBalance = await client.getTradingBalance() | ||
#### Get account info | ||
```javascript | ||
var { Client } = require('cryptomarket'); | ||
var client = new Client({'apiKey': mykey, 'apiSecret': mysecret}); | ||
// move balance from account to trading | ||
let result = await client.transferMoneyFromAccountBalanceToTradingBalance('ETH', '3.2') | ||
client.getAccount() | ||
.then((obj) => { | ||
const data = obj.data; | ||
console.log(data); | ||
}).catch((err) => { | ||
console.error(err); | ||
}) | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ | ||
name: 'John Doe', | ||
email: 'john.doe@gmail.com', | ||
rate: BaseModel { | ||
client: <ref *1> Client { | ||
baseApiUri: 'https://api.cryptomkt.com/v2/', | ||
strictSSL: true, | ||
timeout: 5000, | ||
apiKey: 'FS24FJ7', | ||
apiSecret: 'SFT23GSD', | ||
api: true, | ||
socket: [Socket] | ||
}, | ||
market_maker: '0.0039', | ||
market_taker: '0.0068' | ||
}, | ||
bank_accounts: [ | ||
BaseModel { | ||
client: [Client], | ||
id: 00001, | ||
bank: 'BANCO DE CHILE - EDWARDS', | ||
description: '', | ||
country: 'CL', | ||
number: '1234567890', | ||
dv: null, | ||
agency: null, | ||
clabe: '' | ||
} | ||
] | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
// get your active orders | ||
let orders = await client.getActiveOrders('EOSETH') | ||
#### Create an order | ||
```javascript | ||
// Receives a Js object. "market", "type", "side" and "amount" are mandatory. | ||
// (Example: {"amount": 1, "market": "XLMCLP", "price": 50.5, "type": "limit", "side": "sell"} | ||
// Note that "side" can be either "sell" or "buy", also "type" can be "limit", "stop-limit" or "market". | ||
// If you want to execute an "stop-limit" order you need to specify the "limit" amount. | ||
// Example: {"amount": 1, "market": "XLMCLP", "price": 50.5, "type": "stop-limit", "limit": 50, "side": "sell"} | ||
client.createOrder(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
// create a new order | ||
let newOrder = await client.createOrder({'symbol':'EOSETH', 'side':'buy', 'quantity':'10', 'price':'10'}) | ||
``` | ||
##### Expected output | ||
```javascript | ||
response: { | ||
status: 'success', | ||
data: { | ||
id: 'O000001', | ||
amount: [Object], | ||
price: '50.5', | ||
stop: null, | ||
avg_execution_price: '0', | ||
market: 'XLMCLP', | ||
type: 'limit', | ||
side: 'sell', | ||
fee: '0', | ||
created_at: '2020-02-21T05:08:58.700000', | ||
updated_at: '2020-02-21T05:08:58.768314', | ||
status: 'filled' | ||
} | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
## websocket client | ||
There are three websocket clients, one for public request (WSPublicClient), one for trading request (WSTradingClient) and one for the account requests (WSAccountClient). | ||
#### Create multiple orders | ||
```javascript | ||
// Receives object array that contains multiple orders. "market", "type", "side" and "amount" are mandatory. | ||
// Example: [{"amount": 1, "market": "XLMCLP", "price": 50.5, "type": "limit", "side": "sell"}, {Order2},...] | ||
Clients work with promises | ||
client.createMultiOrders(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
response: { | ||
status: 'success', | ||
data: { | ||
created: [{Order1},{Order2},...], | ||
not_created: [] | ||
} | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
Clients must be connected before any request. Authentication for WSTradingClient and WSAccountClient is automatic. | ||
#### Obtain active orders | ||
```javascript | ||
// Receives a Js object that contains the market | ||
// Example: {"market":"XLMCLP"} | ||
const { WSPublicClient, WSTradingClient, WSAccountClient} = require('cryptomarket') | ||
client.getActiveOrders(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ | ||
status: 'success', | ||
pagination: { page: 0, limit: 20, next: null, previous: null }, | ||
data: [ | ||
BaseModel { | ||
client: [Client], | ||
id: 'O000001', | ||
amount: [BaseModel], | ||
price: '72', | ||
stop: null, | ||
avg_execution_price: '0', | ||
market: 'XLMCLP', | ||
type: 'limit', | ||
side: 'sell', | ||
fee: '0', | ||
created_at: '2020-02-21T14:05:30.313000', | ||
updated_at: '2020-02-21T14:05:30.334726', | ||
status: 'queued' | ||
}, | ||
BaseModel { | ||
client: [Client], | ||
id: 'O000002', | ||
amount: [BaseModel], | ||
price: '71', | ||
stop: null, | ||
avg_execution_price: '0', | ||
market: 'XLMCLP', | ||
type: 'limit', | ||
side: 'sell', | ||
fee: '0', | ||
created_at: '2020-02-21T14:05:30.216000', | ||
updated_at: '2020-02-21T14:05:30.245189', | ||
status: 'queued' | ||
} | ||
... | ||
] | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
let publicClient = new WSPublicClient() | ||
await publicClient.connect() | ||
#### Cancel an order | ||
```javascript | ||
// Receives object that contains the order's ID. | ||
// Example: {"id":"O000004"} | ||
// get currencies | ||
await publicClient.getCurrencies() | ||
client.cancelOrder(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
response: { | ||
status: 'success', | ||
data: { | ||
id: 'O000004', | ||
amount: [Object], | ||
price: '72', | ||
stop: null, | ||
avg_execution_price: '0', | ||
market: 'XLMCLP', | ||
type: 'limit', | ||
side: 'sell', | ||
fee: '0', | ||
created_at: '2020-02-21T14:05:30.313000', | ||
updated_at: '2020-02-21T14:24:08.897689', | ||
status: 'cancelled' | ||
} | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
let apiKey='AB32B3201' | ||
let apiSecret='21b12401' | ||
let tradingClient = new WSTradingClient(apiKey, apiSecret) | ||
#### Cancel multiple orders | ||
await tradingClient.connect() | ||
```javascript | ||
// Receives object array that contains multiple order's IDs. | ||
// Example: [{"id":"O000001"},{"id":"O000002"},...] | ||
// get your trading balance | ||
let balance = await tradingClient.getTradingBalance() | ||
client.cancelMultiOrders(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
response: { | ||
status: 'success', | ||
data: { canceled: [{Order1},{Order2},...], not_canceled: [] } | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
// get your active orders | ||
let activeOrders = await tradingClient.getActiveOrders() | ||
#### Make a transfer | ||
await tradingClient.createOrder({ | ||
clientOrderId:"qqwe123qwe", | ||
symbol:'EOSETH', | ||
side:'buy', | ||
quantity:'10', | ||
price:'10' | ||
}) | ||
```javascript | ||
// Receives a Js object. "currency", "address", and "amount" are mandatory. | ||
// Example: {"currency": "ETH", "address": "0xf2ec...", "amount": 0.02} | ||
let accountClient = new WSAccountClient(apiKey, apiSecret) | ||
await accountClient.connect() | ||
client.transfer(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
// get your account balance | ||
let accBalance = await accountCilent.getAccountBalance() | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ status: 'success', data: '' } | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
### subscriptions | ||
#### Obtain executed orders | ||
```javascript | ||
// Receives a Js object that contains the market. | ||
// Example: {"market":"XLMCLP"} | ||
all subscriptions take a callback argument to call with each feed of the subscription | ||
client.getExecutedOrders(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ | ||
"status": "success", | ||
"pagination": { | ||
"previous": "null", | ||
"limit": 20, | ||
"page": 0, | ||
"next": "null" | ||
}, | ||
"data": [ | ||
client: [Client], | ||
id: 'O000003', | ||
amount: { | ||
"original": "1.4044", | ||
"remaining": "1.4044" | ||
}, | ||
price: '50.5', | ||
stop: null, | ||
avg_execution_price: '58', | ||
market: 'XLMCLP', | ||
type: 'limit', | ||
side: 'sell', | ||
fee: '0.394', | ||
created_at: '2020-02-21T05:08:58.700000', | ||
updated_at: '2020-02-21T05:08:59.549126', | ||
status: 'filled', | ||
fills: [Array] | ||
] | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Obtain order status | ||
```javascript | ||
// Receives a Js object that contains the ID. | ||
// Example: {"id":"O000005"} | ||
client.getOrderStatus(object, (err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
response: { | ||
status: 'success', | ||
data: { | ||
id: 'O000005', | ||
amount: [Object], | ||
price: '71', | ||
stop: null, | ||
avg_execution_price: '0', | ||
market: 'XLMCLP', | ||
type: 'limit', | ||
side: 'sell', | ||
fee: '0', | ||
created_at: '2020-02-21T14:05:30.216000', | ||
updated_at: '2020-02-21T14:05:30.245189', | ||
status: 'queued', | ||
fills: [] | ||
} | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Obtain account balance | ||
```javascript | ||
client.getBalance((err, output) => { | ||
if(err){ | ||
console.log('error'); | ||
return | ||
} | ||
console.log(output); | ||
}); | ||
``` | ||
##### Expected output | ||
```javascript | ||
{ | ||
"status": "success", | ||
"data": [ | ||
{ | ||
"available": "1203.1231", | ||
"wallet": "CLP", | ||
"balance": "120347" | ||
}, | ||
{ | ||
"available": "10.3399", | ||
"wallet": "ETH", | ||
"balance": "11.3399" | ||
}, | ||
... | ||
] | ||
// callback is for the subscription feed | ||
function callback(feed) { | ||
// handle feed | ||
console.log(feed) | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
## Using socket | ||
await publicClient.subscribeToOrderBook('EOSETH', callabck) | ||
Cryptomarket's API v2 integrates Socket.IO! You can now receive real-time events connecting to the sockets. | ||
### Get socket instance | ||
```javascript | ||
var { Client } = require('cryptomarket'); | ||
var client = new Client({'apiKey': mykey, 'apiSecret': mysecret}); | ||
var socket; | ||
client.socket.connect() | ||
.then((skt) => { | ||
socket = skt | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
//or | ||
var socket = await client.socket.connect(); | ||
await accountClient.subscribeToTransactions(callback) | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
### Receive socket events | ||
## error handling | ||
#### Market subscription | ||
```javascript | ||
socket.subscribe('ETHCLP'); | ||
``` | ||
#### Unsubscribe from market | ||
```javascript | ||
socket.unsubscribe('ETHCLP'); | ||
``` | ||
{ CryptomarketSDKException, Client, WSPublicClient } = require('cryptomarket') | ||
// exceptions derive from the CryptomarketSDKException class. | ||
#### Receive open book info | ||
```javascript | ||
// Subscription required. | ||
socket.on('open-book', (data) => { | ||
console.log('open-book', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
open-book { | ||
ETHCLP: { | ||
sell: [ | ||
[Order1], [Order2],... | ||
], | ||
buy: [ | ||
[Order1], [Order2],... | ||
] | ||
} | ||
client = new Client() | ||
// catch a failed transaction | ||
try { | ||
order = client.createOrder({ | ||
'symbol':'EOSETHH', // non existant symbol | ||
'side':'sell', | ||
'quantity':'10', | ||
'price':'10'}) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Receive Historical book info | ||
```javascript | ||
// Subscription required. | ||
wsclient = new WSPublicClient() | ||
await wsclient.connect() | ||
socket.on('historical-book', (data) => { | ||
console.log('historical-book', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
[ | ||
{ | ||
requestId: 'OOETHCLP0000000000000000000001', | ||
tradeId: 'O232937', | ||
stockId: 'ETHCLP', | ||
kind: 1, | ||
type: 2, | ||
side: 1, | ||
price: '204820.000000000000000000000000000000', | ||
limit: null, | ||
condition: null, | ||
flag: 'GENERAL', | ||
amount: '0.00000000000000000000000000000000000', | ||
initAmount: '2.07330000000000000000000000000000000', | ||
dateReceived: 1582205310697, | ||
executed_price: '204820.000000000000000000000000000000', | ||
executed_amount: '2.07330000000000000000000000000000000', | ||
executed_date: 1582205310745 | ||
}, | ||
{ | ||
requestId: 'OOETHCLP0000000000000000000002', | ||
tradeId: 'O232665', | ||
stockId: 'ETHCLP', | ||
kind: 1, | ||
type: 2, | ||
side: 1, | ||
price: '201540.000000000000000000000000000000', | ||
limit: null, | ||
condition: null, | ||
flag: 'GENERAL', | ||
amount: '1.66960000000000000000000000000000000', | ||
initAmount: '1.92640000000000000000000000000000000', | ||
dateReceived: 1582204925623, | ||
executed_price: '201260.000000000000000000000000000000', | ||
executed_amount: '0.256800000000000000000000000000000000', | ||
executed_date: 1582204925645 | ||
} | ||
] | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Receive candles info | ||
```javascript | ||
// Subscription required. | ||
socket.on('candles', (data) => { | ||
console.log('candles', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
candles { | ||
'buy': { | ||
'1': [ | ||
[{ | ||
date: '21/02/2020 04:56:00', | ||
stockId: 'ETHCLP', | ||
type: 1, | ||
timeFrame: 1, | ||
lowPrice: 212060, | ||
hightPrice: 212060, | ||
openPrice: 212060, | ||
closePrice: 212100, | ||
count: 3, | ||
volume: 0, | ||
lastBuyPrice: 217900, | ||
lastSellPrice: 227220 | ||
}],[Object],...], | ||
'5': [[Object],[Object],...], | ||
'15':[[Object],[Object],...], | ||
'60': [[Object],[Object],...], | ||
'240':[[Object],[Object],...], | ||
'1440':[[Object],[Object],...], | ||
'10080':[[Object],[Object],...], | ||
'44640':[[Object],[Object],...] | ||
// catch a missing argument | ||
try { | ||
await wsclient.subscribeToOrderbook('ETHBTC') // needs a callback | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
'sell':{ | ||
'1':[[Object],...], | ||
'5':... | ||
}, | ||
lastBuyPrice: 218880,lastSellPrice: 227220 | ||
// also catches forwarded errors from the cryptomarket exchange server | ||
try { | ||
let trades = await wsclient.getTrades("abcde", myCallback) // not a real symbol | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Receive ticker info | ||
```javascript | ||
socket.on('ticker', (data) => { | ||
console.log('ticker', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
ticker { | ||
EOSARS: { | ||
BID: 346.95, | ||
ASK: 364.65, | ||
delta1d: -13.04511278195489, | ||
delta7d: -21.928442844284426 | ||
}, | ||
BTCCLP: { | ||
BID: 7914600, | ||
ASK: 8038600, | ||
delta1d: -2.4334319526627217, | ||
delta7d: -2.1318164956102383 | ||
}, | ||
ETHCLP: { | ||
BID: 213600, | ||
ASK: 218880, | ||
delta1d: 1.0598031794095382, | ||
delta7d: 0.6692430954849656 | ||
}, | ||
... | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
# Checkout our other SDKs | ||
#### Receive balance info | ||
[python sdk](https://github.com/cryptomkt/cryptomkt-python) | ||
```javascript | ||
socket.on('balance', (data) => { | ||
console.log('balance', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
balance { | ||
ETH: { | ||
currency: 'ETH', | ||
countable: '0.0700000000000000000000000000000000000', | ||
available: '0.0700000000000000000000000000000000000', | ||
currency_kind: 1, | ||
currency_name: 'ETH', | ||
currency_big_name: 'Ether', | ||
currency_prefix: '', | ||
currency_postfix: ' ETH', | ||
currency_decimals: 4 | ||
}, | ||
... | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
[java sdk](https://github.com/cryptomkt/cryptomkt-java) | ||
#### Receive user orders info | ||
[go sdk](https://github.com/cryptomkt/cryptomkt-go) | ||
```javascript | ||
socket.on('open-orders', (data) => { | ||
console.log('open-orders', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
open-orders [ | ||
{ | ||
requestId: 'OOXLMCLP0000000000000000000001', | ||
tradeId: 'O000001', | ||
traderId: '2', | ||
stockId: 'XLMCLP', | ||
kind: 2, | ||
type: 2, | ||
side: 2, | ||
price: '80.0000000000000000000000000000000000', | ||
limit: null, | ||
condition: null, | ||
flag: 'GENERAL', | ||
amount: '1.00000000000000000000000000000000000', | ||
initAmount: '1.00000000000000000000000000000000000', | ||
dateReceived: 1582301424510 | ||
}, | ||
{Order2},... | ||
] | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Receive historical user orders info | ||
```javascript | ||
socket.on('historical-orders', (data) => { | ||
console.log('historical-orders', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
historical-orders [ | ||
{ | ||
requestId: 'OOXLMCLP000000000000000000001', | ||
tradeId: 'O000001', | ||
traderId: '1', | ||
stockId: 'XLMCLP', | ||
kind: 2, | ||
type: 2, | ||
side: 2, | ||
price: '50.5000000000000000000000000000000000', | ||
limit: null, | ||
condition: null, | ||
flag: 'GENERAL', | ||
amount: '0.00000000000000000000000000000000000', | ||
initAmount: '1.00000000000000000000000000000000000', | ||
dateReceived: 1582261738700 | ||
}, | ||
{ | ||
requestId: 'OOXLMCLP000000000000000000002', | ||
tradeId: 'O0000022', | ||
traderId: '1', | ||
stockId: 'XLMCLP', | ||
kind: 2, | ||
type: 2, | ||
side: 2, | ||
price: '72.0000000000000000000000000000000000', | ||
limit: null, | ||
condition: null, | ||
flag: 'GENERAL', | ||
amount: '1.00000000000000000000000000000000000', | ||
initAmount: '1.00000000000000000000000000000000000', | ||
dateReceived: 1582293930313, | ||
dateTriggered: null | ||
}, | ||
... | ||
] | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
#### Receive User´s operated volume | ||
```javascript | ||
socket.on('operated', (data) => { | ||
console.log('operated', data); | ||
}); | ||
``` | ||
##### Expected Output | ||
```javascript | ||
operated { | ||
flag: 'L0', | ||
threshold: '0.00000000000000000000000000000000000', | ||
traded: '0.0718085391503182500000000000000000000', | ||
tk: '0.00680000000000000000000000000000000000', | ||
mk: '0.00390000000000000000000000000000000000' | ||
} | ||
``` | ||
[(top ↑)](#cryptomkt-node) | ||
[ruby sdk](https://github.com/cryptomkt/cryptomkt-ruby) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
113214
5
1
23
2613
0
156
2
+ Addedbigdecimal@^0.6.1
+ Addedcrypto-js@^4.0.0
+ Addednode-fetch@^2.6.1
+ Addedrxjs@^6.6.3
+ Addedws@^7.4.0
+ Addedbigdecimal@0.6.1(transitive)
+ Addedcrypto-js@4.2.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
+ Addedws@7.5.10(transitive)
- Removedhttp-errors@1.7.3
- Removedjs-event-bus@1.0.0
- Removedjsondiffpatch@0.4.1
- Removedlodash@4.17.15
- Removedobject-assign@4.1.1
- Removedrequest@2.88.0
- Removedsocket.io-client@2.3.0
- Removedafter@0.8.2(transitive)
- Removedajv@6.12.6(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedarraybuffer.slice@0.0.7(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasync-limiter@1.0.1(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbacko2@1.0.2(transitive)
- Removedbase64-arraybuffer@0.1.40.1.5(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbetter-assert@1.0.2(transitive)
- Removedblob@0.0.5(transitive)
- Removedcallsite@1.0.0(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcomponent-bind@1.0.0(transitive)
- Removedcomponent-emitter@1.2.11.3.1(transitive)
- Removedcomponent-inherit@0.0.3(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@3.1.04.1.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddepd@1.1.2(transitive)
- Removeddiff-match-patch@1.0.5(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedengine.io-client@3.4.4(transitive)
- Removedengine.io-parser@2.2.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhas-binary2@1.0.3(transitive)
- Removedhas-cors@1.1.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhttp-errors@1.7.3(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedindexof@0.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@2.0.1(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjs-event-bus@1.0.0(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsondiffpatch@0.4.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlodash@4.17.15(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedobject-component@0.0.3(transitive)
- Removedparseqs@0.0.50.0.6(transitive)
- Removedparseuri@0.0.50.0.6(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@1.4.12.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsetprototypeof@1.1.1(transitive)
- Removedsocket.io-client@2.3.0(transitive)
- Removedsocket.io-parser@3.3.4(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstatuses@1.5.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedto-array@0.1.4(transitive)
- Removedtoidentifier@1.0.0(transitive)
- Removedtough-cookie@2.4.3(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedws@6.1.4(transitive)
- Removedxmlhttprequest-ssl@1.5.5(transitive)
- Removedyeast@0.1.2(transitive)