Skip to content

Instantly share code, notes, and snippets.

@gcr
Created February 8, 2018 21:48
Show Gist options
  • Save gcr/f5cd87c871c30dc8b63e258e4221b6ee to your computer and use it in GitHub Desktop.
Save gcr/f5cd87c871c30dc8b63e258e4221b6ee to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Propublica Congress API demo\n",
"Based on demo at https://propublica-congress.readthedocs.io/en/latest/\n",
"(with updates to correct issues)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"API_KEY = \"API_KEY\"\n",
"\n",
"from congress import Congress\n",
"congress = Congress(API_KEY)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using Members endpoint:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# get member by bioguide ID\n",
"pelosi = congress.members.get('P000197')\n",
"\n",
"pelosi['twitter_account']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Bills endpoint: \n",
"\n",
"Get recent House bills\n",
"Tecent bills come in two types: 'introduced' and 'updated'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"introdcued = congress.bills.recent(\n",
" chamber ='house',\n",
" congress=115,\n",
" type ='introduced')\n",
"# Or: introduced = congress.bills.introduced('house')\n",
"\n",
"len(introdcued['bills'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"passed = congress.bills.passed('senate')\n",
"len(passed['bills'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"passed['bills'][0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment