1.0.1 • Published 5 years ago

coinlib-api v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Coinlib API Client for Node.js

A Node.js wrapper for the Coinlib API with no dependencies.

• Installation

Latest version: 1.0.1

npm install coinlib-api

• Testing

npm test

• Coinlib API Documentation

For complete API documentation, up-to-date parameters, reponses and errors, please refer to https://coinlib.io/apidocs.

• Getting your API Keys

Access to the Coinlib.com API requires a free account. Sign up at https://coinlib.io.

Log into your account and navigate to the profile settings page at https://coinlib.io/profile then find the "API" section at the bottom.

Fill in "Where will you use our API?" and then generate your API key.

• Quick Start Example

//1. Import coinlib-api
const Coinlib = require('coinlib-api');

//2. Initiate the Coinlib API Client with your API key
const CoinlibClient = new Coinlib(COINLIB_API_KEY);

//3. Make calls
var func = async() => {
  let data = await CoinlibClient.ping();
};

• Setting your Initial Coinlib Parameters

You'll need to set up a few parameters before using the Coinlib module. Upon instantiation, it's recommended to set the API Key.

Key

The API Key is required to be set before making any valid requests.

Setting the Key

CoinlibClient.setKey(COINLIB_API_KEY);
//Alternatively
CoinlibClient.key = COINLIB_API_KEY;

• Constants

This module provides helper constants for use in calls.


Coinlib.ORDER

Order results in specific calls by using one of the following values.

KeyUsageDescription
RANK_ASCCoinlib.ORDER.RANK_ASCOrder by Coinlib rank (ascending)
RANK_DESCCoinlib.ORDER.RANK_DESCOrder by Coinlib rank (descending)
VOLUME_ASCCoinlib.ORDER.VOLUME_ASCOrder by volume (ascending)
VOLUME_DESCCoinlib.ORDER.VOLUME_DESCOrder by volume (descending)
PRICE_ASCCoinlib.ORDER.PRICE_ASCOrder by price (ascending)
PRICE_DESCCoinlib.ORDER.PRICE_DESCOrder by price (descending)
DATE_ADDED_ASCCoinlib.ORDER.DATE_ADDED_ASCOrder by date added (ascending)
DATE_ADDED_DESCCoinlib.ORDER.DATE_ADDED_DESCOrder by date added (descending)

• Making Calls

All calls using the CoinlibClient are asynchronous.

All calls are returned in the following format:

{
    success: Boolean,
    message: String,
    code: Number,
    data: Object
}

The Coinlib splits up the currently available calls outline in the official Coinlib API documentation into one parts. (Aside from the global call.)

NamespaceUsageDescription
coinsCoinlib.coins[...]Calls related to coins

• Global

Global market stats.

global()

Retrieve global market stats.

Params:

  • params: Object - Parameters to pass through to the request
  • params.pref: String default: USD - Symbol to use for prices and other market values

Usage Example:

let data = await CoinlibClient.global();

• Coins

Calls related to coins.

coins.list()

List all supported coins with data - paginated by 100.

Params:

  • params: Object - Parameters to pass through to the request
  • params.pref: String default: USD - Symbol to use for prices and other market values
  • params.page: Number - Starting from 1. Per official documentation: "For now we return 100 results per page, but this may change without warning."
  • params.order: String - Order results by Coinlib.ORDER[*]

Usage Example:

let data = await Coinlib.coins.list();

coins.fetchInfo()

Fetch a specific coin's information.

Params:

  • coinSymbols: String|Array - (Required) Single coin symbol or a list of symbols.
  • params: Object - Parameters to pass through to the request
  • params.pref: String default: USD - Symbol to use for prices and other market values

Usage Example:

let data = await Coinlib.coins.fetchInfo(['BTC', 'ETH']);
//
let data = await Coinlib.coins.fetchInfo('BTC', {
  pref: 'USD'
});

• Say Hi

Find me on Gab: @markmiscavage.

Tweet at me: @markmiscavage.

• License

MIT License

Copyright (c) 2018 Mark Miscavage

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.