Skip to content

Instantly share code, notes, and snippets.

@cameronhotchkies
Created August 5, 2019 00:05
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 cameronhotchkies/7e7ccf6c599737678abc0cc2d6e81384 to your computer and use it in GitHub Desktop.
Save cameronhotchkies/7e7ccf6c599737678abc0cc2d6e81384 to your computer and use it in GitHub Desktop.
Simple python script for alphavantage API
#!/usr/bin/env python3
import urllib.request
import urllib.parse
import json
api_key = 'demo'
ticker = 'MSFT'
url = f'https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={ticker}&apikey={api_key}'
f = urllib.request.urlopen(url)
res = f.read().decode('UTF-8')
global_quote = json.loads(res)
gq = global_quote['Global Quote']
price = gq['05. price']
print(f"Current price for {ticker} is {price}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment