Skip to content

Instantly share code, notes, and snippets.

@windoze95
Last active June 30, 2025 05:51
Show Gist options
  • Select an option

  • Save windoze95/f68549307e5fcb5cbce61907cae1dc32 to your computer and use it in GitHub Desktop.

Select an option

Save windoze95/f68549307e5fcb5cbce61907cae1dc32 to your computer and use it in GitHub Desktop.
Fetch cryptocurrency ticker data for Awesome WM widget
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