Skip to content

Instantly share code, notes, and snippets.

@smycek
Last active September 22, 2021 03:28
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 smycek/c5ed1e98bc754e4046fcb8f1685388af to your computer and use it in GitHub Desktop.
Save smycek/c5ed1e98bc754e4046fcb8f1685388af to your computer and use it in GitHub Desktop.
Using the CLI to fetch CoinGecko prices via API

Fetch prices using CLI and print json to stdout

One liner to fetch the simple price of any token listed on CoinGecko via their open API.
You need the utilities curl and jq. Type the command below into your terminal:

curl -s -X 'GET' 'https://api.coingecko.com/api/v3/simple/price?ids=dragon-egg%2Cstorm-token%2Cwrapped-avax%2Cstellar%2Cmonero%2Cbitcoin%2Cethereum&vs_currencies=usd%2Ceur&include_market_cap=false&include_24hr_vol=false&include_24hr_change=false&include_last_updated_at=false' -H 'accept: application/json' | jq . --sort-keys && date

Output

{
  "bitcoin": {
    "eur": 35902,
    "usd": 42097
  },
  "dragon-egg": {
    "eur": 20.4,
    "usd": 23.92
  },
  "ethereum": {
    "eur": 2443.86,
    "usd": 2865.55
  },
  "monero": {
    "eur": 192.26,
    "usd": 225.44
  },
  "stellar": {
    "eur": 0.23257,
    "usd": 0.2727
  },
  "storm-token": {
    "eur": 2.05,
    "usd": 2.41
  },
  "wrapped-avax": {
    "eur": 54.24,
    "usd": 63.6
  }
}
Wed Sep 22 04:49:51 CEST 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment