Skip to content

Instantly share code, notes, and snippets.

@99darwin
Created June 19, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 99darwin/a324bbbeb6accb2c7387169529c53396 to your computer and use it in GitHub Desktop.
Save 99darwin/a324bbbeb6accb2c7387169529c53396 to your computer and use it in GitHub Desktop.
Simple coinmarketcap API call

CoinMarketCap Query

Simple API call to CoinMarketCap for the USD price of DIVI.

Dependencies

npm i --save request request-promise lodash
const rp = require('request-promise');
const _ = require('lodash');
let options = {
uri: 'https://api.coinmarketcap.com/v1/ticker/divi/',
qs: {
convert: 'USD'
},
headers: {
'User-Agent': 'Request-Promise'
},
json: true
};
rp(options)
.then((response) => {
let usdPrice = _.round(response[0].price_usd, 3)
console.log(`USD price: ${usdPrice}`);
// Render the price however you see fit
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment