Last active
April 24, 2020 23:52
-
-
Save byronmansfield/806c94230ff1712b80cafa6365526c7b to your computer and use it in GitHub Desktop.
Example for python api call json
This file contains 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
#!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