Skip to first unread message

aumandg

unread,
May 17, 2018, 8:31:39 PM5/17/18
to mitappinv...@googlegroups.com
I have this API call https://api.coinmarketcap.com/v2/ticker/?convert=USD&limit=10

I have the following blocks and I am not understanding why it is not finding BTC in the list, I get "false".  I have tested "is a list thing" with response "true".  


aumandg

unread,
May 17, 2018, 9:32:12 PM5/17/18
to MIT App Inventor Forum


Farzeen Harunani

unread,
May 18, 2018, 8:36:07 AM5/18/18
to MIT App Inventor Forum
I'm just guessing here, but are you sure that the string "BTC" is exactly what's being returned? No spaces or anything?
Farzeen

Abraham Getzler

unread,
May 18, 2018, 10:31:00 AM5/18/18
to MIT App Inventor Forum
What are you looking to get when you look for "BTC' in an object with this  structure? :
{
    "data": {
        "1": {
            "id": 1, 
            "name": "Bitcoin", 
            "symbol": "BTC", 
            "website_slug": "bitcoin", 
            "rank": 1, 
            "circulating_supply": 17040550.0, 
            "total_supply": 17040550.0, 
            "max_supply": 21000000.0, 
            "quotes": {
                "USD": {
                    "price": 8111.23, 
                    "volume_24h": 6120730000.0, 
                    "market_cap": 138219820377.0, 
                    "percent_change_1h": -0.3, 
                    "percent_change_24h": -2.6, 
                    "percent_change_7d": -6.34
                }
            }, 
            "last_updated": 1526652872
        }, 
        "1027": {
            "id": 1027, 
            "name": "Ethereum", 
            "symbol": "ETH", 
            "website_slug": "ethereum", 
            "rank": 2, 
            "circulating_supply": 99512624.0, 
            "total_supply": 99512624.0, 
            "max_supply": null, 
            "quotes": {
                "USD": {
                    "price": 679.625, 
                    "volume_24h": 2463910000.0, 
                    "market_cap": 67631267085.0, 
                    "percent_change_1h": -0.55, 
                    "percent_change_24h": -3.48, 
                    "percent_change_7d": -1.25
                }
            }, 
            "last_updated": 1526652856
        }, 
        "52": {
            "id": 52, 
            "name": "Ripple", 
            "symbol": "XRP", 
            "website_slug": "ripple", 
            "rank": 3, 
            "circulating_supply": 39189968239.0, 
            "total_supply": 99992233977.0, 
            "max_supply": 100000000000.0, 
            "quotes": {
                "USD": {
                    "price": 0.663241, 
                    "volume_24h": 360078000.0, 
                    "market_cap": 25992393725.0, 
                    "percent_change_1h": -1.3, 
                    "percent_change_24h": -4.86, 
                    "percent_change_7d": -4.03
                }
            }, 
            "last_updated": 1526652841
        }, 
        "1831": {
            "id": 1831, 
            "name": "Bitcoin Cash", 
            "symbol": "BCH", 
            "website_slug": "bitcoin-cash", 
            "rank": 4, 
            "circulating_supply": 17134500.0, 
            "total_supply": 17134500.0, 
            "max_supply": 21000000.0, 
            "quotes": {
                "USD": {
                    "price": 1165.77, 
                    "volume_24h": 878361000.0, 
                    "market_cap": 19974886065.0, 
                    "percent_change_1h": -0.79, 
                    "percent_change_24h": -9.1, 
                    "percent_change_7d": -16.94
                }
            }, 
            "last_updated": 1526652854
        }, 


 Are you looking for the smallest object that contains the tag:value "symbol": "BTC"
so you can extract sibling tags/value pairs?

ABG

Ghica

unread,
May 18, 2018, 11:57:09 AM5/18/18
to MIT App Inventor Forum
Here is a set of blocks that plow through your JSON structure. Unfortunately you have to find out what the structure is before you can find things.
I think there are generic procedures that can do this better, but still you have to know what the structure is.

If you execute the .aia (attached) you will see this: 

Cheers, Ghica.
JSONparsing.aia

Abraham Getzler

unread,
May 18, 2018, 2:32:58 PM5/18/18
to MIT App Inventor Forum
I took a different tack, trying for a more general solution
for the next person looking to search in a JSON tree.

See attached.

ABG

Capture.PNG
Designer.PNG
JSON_finder.aia
USD_conversions.json
blocks.png

aumandg

unread,
May 18, 2018, 7:48:59 PM5/18/18
to MIT App Inventor Forum
Before the api call was changed, I was able to find the call letters and then pull the price based on where the call letters where.  The blocks below, since they changed there api call it does not work any longer so I am trying to do the same thing, so the app works again.


aumandg

unread,
May 18, 2018, 10:23:59 PM5/18/18
to MIT App Inventor Forum
I believe I have what I need, will do some more testing to see if I can get the app working correctly again with the following blocks.


Reply all
Reply to author
Forward
0 new messages