PoliticianList: Playing with Congressional Data
I’ve often found myself wondering when a particular senator is up for re-election, or what party an obscure member of the House is from. Sometimes a quick Google search tells you everything, but sometimes I find myself hitting Control-F to find out if “Republican” or “Democrat” appears on the page. So I looked around and found an API from ProPublica. Then I made a list. You can see the repo here and the app itself at politicianlist.com.
It was a nice opportunity for me to play with a data API and work on my React skills. I didn’t want to mess with branding so I just used Bootstrap. I might try to make it look prettier down the road, but the goal was to get a list of members of Congress that can be sorted and filtered.
Things went pretty well for the most part, but I had a few snags with the data. The API lists everybody, even if they’re no longer in Congress. Anyone who left because of health issues or got caught doing normal politician things without hiding them properly remains on the list, but with the property
in_office set to false. So it’s possible to have three senators for a state if one of them recently came in through a special election.
I filtered out anyone who isn’t currently in office and then found myself with a new problem. Members of Congress have an ID number in the data that I use as a key in my React lists, and suddenly I wound up with duplicates. Turns out that ProPublica updated the data and left a few people in there twice. The only difference between the entries was the last time they were updated. This blew up my app, so I had to filter things down again to search for duplicates and keep the most recent one.
The next thing to try out was pointing a domain name to my GitHub account. You’re allowed to have one organizational site with your account, so I learned how to get things set up to send politicianlist.com to my new app. Just one problem: every time I update the code, the page would disappear behind a 404 error until the repo had rebuilt and the domain name had caught up with the changes. It took 20-30 minutes each time. No bueno, especially since I plan to tinker with this quite a bit in the near future.
I could have just hosted it on my own web host, but… nah. I decided to switch it back to a regular project page and just use the domain name as a forward. Now I can play around with the code and people will still get the current version until the new stuff shows up in a few minutes.
This is an ongoing project, so I’ll continue to make changes, Many of them will be under the hood, but you can expect the appearance to change as well. For example, I have plans to add photos to the list, but there are hundreds of members of Congress and the one public domain image provider I could find is missing a few. I’ll need to sort out some error handling and maybe get those images from somewhere else.
In the meantime, PoliticianList is up and running.