Last active
June 30, 2025 05:51
-
-
Save windoze95/f68549307e5fcb5cbce61907cae1dc32 to your computer and use it in GitHub Desktop.
Fetch cryptocurrency ticker data for Awesome WM widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local json = require("json") | |
| function command(cmd, raw) | |
| local f = assert(io.popen(cmd, 'r')) | |
| local s = assert(f:read('*a')) | |
| f:close() | |
| if raw then return s end | |
| s = string.gsub(s, '^%s+', '') | |
| s = string.gsub(s, '%s+$', '') | |
| s = string.gsub(s, '[\n\r]+', ' ') | |
| return s | |
| end | |
| local res = command("curl -s 'https://api.coinmarketcap.com/v1/ticker/?limit=2'") | |
| local o = json.decode(res) | |
| local eth = o[2] | |
| print(eth["name"], eth["price_usd"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment