Skip to content

Instantly share code, notes, and snippets.

@earlcharles1
Last active March 24, 2022 16:18
Show Gist options
  • Save earlcharles1/e885f0f53eaec6f3ce17115f479eb6ba to your computer and use it in GitHub Desktop.
Save earlcharles1/e885f0f53eaec6f3ce17115f479eb6ba to your computer and use it in GitHub Desktop.
Congress API Fetch
refer = call()
refer
def call():
headers = {
'X-API-Key': 'g9Gl5fJh7xzikftE3DNjzLhtq1VLMDxmN0ZxkI6',
}
params = {
'query': '{Oil}',
}
response = requests.get('https://api.propublica.org/congress/v1/bills/search.json?query={query}', headers=headers, params=params)
BillData = response.text
# covert to fucking dictionary probably or string
x = json.loads(BillData)
#normalize data and selects through nests
df = pd.json_normalize(x, record_path = ['results','bills'])
df_assortment = df[['bill_id', 'title','active','latest_major_action_date','summary','govtrack_url']].sort_values(
by = ['active','latest_major_action_date'], ascending = False)
return HTML(df_assortment.to_html(escape = False))
import requests
import json
import pandas as pd
from IPython.display import HTML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment