Added World Coin Index Price Feed in Crypto Price Checker
The NPM module "cryptoticker" was only using CoinMarketCap, now I feel WorldCoinIndex is also gives a somewhat correct price. So now I have integrated WorldCoinIndex in the cryptoticker. One thing to note that WorldCoinIndex uses API Key, now if you are using the NPM module you need to generate your own key and then send it via the function.
For creating the new Key you need to go to https://www.worldcoinindex.com/apiservice and then click on "Generate your Key" as shown below.
Now next is to query it using the below code where API_KEY is the key you have generated
crypto.priceWCI('eth','API_KEY').then(a=>console.log(a));
crypto.priceWCI('bitcoin','API_KEY').then(a=>console.log(a));
which will give the result as shown below :
Development
So for development you need to export priceWCI as shown below where I am getting the crypto and key and then sending you the value of it. I am not manipulating the data and sending the Promise so that if any application uses it they can take whole advantage of the unmanipulated data.
exports.priceWCI = (crypto, key) => {
return new Promise((resolve, reject) => {
if(!crypto){
reject(new Error('Coin Not Found'));
}else if(!key){
reject(new Error('Key Not Provided'));
}else{
const cryptoId = cryptoValues[crypto.toLowerCase()] || crypto.toLowerCase();
const requestUrl = worldCoinIndexURL + key;
request(requestUrl, function (error, res, body) {
if(!error && res.statusCode === 200) {
const response = JSON.parse(body);
var filteredJson = response.Markets.filter(function(cryptoValue) {
return cryptoValue.Name.toLowerCase() === cryptoId;
});
resolve(filteredJson);
}else {
reject(new Error('Coin Not Found'));
}
});
}
});
Commits
- https://github.com/codingdefined/cryptoticker/commit/c24b7152c18aef8b4a3ae072e4bf5794007312f9
- https://github.com/codingdefined/cryptoticker/commit/0a8cf44fbd57e2ad76ca6b4186602bd4e44c0503
Proof Of Work
I have the same name in github, but I am also providing the Logged in session screenshot.
Posted on Utopian.io - Rewarding Open Source Contributors