Skip to content

Instantly share code, notes, and snippets.

@Anon-Exploiter
Created March 17, 2021 17:51
Show Gist options
  • Save Anon-Exploiter/0b27e01d72b53a11e46141b926a3c6d5 to your computer and use it in GitHub Desktop.
Save Anon-Exploiter/0b27e01d72b53a11e46141b926a3c6d5 to your computer and use it in GitHub Desktop.
Get BTC (USD) price/minute in discord server
# Get USD price of BTC (changing) per minute in your discord server!
# Just replace the webhook_url variable and create a cron as you see fit.
#!/usr/bin/python3
import requests
import json
# BTCPRICE=`curl -s https://api.coindesk.com/v1/bpi/currentprice/USD.json | jp bpi.USD.rate | cut -d '"' -f2`
# JSON="{\"content\": \"Current price of BTC is: **$BTCPRICE** USD\"}"
# curl -d "$JSON" -H "Content-Type: application/json"
WEBHOOK_URL = "https://discord.com/api/webhooks/..."
if __name__ == '__main__':
response = requests.get('https://api.coindesk.com/v1/bpi/currentprice/USD.json').text
data = json.loads(response)['bpi']['USD']['rate']
print(data)
requests.post(WEBHOOK_URL,
json = {
"content": f"Current price of BTC is: **{data}** USD"
}
)
print("[#] Posted to server")
@Anon-Exploiter
Copy link
Author

Also, be sure to mute the channel afterwards! 😛

Output:

image

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