Inspiration

I wanted to apply what I learned during my time at the Web Development path, and since the elections are a current thing, I wanted to pull data and put it into a simple format that can be frequently asked for by almost anyone!

What it does

Once a user sends an SMS to the designated phone number with the correct format, the program will parse it and return formatted JSON data back to the user through an SMS. They can search by political party (gop/dem) and then a state's abbreviation, which will give all candidates who participated in that Primary/Caucus. The user can also add as many candidates as they want to find their specific ratings as well. Here are a few examples:

dem MI Sanders (Sanders' rating in the 2016 Michigan Democratic Presidential Primary)

gop AZ Cruz (Cruz' rating in the 2016 Arizona Republican Presidential Primary)

gop IL (Returns all ratings in the 2016 Illinois Republican Presidential Primary)

dem IA Clinton Undecided (Clinton's and the Undecided vote in the 2016 Iowa Democratic Presidential Caucus)

How I built it

I used python with the JSON, flask, and twilio libraries in order to build this app. I collected the JSON data from the Huffington Post's Pollster API (I don't think the Associated Press API is public), and used flask and twilio which will retrieve messages and respond appropriately.

Challenges I ran into

My initial challenge was finding an API. I originally wanted to use the AP Elections API but I realized they don't really give that out. I then stuck with the HuffPost's Pollster API, using their json files in order to provide live updates of the primaries.

When I initially got a working version, it ran really slowly, but that was only because I kept reloading the JSON after each query, which wastes a lot of time. I also had to account for a lot of user errors, such as spelling mistakes and misaligned parameters.

When using the Twilio API I didn't realize that there was an automated response for saying 'help', which I tried to use in order to initiate the user with this app. I spent a lot of time trying to go around that roadblock before realizing that I should just set another command for it, like '!help'. Looking back at it, that roadblock was just super silly.

Accomplishments that I'm proud of

I'm proud of providing a means of communication through the internet, despite it being kind of niche. I spent hours on this project and I'm really glad with how neat the output is, even though the code is messy. Since the elections are still going on, updating this app with more features would be a blast to get back into.

What I learned

I learned an immense amount about web development and communication through the internet. Both of these topics were really fun to learn about, and not brutally difficult to get into, so I got to enjoy myself while also gaining a valuable learning experience. I had to ease my way back into Python again since I mainly do Java, so I relearned the syntax of the language.

What's next for Politext 2016?

I hope to add more features to this app, the Pollster API has topics span outside of the 2016 Presidential Elections, such as including the Senate Primaries, House and Governor Elections, and favorable ratings. My next step would probably provide a more specific format that will encompass these topics in a user-friendly way, so they can easily retrieve information that only benefits them, with data spanning as far back as 2012.

More user input would be something I'd like to add as well, maybe a simple poll that shows what candidate the user-base is favorable towards. There really is only expanding at this point, with an increasing want for features.

Share this project:

Updates