Skip to content

Instantly share code, notes, and snippets.

@vastus
Last active September 30, 2022 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vastus/003e0bed58973ea17859365f5ad3ded0 to your computer and use it in GitHub Desktop.
Save vastus/003e0bed58973ea17859365f5ad3ded0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage:
# EMAIL='you@example.com' PASSWORD='your password' bash api_v2_getting_started.sh
TOKEN=
GET() {
curl -s -H 'content-type: application/json' \
-H "authorization: Bearer ${TOKEN}" \
"https://api.tokenterminal.com$1"
}
POST() {
curl -s -H 'content-type: application/json' \
"https://api.tokenterminal.com$1" \
-d "$2"
}
# get the API token
# note: login/logout/account resources are still under v1/
TOKEN=$(POST "/v1/login" '{"email": "'${EMAIL:?}'", "password": "'${PASSWORD:?}'"}' | jq -r '.token')
# see which metrics are available for AAVE
aave_metric_availability="/v2/projects/aave"
echo "GET $aave_metric_availability"
GET "$aave_metric_availability" | jq '.'
echo
echo "------------------------"
echo
# query AAVE fees and revenue
aave_fees_revenues="/v2/projects/aave/metrics?&start=2022-09-22&metrics=fees,revenue"
echo "GET $aave_fees_revenues"
GET $aave_fees_revenues | jq '.'
@vastus
Copy link
Author

vastus commented Sep 30, 2022

GET /v2/projects/aave
{
  "data": {
    "metric_availability": {
      "gmv": {
        "chains": [
          "ethereum",
          "avalanche",
          "polygon",
          "optimism",
          "arbitrum",
          "fantom"
        ],
        "versions": [
          "v2",
          "v3"
        ],
        "business_lines": [
          "lending"
        ],
        "business_types": [
          "interest"
        ],
        "has_component_data": false
      },
      "tvl": {
        "chains": [],
        "versions": [],
        "business_lines": [],
        "business_types": [],
        "has_component_data": false
      },
      "fees": {
        "chains": [
          "ethereum",
          "avalanche",
          "polygon",
          "optimism",
          "arbitrum",
          "fantom"
        ],
        "versions": [
          "v2",
          "v3"
        ],
        "business_lines": [
          "lending"
        ],
        "business_types": [
          "interest"
        ],
        "has_component_data": false
      },
      "revenue": {
        "chains": [
          "ethereum",
          "avalanche",
          "polygon",
          "optimism",
          "arbitrum",
          "fantom"
        ],
        "versions": [
          "v2",
          "v3"
        ],
        "business_lines": [
          "lending"
        ],
        "business_types": [
          "interest"
        ],
        "has_component_data": false
      },
      "treasury": {
        "chains": [
          "ethereum"
        ],
        "versions": [],
        "business_lines": [],
        "business_types": [
          "default"
        ],
        "has_component_data": false
      },
      "active_users": {
        "chains": [],
        "versions": [],
        "business_lines": [],
        "business_types": [],
        "has_component_data": false
      },
      "tokenholders": {
        "chains": [
          "ethereum"
        ],
        "versions": [],
        "business_lines": [],
        "business_types": [],
        "has_component_data": false
      },
      "fees_supply_side": {
        "chains": [
          "ethereum",
          "avalanche",
          "polygon",
          "optimism",
          "arbitrum",
          "fantom"
        ],
        "versions": [
          "v2",
          "v3"
        ],
        "business_lines": [
          "lending"
        ],
        "business_types": [
          "interest"
        ],
        "has_component_data": false
      },
      "token_incentives": {
        "chains": [
          "polygon",
          "ethereum",
          "avalanche"
        ],
        "versions": [
          "v2",
          "v3"
        ],
        "business_lines": [
          "lending"
        ],
        "business_types": [
          "interest"
        ],
        "has_component_data": false
      }
    }
  }
}
GET /v2/projects/aave/metrics?&start=2022-09-22&metrics=fees,revenue
[
  {
    "timestamp": "2022-09-29T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 57238.95653734989,
    "revenue": 6353.888489335015
  },
  {
    "timestamp": "2022-09-28T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 106471.82541400866,
    "revenue": 12598.272037410527
  },
  {
    "timestamp": "2022-09-27T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 248655.2147937668,
    "revenue": 29025.230823508744
  },
  {
    "timestamp": "2022-09-26T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 256251.27446442458,
    "revenue": 30392.940819686366
  },
  {
    "timestamp": "2022-09-25T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 250153.7785111575,
    "revenue": 29479.519155737802
  },
  {
    "timestamp": "2022-09-24T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 255233.81918228697,
    "revenue": 30759.67178831875
  },
  {
    "timestamp": "2022-09-23T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 252512.04714604432,
    "revenue": 30705.60083386551
  },
  {
    "timestamp": "2022-09-22T00:00:00.000Z",
    "project_name": "Aave",
    "fees": 263628.15997100115,
    "revenue": 32840.86135770859
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment