Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 2.59 KB

README.md

File metadata and controls

51 lines (37 loc) · 2.59 KB

WhoseRep

The @WhoseRep Twitter bot pulls campaign finance data from OpenSecrets.org and US congressional member data from ProPublica.org to tweet small insights into government representatives.

How it works

For each tweet, a legislator and one of their top campaign contributors are chosen randomly, along with some additional information, such as a committee on which the legislator serves.

Example: "Rep John K Delaney (D-MD) accepted $13,250 from Nasdaq Inc. He serves in the Joint Economic Committee."

Make it work

Dependencies

pip install tweepy
pip install opensecrets-crpapi
pip install python-congress

Configure it

You will need to create a Twitter account and app for your bot.

You'll also need a Center for Responsive Politics API key and a ProPublica API key.

You may either rename sample.config.py as config.py and enter your keys there, or include them as environment variables.

'TWITTER_ACCESS_TOKEN' : '',
'TWITTER_ACCESS_TOKEN_SECRET' : '',
'TWITTER_CONSUMER_KEY' : '',
'TWITTER_CONSUMER_SECRET' : '',
'OPENSECRETS_API_KEY' : '',
'PROPUBLICA_API_KEY' : ''

Run it

Before running the bot, you first need to generate the data/cids.txt file. This file contains all of the CIDs (Candidate IDs) used by OpenSecrets.org to uniquely identify legislators. You should update this file following congressional member changes, such as post-election.

Note: This will make 51 calls to the getLegislators method API endpoint. Your daily call limit for this endpoint is 200.

Generate the file by running:

python build_cids.py

Then generate a single tweet:

python bot.py

Make your own

There's a lot of interesting, publicly available data about US government representatives. How about extending this bot to tweet about voting records when a legislator is mentioned in the news?