A bunch of scripts that run on CRON jobs that populate the database(s) that store the basic legislator info for TownHallProject.
- Go to: https://console.firebase.google.com/u/0/
- Click: "Add project" and fill out details
- In the upper left of the page, under the "Develop" tab, click: "Database"
- Click: "Create database"
- Ensure that "Start in locked mode" is checked
- Which server location doesn't matter so simply click: "Done"
- Near the top of the page, click: "Cloud Firestore"
- In the opened modal, click: "Realtime Database"
- Click on the bar containing the database url and add "states" to the end,
(it should look like
https://your_project_id.firebaseio.com/states
) - On the far right, click on the vertical triple dots icon
- Click: "Import JSON"
- Click: "Browse"
- From this repository, select the
data/supported-states.json
file for upload. - In the upper left, to the right of the "Project Overview" text, click the cog icon
- In the opened modal, click: "Project settings"
- Click: "Service accounts"
- Click: "Generate new private key"
- Go to: https://www.propublica.org/datastore/api/propublica-congress-api
- On the right, fill out the "Request an API key" form and click: "Submit"
- Go to: https://openstates.org/api/register/
- Fill out the "Register for an API Key" form and click: "Submit"
- Once you have received API keys from Propublica and Open States,
create a file at the top level of this repository called
.env
- Open the private key file you downloaded from firebase in step ten
- In the
.env
file, copy and paste the details from the Firebase private key in the following format:
TESTING_FIREBASE_TOKEN='{your firebase private_key}' # A long string that begins with "-----BEGIN PRIVATE KEY ..."
TESTING_PROJECT_ID='your firebase project_id'
TESTING_CLIENT_EMAIL='{your firebase client_email}'
TESTING_DATABASE_URL='https://{your firebase project_id}.firebaseio.com/'
PROPUBLICA='{your propublica api key}' # A forty character long alphanumeric string
OPEN_STATES_API_KEY='your open states api key' # A forty character long alphanumeric string
Assuming you have node.js installed:
- Run
npm i
- Run
node bin/seed-federal-db-from-propublica.js
- Run
node openstates/get-state-lawmakers.js