Get specific JSON data value using array from Coin Market Cap API

0 votes

I want to get the symbol and other information using the "name" in my array.

$.getJSON("//api.coinmarketcap.com/v1/ticker/?limit=0", function(data) {

    var crypto = [
      "Ethereum",
      "Ripple",
      "Tron", 
    ];

    // used for array to get length
    var arrayLength = crypto.length;

    for (var i = 0; i < data.length; i++) {

        console.log( data[i].name == crypto[i] );
    }
  });

I've tried to use:

console.log( data[i].name == crypto[i] );

but can't get this to work. As of now it lists everything when I only want to list data from the items in my array.

I want to get the data in the array using the name to retrieve its information from the API.

Oct 8, 2018 in Blockchain by slayer
• 29,350 points
1,635 views

1 answer to this question.

0 votes

use inArray function.

example:

$.getJSON("//api.coinmarketcap.com/v1/ticker/?limit=0", function(data) {

    var crypto = [
      "Ethereum",
      "Ripple",
      "Tron", 
    ];

    // used for array to get length
    var arrayLength = crypto.length;

    for (var i = 0; i < data.length; i++) {
        if(jQuery.inArray(data[i].name, crypto) !== -1)
            console.log('Finded: ' + data[i].name);
    }
  });
answered Oct 8, 2018 by Omkar
• 69,210 points

Related Questions In Blockchain

0 votes
1 answer

Is there a way to get the market cap or market cap rank of a coin using the Binance API?

This is how I did so: https://www.binance.com/exchange-api/v2/public/asset-service/product/get-products Get this ...READ MORE

answered Apr 6, 2022 in Blockchain by Aditya
• 7,680 points
2,408 views
0 votes
1 answer
0 votes
1 answer

Cant get a specific value in JSON/PHP

Convert the json-string to a php-array and ...READ MORE

answered Sep 11, 2018 in Blockchain by slayer
• 29,350 points
2,568 views
0 votes
1 answer

How to get value from solidity contract using java?

web3j caters for this very use case. It ...READ MORE

answered Sep 28, 2018 in Blockchain by slayer
• 29,350 points
1,735 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,663 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,215 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,129 views
0 votes
1 answer

Ethereum solidity: Unable to get value from another contract

I have faced similar issues when compiling ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,210 points
1,469 views
0 votes
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP