Skip to main content

My Flask Application

Background

To understand the purpose behind this application I would like to share a little bit about myself outside of programming. I love to fish especially Rainbow Trout. During the beginning of the spring 2022 Trout season, my area got a ton of rain leaving the rivers I normally like to fish unfishable. At one of my favorite spots, I noticed a USGS station about a hundred yards up the river from where I normally fish. With some research, I found that I could view the current conditions of the river like depth and flow rate. However, the data was messy and was not easy to view. Doing what every reasonable developer would do, I decided to create my own application to view current river conditions to determine if my favorite spot has favorable conditions. The first step, create a backend application that gathers and refines information from USGS and gives it the ability to send that data over my own API! The application itself is hosted on Python Anywhere a great platform for hosting scripts and Python applications.

Getting Locations

The first step in using the application would be to select the river you would like to fish. To do this a list of all locations must be compiled to allow the user to select their desired river. For development purposes, I chose to only start with locations located in my home state of New Jersey. A previous script was created to pull location information from an XML file provided by USGS and store the name, ID, and coordinates of each site in a JSON file for later users. By calling this endpoint it returns the locations from the desired state.

/getLocations/?key=<API_KEY>&state=<STATE>&type=<WATER_TYPE>

API KEY: TEST

STATE: NJ

WATER TYPE: ST

Getting River Data

After the Location is selected by the user, the get river conditions endpoint is called with the selected river ID. The endpoint triggers another script that calls two USGS endpoints (River Height, and River Flow) and combines the data into a single JSON file to be sent as the API response. Each field contains the river’s height, flow rate, and timestamp of when that data was taken. The data ranges from the current time to that of 7 days ago.
After the water conditions are added another script is called that adds current and future weather conditions from the coordinates of the site. This data is sourced from the Open Weather Map API and uses the Current and 5-day forecast endpoints.
Test it out for yourself by selecting an ID from the get Locations sample output and pasting it onto the river ID field!

/getRiverConditions/?key=<API_KEY>&river=<RIVER_ID>

API KEY: TEST

RIVER ID: 01379000 (Passaic River)

Functionalities

  • API endpoint to return all USGS water monitoring sites by state
  • Filters out all inactive USGS water monitoring sites
  • API endpoint that returns 7 day history from current time of selected monitoring site
  • Features API key authentication to block unauthorized use of the API
  • Returns current weather conditions and the five day weather forecast
  • Returns 7 day water conditions average

Coming soon!

  • Adding Moon Phase
  • Functionality to check if any recent data (10 minutes)was pulled from a requested location to minimize CPU usage by calling USGS endpoints
  • Adding a front end using the Flutter SDK