Skip to content

Instantly share code, notes, and snippets.

@timothycarambat
Created September 15, 2021 01:59
Show Gist options
  • Save timothycarambat/db52c7b475edc0bdf0771e064874a2c5 to your computer and use it in GitHub Desktop.
Save timothycarambat/db52c7b475edc0bdf0771e064874a2c5 to your computer and use it in GitHub Desktop.
Senate and House Stock watcher Python3 data listing
import requests, json, datetime
# This function will grab the data from house/senate stockwatcher and return an array
# of dictonary items that represent transactions
def fetch_data():
response = requests.get("https://senate-stock-watcher-data.s3-us-west-2.amazonaws.com/aggregate/all_transactions.json")
# response = requests.get("https://house-stock-watcher-data.s3-us-west-2.amazonaws.com/data/all_transactions.json")
if response.status_code != 200:
print("request failed.")
return False
data = response.json()
data.sort(key = lambda x: datetime.datetime.strptime(x['disclosure_date'], '%m/%d/%Y'), reverse=True)
return data
print(fetch_data())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment