AnsweredAssumed Answered

Creating HTTP request

Question asked by psijmons on Nov 21, 2018
Latest reply on Nov 21, 2018 by fmpdude

I am trying to create an HTTP request that used to be quite simple, but due to an upcoming change in API, I can't get it to work.

The code that needs to be processed is:

 

const rp = require('request-promise');
const requestOptions = {
  method: 'GET',
  uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
  qs: {
    start: 1,
    limit: 5000,
    convert: 'USD'
  },
  headers: {
    'X-CMC_PRO_API_KEY': 'e967e07b-78b5-4db6-9e85-940ef8a313c2'
  },
  json: true,
  gzip: true
};

rp(requestOptions).then(response => {
  console.log('API call response:', response);
}).catch((err) => {
  console.log('API call error:', err.message);
});

 

The API key is valid and will be destroyed after this post is solved.
More details are here:
CoinMarketCap Professional API Documentation

 

Once I get the http reply, I will have no problem dealing with the JSON result, but I'm doing something wrong in the URL syntax.  I may be close but it's the type of code that one typo will just kill it. Any help appreciated.

TIA

Peter

Outcomes