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

coinmarketcal-node

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coinmarketcal-node

A node.js wrapper for CoinMarketCal API @ https://api.coinmarketcal.com/.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

coinmarketcal-node

A node.js wrapper for the coinmarketcal API.

Installation

$ npm install coinmarketcal-node

Quick Start

Get API keys from https://api.coinmarketcal.com/.

Initialize client with client_id and client_secret.

const coinmarketcal = new CoinMarketCal(client_id, client_secret);

Generate an access token with client and pass in a callback function which has the access_token as a parameter.

coinmarketcal.generateAccessToken(callback);

Within the callback, use the access_token to request other API resources.

const callback = (access_token) => {
  coinmarketcal.getCategories(access_token, categoriesCb);
  coinmarketcal.getCoins(access_token, coinsCb);
  coinmarketcal.getEvents(access_token, {}, eventsCb);
}

Detailed Example

const CoinMarketCal = require("coinmarketcal-node");

// Get API keys @ https://api.coinmarketcal.com/
const authObj = {
    client_id: "",
    client_secret: "",
};

const coinmarketcal = new CoinMarketCal(authObj.client_id, authObj.client_secret);

// Uncomment the console.log()'s below to view response data. 
const useAccessToken = (response) => {
    const { access_token } = response;

    // console.log(access_token);

    const listCategories = (categories) => {
        // console.log(categories);
    };

    const listCoins = (coins) => {
        // console.log(coins);
    };

    const listEvents = (events) => {
        // console.log(events);
    };

    // These resources only require a valid access token to return data.
    coinmarketcal.getCategories(access_token, listCategories);
    coinmarketcal.getCoins(access_token, listCoins);

    /*
    The event resource takes additional query params for filtering events. Please review the 
    the additional parameters for the events resource @ https://api.coinmarketcal.com/
    */

    const eventQuery = {
        page: 1, // integer? - Default value: 1
        max: 5, // integer? - Default value: 16 Max: 300
        // dateRangeStart?: string - Default Value: Today - Format - "MM/DD/YYYY",
        // dateRangeEnd?: string - Default Value: Most recent event - Format - "MM/DD/YYYY",
        // coins?: string - "bitcoin,ethereum,ripple",
        // categories?: string - "1,2,3",
        // sortBy?: string - "created_desc" || "hot_events",
        // showOnly?: string - "hot_events",
    };

    coinmarketcal.getEvents(access_token, eventQuery, listEvents);
};

// Generate access token with a callback function to access response data.
coinmarketcal.generateAccessToken(useAccessToken);

Keywords

FAQs

Package last updated on 19 Mar 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