Skip to main content

Notifications

Power Automate - Building Flows
Suggested answer

Get crypto data from Coinmarketcap

Posted on by 4
I am trying to get data for id, name, price, market cap and volume using the coinmarketcap api. I have created a scheduled flow, initialised variables, created an array of token ids and used an HTTP get to pull out the data. I have then used Parse JSON with the schema generated from this sample payload:
{
  "status": {
    "timestamp": "2024-11-12T16:43:27.276Z",
    "error_code": 0,
    "error_message": null,
    "elapsed": 18,
    "credit_count": 1,
    "notice": null
  },
  "data": {
    "1": {
      "id": 1,
      "name": "Bitcoin",
      "symbol": "BTC",
      "slug": "bitcoin",
      "num_market_pairs": 11798,
      "date_added": "2010-07-13T00:00:00.000Z",
      "tags": [
        "mineable",
        "pow",
        "sha-256",
        "store-of-value",
        "state-channel",
        "coinbase-ventures-portfolio",
        "three-arrows-capital-portfolio",
        "polychain-capital-portfolio",
        "binance-labs-portfolio",
        "blockchain-capital-portfolio",
        "boostvc-portfolio",
        "cms-holdings-portfolio",
        "dcg-portfolio",
        "dragonfly-capital-portfolio",
        "electric-capital-portfolio",
        "fabric-ventures-portfolio",
        "framework-ventures-portfolio",
        "galaxy-digital-portfolio",
        "huobi-capital-portfolio",
        "alameda-research-portfolio",
        "a16z-portfolio",
        "1confirmation-portfolio",
        "winklevoss-capital-portfolio",
        "usv-portfolio",
        "placeholder-ventures-portfolio",
        "pantera-capital-portfolio",
        "multicoin-capital-portfolio",
        "paradigm-portfolio",
        "bitcoin-ecosystem",
        "ftx-bankruptcy-estate"
      ],
      "max_supply": 21000000,
      "circulating_supply": 19781271,
      "total_supply": 19781271,
      "is_active": 1,
      "infinite_supply": false,
      "platform": null,
      "cmc_rank": 1,
      "is_fiat": 0,
      "self_reported_circulating_supply": null,
      "self_reported_market_cap": null,
      "tvl_ratio": null,
      "last_updated": "2024-11-12T16:41:00.000Z",
      "quote": {
        "USD": {
          "price": 86970.06050101147,
          "volume_24h": 152229373269.7326,
          "volume_change_24h": 61.7735,
          "percent_change_1h": 0.31958302,
          "percent_change_24h": 2.85507507,
          "percent_change_7d": 23.89249677,
          "percent_change_30d": 38.77402996,
          "percent_change_60d": 46.28354332,
          "percent_change_90d": 47.22524777,
          "market_cap": 1720378335656.9036,
          "market_cap_dominance": 59.3802,
          "fully_diluted_market_cap": 1826371270521.24,
          "tvl": null,
          "last_updated": "2024-11-12T16:41:00.000Z"
        }
      }
    },
    "1027": {
      "id": 1027,
      "name": "Ethereum",
      "symbol": "ETH",
      "slug": "ethereum",
      "num_market_pairs": 9532,
      "date_added": "2015-08-07T00:00:00.000Z",
      "tags": [
        "pos",
        "smart-contracts",
        "ethereum-ecosystem",
        "coinbase-ventures-portfolio",
        "three-arrows-capital-portfolio",
        "polychain-capital-portfolio",
        "binance-labs-portfolio",
        "blockchain-capital-portfolio",
        "boostvc-portfolio",
        "cms-holdings-portfolio",
        "dcg-portfolio",
        "dragonfly-capital-portfolio",
        "electric-capital-portfolio",
        "fabric-ventures-portfolio",
        "framework-ventures-portfolio",
        "hashkey-capital-portfolio",
        "kenetic-capital-portfolio",
        "huobi-capital-portfolio",
        "alameda-research-portfolio",
        "a16z-portfolio",
        "1confirmation-portfolio",
        "winklevoss-capital-portfolio",
        "usv-portfolio",
        "placeholder-ventures-portfolio",
        "pantera-capital-portfolio",
        "multicoin-capital-portfolio",
        "paradigm-portfolio",
        "layer-1",
        "ftx-bankruptcy-estate"
      ],
      "max_supply": null,
      "circulating_supply": 120423718.45088653,
      "total_supply": 120423718.45088653,
      "is_active": 1,
      "infinite_supply": true,
      "platform": null,
      "cmc_rank": 2,
      "is_fiat": 0,
      "self_reported_circulating_supply": null,
      "self_reported_market_cap": null,
      "tvl_ratio": null,
      "last_updated": "2024-11-12T16:41:00.000Z",
      "quote": {
        "USD": {
          "price": 3254.2681713784345,
          "volume_24h": 67644582260.368225,
          "volume_change_24h": 33.5712,
          "percent_change_1h": -0.33198555,
          "percent_change_24h": -1.06654707,
          "percent_change_7d": 32.33328497,
          "percent_change_30d": 32.4248495,
          "percent_change_60d": 35.35924232,
          "percent_change_90d": 22.50022077,
          "market_cap": 391891074033.75793,
          "market_cap_dominance": 13.5264,
          "fully_diluted_market_cap": 391891074033.76,
          "tvl": null,
          "last_updated": "2024-11-12T16:41:00.000Z"
        }
      }
    }
  }
}
I have tried to use the Parse JSON output as the input for a for apply to each action  in which I want to extract the data and save it to sharepoint but I get an error saying
"Action 'Apply_to_each' failed: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@outputs('Parse_JSON')' is of type 'Object'. The result must be a valid array".
The parse json output looks identical to the input.
Any help would be greatly appreciated.
 
  • Suggested answer
    trice602 Profile Picture
    trice602 10,944 on at
    Get crypto data from Coinmarketcap
    Hi,
     
    Change your apply to each to this expression.

    outputs('Parse_JSON')?['data']
     
    Then use the individual properties to get each value:
     
    • item()?['id'] for the token ID
    • item()?['name'] for the name
    • item()?['quote']?['USD']?['price'] for the price
    • item()?['quote']?['USD']?['market_cap'] for the market cap
    • item()?['quote']?['USD']?['volume_24h'] for the volume
     
    ------------------------------------------------


    If this was helpful, please like and/or mark as a verified answer to help others find this too!


    Always glad to help! 💯💯💯💯💯

    Tom 

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

     


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard