I was using this code to get data of the currency like price, market cap etc... I'm preparing new bot and the request is not working due api error...
Code:
'use strict';
const rp = require('request-promise');
const requestOptions = {
method: 'GET',
uri: 'https://3rdparty-apis.coinmarketcap.com/v1/cryptocurrency/widget?id=3501&convert=BTC,ETH,USD',
headers: {
json: true,
gzip: true
}
};
rp(requestOptions).then(response => {
const answer = JSON.parse(response)
console.log('API Call response:', answer["data"]["3501"]["quote"]);
}).catch((err) => {
console.log('API Call error:', err.message);
});
Error:
API Call error: 403 - "error code: 1020"
Any ideas what is wrong? https://3rdparty-apis.coinmarketcap.com/v1/cryptocurrency/widget?id=3501&convert=BTC,ETH,USD
It works perfectly fine and i can see all the data when im puttin link inside web browser.
Set your user agent like:
'use strict';
const rp = require('request-promise');
const requestOptions = {
method: 'GET',
uri: 'https://3rdparty-apis.coinmarketcap.com/v1/cryptocurrency/widget?id=3501&convert=BTC,ETH,USD',
headers: {
json: true,
gzip: true,
'User-Agent': 'Discordbot/2.0'
}
};