Open2

axiosでDappRadarのAPIからデータを取得する

yuyu

データ取得のサンプルコード


import axios from 'axios'
import fs from 'fs'

const baseUrl = `https://api.dappradar.com/XXXXXXXX/`
const primeApiKey = `XXXXXXXXXXXXXXXX`

async function sendRequest() {
  try {
    const response = await axios({
      method: 'GET',
      url: baseUrl + 'dapps/top/uaw?range=30d&top=100',
      headers: {
        'X-BLOBR-KEY': primeApiKey
      }
    })

    console.log(response.data)

  } catch (error) {
    console.error('Request failed', error)
  }
}

sendRequest()

yuyu

レスポンスの例

{
  "success": true,
  "chain": null,
  "category": null,
  "range": "30d",
  "top": 10,
  "results": [
    {
      "dappId": 18305,
      "name": "Stargate",
      "description": "A Composable Omnichain Native Asset Bridge",
      "fullDescription": "<p>Stargate is a fully composable liquidity transport protocol that lives at the heart of omnichain DeFi.</p>",
      "logo": "https://dashboard-assets.dappradar.com/geRRcWz9IdTwSrm1/document/18305/stargatefinance-dapp-defi-ethereum-logo_66dc9532020488c50870b5dae3e34654.png",
      "link": "https://dappradar.com/dapp/stargate",
      "website": "https://stargate.finance/",
      "chains": [
        "arbitrum",
        "avalanche",
        "base",
        "binance-smart-chain",
        "ethereum",
        "fantom",
        "optimism",
        "polygon"
      ],
      "categories": [
        "defi"
      ],
      "socialLinks": [
        {
          "title": "discord",
          "url": "https://stargate.finance/discord",
          "type": "discord"
        },
        {
          "title": "medium",
          "url": "https://medium.com/stargate-official",
          "type": "medium"
        },
        {
          "title": "telegram",
          "url": "https://t.me/joinchat/LEM0ELklmO1kODdh",
          "type": "telegram"
        },
        {
          "title": "twitter",
          "url": "https://twitter.com/StargateFinance",
          "type": "twitter"
        }
      ],
      "tags": [
        {
          "id": "10",
          "name": "Layer 2",
          "slug": "layer-2"
        },
        {
          "id": "11",
          "name": "Content Creation",
          "slug": "content-creation"
        },
        {
          "id": "12",
          "name": "Art",
          "slug": "art"
        },
        {
          "id": "13",
          "name": "Pools",
          "slug": "pools"
        },
        {
          "id": "14",
          "name": "Gambling",
          "slug": "gambling"
        },
        {
          "id": "15",
          "name": "Knowledge",
          "slug": "knowledge"
        },
        {
          "id": "16",
          "name": "Farming",
          "slug": "farming"
        },
        {
          "id": "18",
          "name": "Discussions",
          "slug": "discussions"
        },
        {
          "id": "19",
          "name": "Photos",
          "slug": "photos"
        },
        {
          "id": "1",
          "name": "NFT",
          "slug": "nft"
        },
        {
          "id": "20",
          "name": "Videos",
          "slug": "videos"
        },
        {
          "id": "21",
          "name": "Move to Earn",
          "slug": "move-to-earn"
        },
        {
          "id": "22",
          "name": "Metaverse",
          "slug": "metaverse"
        },
        {
          "id": "23",
          "name": "Sports",
          "slug": "sports"
        },
        {
          "id": "24",
          "name": "Social",
          "slug": "social"
        },
        {
          "id": "2",
          "name": "Exchanges",
          "slug": "exchanges"
        },
        {
          "id": "3",
          "name": "Staking",
          "slug": "staking"
        },
        {
          "id": "4",
          "name": "Yield",
          "slug": "yield"
        },
        {
          "id": "5",
          "name": "DeFi",
          "slug": "defi"
        },
        {
          "id": "6",
          "name": "Games",
          "slug": "games"
        },
        {
          "id": "7",
          "name": "Play to Earn",
          "slug": "play-to-earn"
        },
        {
          "id": "8",
          "name": "Marketplaces",
          "slug": "marketplaces"
        },
        {
          "id": "9",
          "name": "Governance",
          "slug": "governance"
        }
      ],
      "metrics": {
        "transactions": 2020813,
        "transactionsPercentageChange": -35.39,
        "uaw": 1162607,
        "uawPercentageChange": -30.14,
        "volume": 1203098437.03,
        "volumePercentageChange": -38.44,
        "balance": 363754212.87,
        "balancePercentageChange": -8.59
      }
    },
    ...
  ]
}