Skip to content

Instantly share code, notes, and snippets.

@kylewin
Last active December 30, 2023 06:32
Show Gist options
  • Save kylewin/50318958041e1cb8c7b615cf9302681a to your computer and use it in GitHub Desktop.
Save kylewin/50318958041e1cb8c7b615cf9302681a to your computer and use it in GitHub Desktop.
Get Crypto price
symbol=$(echo $1 | tr 'a-z' 'A-Z')
filter=".data.$symbol.name,.data.$symbol.quote.USD.price"
token=$(security find-generic-password -a "$USER" -s 'CMC_API_TOKEN' -w)
curl -s -H "X-CMC_PRO_API_KEY: $token" -H "Accept: application/json" -d "symbol=$symbol" "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest" -G | jq $filter | tee >(pbcopy)
@kylewin
Copy link
Author

kylewin commented Dec 30, 2023

Reg an CMC API Token at https://coinmarketcap.com
Add CMC_API_TOKEN to macos-keychain

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