Skip to content

Instantly share code, notes, and snippets.

@byronmansfield
Last active April 24, 2020 23:52
Show Gist options
  • Save byronmansfield/806c94230ff1712b80cafa6365526c7b to your computer and use it in GitHub Desktop.
Save byronmansfield/806c94230ff1712b80cafa6365526c7b to your computer and use it in GitHub Desktop.
Example for python api call json
#!usr/bin/env python
import json
import requests
API_KEY = 'abcxyz'
url = 'https://example.com/v1/api/endpoint'
params = dict(key=API_KEY, format=json)
headers = {'Content-Type': 'application/json'}
def run():
response = requests.get(url=url, params=params, headers=headers)
mydata = response.json()
for data in mydata['date']:
if date >= '1990':
print("Data entry is greater than or equal to 1990")
print(json.dumps(date["company"]))
if __name__ == '__main__':
run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment