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

coinranking-api

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coinranking-api

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

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Coinranking API Client for Node.js

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

• Installation

Latest version: 1.0.0

npm install coinranking-api

https://www.npmjs.com/package/coinranking-api

• Coinranking API Documentation

For complete API documentation, up-to-date parameters, responses and errors, please refer to https://docs.coinranking.com.

• Quick Start Example

//1. Import coinranking-api
const Coinranking = require('coinranking-api');

//2. Initiate the Coinranking API Client
const CoinrankingClient = new Coinranking();

//3. Make calls
var func = async() => {
  let data = await Coinranking.stats.global();
};

• Constants

This module provides helper constants for use in calls.


Coinranking.SORT

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

KeyUsageDescription
COINRANKINGCoinranking.SORT.COINRANKINGSort results by Coinranking's system
PRICECoinranking.SORT.PRICESort results by price
MARKET_CAPCoinranking.SORT.MARKET_CAPSort results by market cap
CHANGECoinranking.SORT.CHANGESort results by change

Coinranking.ORDER

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

KeyUsageDescription
DESCCoinranking.ORDER.DESCOrder results by descending Coinranking.SORT values
ASCCoinranking.ORDER.ASCOrder results by ascending Coinranking.SORT values

Coinranking.TIME_PERIODS

Time period where the change and history are based on.

KeyUsageDescription
HOUR_24Coinranking.TIME_PERIODS.HOUR_2424 Hours
DAY_7Coinranking.TIME_PERIODS.DAY_77 days
DAY_30Coinranking.TIME_PERIODS.DAY_3030 days
YEAR_1Coinranking.TIME_PERIODS.YEAR_11 year
YEAR_5Coinranking.TIME_PERIODS.YEAR_55 years

• Making Calls

All calls using the CoinrankingClient are asynchronous.

All calls are returned in the following format:

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

The CoinrankingClient splits up the currently available calls outline in the official Coinranking API documentation into 4 parts.

NamespaceUsageDescription
coinsCoinranking.coins[...]Calls related to coins
statsCoinranking.stats[...]Calls related to global stats
marketsCoinranking.markets[...]Calls related to markets
exchangesCoinranking.exchanges[...]Calls related to exchanges

• Coins

Calls related to coins.

coins.all()

List all coins with data (name, price, history, rank, etc) - paginated by 50

Params:

  • params: Object - Parameters to pass through to the request
  • params.base: {String} - [default: USD] - Base currency
  • params.timePeriod: {String} - [default: 24h] - One of Coinranking.TIME_PERIODS
  • params.prefix: {String} - Search to filter the list on. Only one of prefix, symbols, slugs or IDs parameters can be used at once
  • params.symbols: {String} - Symbols to filter the list on. Separated by comma. Only one of prefix, symbols, slugs or IDs parameters can be used at once
  • params.slugs: {String} - Slugs to filter the list on. Separated by comma. Only one of prefix, symbols, slugs or IDs parameters can be used at once
  • params.ids: {String} - IDs to filter the list on. Separated by comma. Only one of prefix, symbols, slugs or IDs parameters can be used at once
  • params.sort: {String} - [default: coinranking] - One of Coinranking.SORT
  • params.limit: {String|Number} - [default: 50] - Limit. Used for pagination. Range: 0-100
  • params.offset: {String|Number} - [default: 0] - Offset. Used for pagination
  • params.order: {String} - [default: desc] - One of Coinranking.ORDER

Usage Example:

let data = await CoinrankingClient.coins.all({});

coins.fetch()

Get current data (name, price, history, rank, etc.) for a coin.

  • coinId: {String|Number} - (Required) The coin id (can be obtained from coins.all()) eg. 1
  • params: {Object} - Parameters to pass through to the request
  • params.base: {String} - [default: USD] - Base currency
  • params.timePeriod: {String} - [default: 24h]- One of Coinranking.TIME_PERIODS

Usage Example:

let btc = '1'; //Coin ID
let data = await CoinrankingClient.coins.fetch(btc, {});

coins.history()

Get pricing history for a given coin.

  • coinId: {String|Number} - (Required) The coin id (can be obtained from coins.all()) eg. 1
  • params: {Object} - Parameters to pass through to the request
  • params.base: {String} - [default: USD] - Base currency
  • params.timeframe: {String} - [default: 24h]- One of Coinranking.TIME_PERIODS

Usage Example:

let btc = '1'; //Coin ID
let data = await CoinrankingClient.coins.history(btc, {});

• Stats

Calls related to global stats.

stats.global()

Get global stats - total coins, markets, market cap, 24 hour volume

Params:

  • params: Object - Parameters to pass through to the request
  • params.base: {String} - [default: USD] - Base currency

Usage Example:

let data = await CoinrankingClient.stats.global({});

• Markets

Calls related to markets

markets.all()

List all markets for currencies - paginated by 50

Params:

  • params: Object - Parameters to pass through to the request
  • params.refCurrencyId: {String|Number} - [default: 1509] - Id of currency in which prices are calculated, defaults to USD (i.e. CoinId: 1509)
  • params.currencyId: {String|Number} - Filter markets with specific currency as either base or quote. Specifying a currencyId will also alter how prices are shown: By default all the markets will show the price of the base in the refCurrency (e.g. an ETH/BTC market will show the price of ETH). By specifying a currencyId the prices of this currency will always be shown, disregarding whether or not this currency represents the base or the quote in the market (e.g. by specifying BTC as currency, both ETH/BTC as BTC/USD markets will show prices of BTC)
  • params.toCurrencyId: {String}- Filter markets with specific currency as either base or quote. The toCurrencyId will not alter how the prices will be shown, but will keep the base price. This can be combined with the currencyId variable to get specific markets.
  • params.baseCurrencyId: {String} - Filter markets with specific currency as base
  • params.quoteCurrencyId: {String} - Filter markets with specific currency as quote
  • params.sourceId: {String} - Filter markets from specific source
  • params.limit: {String|Number} - [default: 50] - Limit. Used for pagination. Range: 0-100
  • params.offset: {String|Number} - [default: 0] - Offset. Used for pagination
  • params.order: {String} - [default: volume] - Sort by either volume or price.
  • params.orderDirection: {String} [default: desc] - One of Coinranking.ORDER

Usage Example:

let data = await CoinrankingClient.markets.all({});

• Exchanges

Calls related to exchanges

exchanges.all()

List all exchanges - paginated by 50

Params:

  • params: Object - Parameters to pass through to the request
  • params.refCurrencyId: {String|Number} - [default: 1509] - Id of currency in which prices are calculated, defaults to USD (i.e. CoinId: 1509)
  • params.limit: {String|Number} - [default: 50] - Limit. Used for pagination. Range: 0-100
  • params.offset: {String|Number} - [default: 0] - Offset. Used for pagination
  • params.order: {String} - [default: volume] - Sort by either volume, numberOfMarkets or lastTickerCreatedAt
  • params.orderDirection: {String} - [default: desc] - One of Coinranking.ORDER

Usage Example:

let data = await CoinrankingClient.exchanges.all({});

• Say Hi

Find me on Gab: @markmiscavage.

Tweet at me: @markmiscavage.

• License

MIT License

Copyright (c) 2019 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.

Keywords

FAQs

Package last updated on 28 Jan 2019

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