Coder Social home page Coder Social logo

biscoint-api-node's Introduction

Biscoint API Node

๐ŸŒŽ This documentation is also available in the following languages: PT-BR

TypeScript Mocha Node

NodeJS library for interacting with Biscoint's API. In order to call private methods, you'll need a Biscoint verified account to generate the API key and secret.

Biscoint is a cryptocurrency marketplace that allows trading BTC and another assets in multiple exchanges with a single account.

Example

Check out biscoint-arbitrage-bot, for it showcases the use of many of the methods in this library in an arbitrage bot application.

Install with NPM

  npm i biscoint-api-node

Install with Yarn

  yarn add biscoint-api-node

Instantiate Biscoint class

import Biscoint from 'biscoint-api-node';


// configure here with your keys for private calls, public calls don't need valid keys
const bc = new Biscoint({
  apiKey: 's4t0sh1n4k4m0t0',
  apiSecret: 's4t0sh1n4k4m0t0',
  // apiTimeout: 9000,
});

Optionally, you can uncomment the apiTimeout line to specify the request timeout in milliseconds you want. If not specified the default timeout will be 5000ms.

All methods return a Promise.

Public methods

Ticker


Get Biscoint ticker

bc.ticker();

Returns

{
  base: 'BTC',
  quote: 'BRL',
  vol: 0.00155952,
  low: 32061.15,
  high: 32061.15,
  last: 32061.15,
  ask: 32088.7,
  askQuoteAmountRef: 1000,
  askBaseAmountRef: 0.03116362,
  bid: 29961.9,
  bidQuoteAmountRef: 1000,
  bidBaseAmountRef: 0.03337572,
  timestamp: '2019-12-10T20:22:29.172Z'
}

Fees


Get Biscoint fees

bc.fees();

Returns

{
  withdrawal: {
    BTC: {
      rate: "0.0",
      fixed: {
        slow: "0.0001",
        normal: "0.0002",
        fast: "0.0004"
      }
    },
    BRL: {
      rate: "0.0",
      fixed: {
        ted: "14.90",
        sameBankTransfer: "14.90"
      }
    }
  }
}

Rate limits


Get Biscoint rate limit of your IP

bc.meta();

Returns

{
  version: "v1",
  endpoints: {
    ticker: {
      get: {
        type: "public",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 6,
          rate: "6 per 1 minute"
        }
      }
    },
    fees: {
      get: {
        type: "public",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 2,
          rate: "2 per 1 minute"
        }
      }
    },
    meta: {
      get: {
        type: "public",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 2,
          rate: "2 per 1 minute"
        }
      }
    },
    balance: {
      get: {
        type: "private",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 12,
          rate: "12 per 1 minute"
        }
      }
    },
    offer: {
      get: {
        type: "private",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 24,
          rate: "24 per 1 minute"
        }
      },
      post: {
        type: "private",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 24,
          rate: "24 per 1 minute"
        }
      }
    },
    trades: {
      get: {
        type: "private",
        rateLimit: {
          windowMs: 60000,
          maxRequests: 12,
          rate: "12 per 1 minute"
        }
      }
    }
  }
}

Private methods

Balance


Get your account balance

bc.balance();

Returns

{
  BRL: 5000.00,
  BTC: 0.001
}

Offer


Request a new offer for amount, and side that you specify.

bc.offer({ amount: 0.01, isQuote: false, op: "buy" });

Returns

{
  offerId: "hHaJuKF2m5aD8mZn4",
  base: "BTC",
  quote: "BRL",
  op: "buy",
  isQuote: false,
  baseAmount: "0.01000000",
  quoteAmount: "362.69",
  efPrice: "36269.00",
  createdAt: "2020-01-22T22:39:16.874Z",
  expiresAt: "2020-01-22T22:39:31.874Z",
  apiKeyId: "BdFABxNakZyxPwnRu"
}

Confirm Offer


Confirm offer passing an orderId

bc.confirmOffer({ offerId: "5d9s8w6d12"});

Returns

{
  offerId: "hHaJuKF2m5aD8mZn4",
  base: "BTC",
  quote: "BRL",
  op: "buy",
  isQuote: false,
  baseAmount: "0.01000000",
  quoteAmount: "362.69",
  efPrice: "36269.00",
  createdAt: "2020-01-22T22:39:16.874Z",
  confirmedAt: "2020-01-22T22:39:16.945Z",
  apiKeyId: "BdFABxNakZyxPwnRu"
}

Get last trades


Returns last 20 trades

bc.trades({ op: 'sell' });

Returns

[
  {
    "id": "D6x63B3q3Mec4tggY",
    "offerId": "aX2Bkd8MseB20Axbkba",
    "op": "buy",
    "base": "BTC",
    "quote": "BRL",
    "baseAmount": "0.01000000",
    "quoteAmount": "362.82",
    "apiKeyId": "BdFABxNakZyxPwnRu",
    "efPrice": "36282.00",
    "date": "2020-01-22T23:25:02.785Z"
  },
  ...
]

Get last trades paginated


Returns last 20 trades

bc.trades({ page: 0, limit: 20, base: 'BTC' });

Returns

{
  "page": 0,
  "totalPages": 2,
  "totalSize": 15,
  "limit": 20,
  "trades": [
    {
      "id": "D6x63B3q3Mec4tggY",
      "offerId": "aX2Bkd8MseB20Axbkba",
      "op": "buy",
      "base": "BTC",
      "quote": "BRL",
      "baseAmount": "0.01000000",
      "quoteAmount": "362.82",
      "apiKeyId": "BdFABxNakZyxPwnRu",
      "efPrice": "36282.00",
      "date": "2020-01-22T23:25:02.785Z"
    },
    ...
  ]
}

Testing

Simple do the following steps

  1. Add the following environment variables to your terminal (replace with your own api key and secret)
API_URL='https://api.biscoint.io/' # tip: this can be null
API_KEY='s4t0sh1n4k4m0t0'
API_SECRET='s4t0sh1n4k4m0t0'
  1. Run tests
npm run test

or

yarn test

PRs are welcome!

If you missed something and would like to see it here, don't be shy and create your first PR. Our recruiters are keeping an eye on those who contribute ๐Ÿ‘€.

biscoint-api-node's People

Contributors

bolaum avatar caioaabrantes avatar dependabot[bot] avatar itxtoledo avatar jonathascarrijo avatar lzkill avatar mejnour avatar sttress avatar thiagosouza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.