Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

joyso

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joyso

JOYSO API client library for trading.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

JOYSO

JOYSO API client library for trading.

Installation

You can use this command to install:

npm install joyso

Usage

Setup and connect to JOYSO

const Joyso = require('joyso-api');

async function start() {
  const client = new Joyso({
    // your private key
    key: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
  });

  await client.connect();
}

subscribeOrderBook(pair, callback)

Subscribe order book, notify if change.

client.subscribeOrderBook('ETH_JOY', orderBook => {
  console.log(JSON.stringify(orderBook));
});

Result:

{
  "buy":[
    {
      "price":0.000123456,
      "amount":"8.5"
    },
    {
      "price":0.000123455,
      "amount":"98.5"
    }
  ],
  "sell":[
    {
      "price":0.00012346,
      "amount":"100"
    },
    {
      "price":0.00012347,
      "amount":"500"
    }
  ]
}
  • amount is BigNumber object.

subscribeTrades(pair, callback)

Subscribe market trades, notify if change, return last 100 records.

client.subscribeTrades('ETH_JOY', trades => {
  console.log(JSON.stringify(trades.slice(0, 2)));
});

Result

[
  {
    "id":317,
    "side":"sell",
    "price":0.000123456,
    "amount":"2",
    "pair":"ETH_JOY"
  },
  {
    "id":315,
    "side":"buy",
    "price":0.00012347,
    "amount":"1",
    "pair":"ETH_JOY"
  }
]
  • amount is BigNumber object.

subscribeBalances(callback)

Subscribe balances, notify if change.

client.subscribeBalances(balances => {
  console.log(JSON.stringify(balances));
});

Result

{
  "JOY":{
    "inOrder":"0",
    "available":"4.5"
  },
  "ETH":{
    "inOrder":"0.001447757819",
    "available":"0.097815997145"
  }
}
  • inOrder and available are BigNumber objects.

subscribeOrders(callback)

Subscribe open orders, notify if change.

client.subscribeOrders(orders => {
  console.log(JSON.stringify(orders));
});

Result

[
  {
    "id":353,
    "status":"active",
    "side":"buy",
    "price":0.000123481,
    "amount":"1",
    "fill":"0",
    "pair":"ETH_T00"
  },
  {
    "id":326,
    "status":"partial",
    "side":"buy",
    "price":0.000123456,
    "amount":"12",
    "fill":"3.5",
    "pair":"ETH_JOY"
  }
]
  • amount and fill are BigNumber objects.
  • status could be active or partial

subscribeMyTrades(callback)

Subscribe my trades, notify if change, return last 100 records.

client.subscribeMyTrades(trades => {
  console.log(JSON.stringify(trades.slice(0, 2)));
});

Result

[
  {
    "id":317,
    "status":"done",
    "txHash":"0xcf0aeb815200951559a38650a84f8eefa46411224e5e4076d6313ab47c7f9bb5",
    "side":"sell",
    "price":0.000123456,
    "amount":"2",
    "pair":"ETH_JOY",
    "fee":"ETH",
    "gasFee":"0",
    "txFee":"2.46912e-7"
  },
  {
    "id":316,
    "status":"done",
    "txHash":"0x582cc7a84e8aa7e28e44b11e22f24169a34776915ebbc95a88fa0e77c44faf4c",
    "side":"sell",
    "price":0.00012347,
    "amount":"1",
    "pair":"ETH_JOY",
    "fee":"ETH",
    "gasFee":"0.000105",
    "txFee":"2.4694e-7"
  }
]
  • amount, gasFee and txFee are BigNumber objects.

subscribeFunds(callback)

Subscribe funds, notify if change, return last 100 records.

client.subscribeFunds(funds => {
  console.log(JSON.stringify(funds));
});

Result

[
  {
    "id":192,
    "status":"done",
    "txHash":"0x4dbc49ae4735b1c230244d41377cf6aeccd70c5181df048e3be8306af8a487e6",
    "type":"withdraw",
    "amount":"0.0099",
    "token":"ETH",
    "fee":"ETH",
    "withdrawFee":"0.0001",
    "timestamp":1537434044,
    "blockId":null
  },
  {
    "id":191,
    "status":"done",
    "txHash":"0x8435bf9f69dd908373d50353ebab343b625527cd8ea44532eb01c8b0a5642879",
    "type":"withdraw",
    "amount":"0.001",
    "token":"ETH",
    "fee":"JOY",
    "withdrawFee":"0.809841",
    "timestamp":1537433888,
    "blockId":null
  }
]
  • amount and withdrawFee are BigNumber objects.
  • status could be pending, processing, done or failed
  • type could be deposit, withdraw or transfer

buy({ pair, price, amount, fee })

Place buying order

try {
  let order = await client.buy({
    pair: 'ETH_JOY',
    price: '0.000123481',
    amount: 1,
    fee: 'base'
  });
  console.log(JSON.stringify(order));
} catch (e) {
  if (e.statusCode === 400) {
    console.log(e.error.error);
  } else {
    console.log(e.message);
  }
}

Options

NameRequiredDescription
pairOPair to trade, format is ${base}_${quote}, eg: ETH_JOY
priceOOrder price, minimum is 0.000000001
amountOQuote amount
feeOSpecify how to pay fee. base or joy.

Result

{
  "id":361,
  "status":"complete",
  "side":"buy",
  "price":0.000123481,
  "amount":"1",
  "fill":"1",
  "pair":"ETH_JOY"
}
  • amount and fill are BigNumber objects.
  • status could be active, partial or complete

sell({ pair, price, amount, fee })

Place selling order

let order = await client.sell({
  pair: 'ETH_JOY',
  price: '0.000123481',
  amount: 100,
  fee: 'base'
});

Options and result are same with buy.

trade({ pair, price, amount, fee, side })

Place selling order

let order = await client.trade({
  side: 'buy',
  pair: 'ETH_JOY',
  price: '0.000123481',
  amount: 100,
  fee: 'joy'
});

Options and result are same with buy. One extra options

NameRequiredDescription
sideObuy or sell

withdraw({ token, amount, fee })

Place selling order

await client.withdraw({
  token: 'ETH',
  amount: 0.01,
  fee: 'eth'
});

Options

NameRequiredDescription
tokenOToken to withdraw
amountOAmount to withdraw
feeOSpecify how to pay fee. eth or joy.

License

The project is released under the MIT license.

Contact

The project's website is located at https://github.com/Joyso-io/joyso-api

Keywords

FAQs

Package last updated on 20 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc