Second bot for COMM 113, monitors EPA Envirofacts API for UV index and tweets user if index changes.
This bot uses the EPA UV Index monitor API to retrieve real-time data on a locality's UV index based on a user-inputted zipcode. It also uses the Mapzen Search API to find the city and state associated with this zipcode. The user's location is one of two arguments required for this bot to work, the other being the user's Twitter handle. I also implemented a scheduler on this bot, so that it will check automatically check the UV index once per hour after starting up. I used Twython to tweet the result of each API request to the user.
The most difficult part of this project was probably first understanding how Twython interacted with Twitter. At the beginning, I would get all these different errors because my code was incorrect. It took a bit of research to find out what a 401 error was and how it was different from a 403 error. Another challenge I ran into was figuring out how to schedule the tweets. I tried a number of different modules in Python but they didn't seem to work perfectly (and caused me to exceed my rate limit a couple times), before finally finding one that worked.
Overall, I'm actually pretty proud of how the final product turned out. The only parts I would point out that need improvement are the following. First, my code could be a lot cleaner in some places. Specifically, due to the lack of documentation on the EPA's API, I eventually gave up on making the request URL in the usual way and instead just concatenated all the parts together, which is obviously a big no in terms of style. My only defense is that I wasn't sure what I could have done as an alternative. Secondly, in terms of easy usage, I think it would be cool if it were possible for the user to only input one argument--their username--and have the bot still work. I guess that would involve parsing their Twitter bio or something to look for their location, but that would've been difficult for me to realize in a couple days.
UPDATE: So I'm not entirely sure, but I'm pretty certain that I called the UV Index API one too many times and am currently unable to access the JSON file to run the bot on my computer. That being said, I am still reasonably sure that the code works, as I was testing it beforehand. Hopefully that doesn't get me put on some watchlist.''