NOAA Tides Web Service

We will use a web service provided by the National Oceanic and Atmospheric Administration (NOAA) to get our tide information. One benefit of this is that no API key is needed, since it's your tax dollars at work. However, since this is a part of the US government, the service only covers regions of the United States.

If you live outside the United States, you may have to find a service which sends out tide data as a JSON feed and adapt the code to your new data source. The framework laid out here should provide you a great starting point.

NOAA CO-OPS API

Wow, acronyms! We already covered NOAA above. CO-OPS stands for Center for Operational Oceanographic Products and Services. Why is there a dash? Don't know, it's just what the government does. But also, it doesn't really matter. If you want to know more, read about it here.

API stands for Application Programming Interface, a general term used a lot in programming. The CO-OPS API is one of many web services that NOAA provides. There's a complete list here.

The main documentation for the web service we will use is here:

There are a lot of options and types of data that can be returned. We've worked out the magic invocation needed for the PyPortal and you can find it in the code later. The only item you will need to worry about is finding your closest tide monitoring station ID. This is how you will set your location in the code.

So let's see how you can figure that out next.

Find Your Tide Station ID

To find you station ID, start by going to this webpage:

Scroll down a bit and you'll see a map. You can simply click on the state of interest. Note that some states are not clickable. That's because they don't have tides :(

Once you've clicked on a state you'll get a familiar map like interface that you can drag and zoom around. Use that to zoom in and find the station marker that seems like it will work best for your location.

Click on the marker and it will bring up information about that marker.

The station ID will be the number shown near the top. This is what you will enter into your code.

Basic Tide Time Info

Here's the URL that gets the high and low times for the current day at the station location. The station ID is the very last thing in the URL, so you can change it for your location if you want.

Download: file
https://tidesandcurrents.noaa.gov/api/datagetter?date=today&product=predictions&datum=mllw&interval=hilo&format=json&units=metric&time_zone=lst_ldt&station=9447130

If you put that address in your web browser you'll get something that looks like this:

Not a very pretty web page. That's because it's just JSON data. The key predictions is the root for all the data. Then there are several entries that look like:

Download: file
{"t":"2019-04-15 02:55", "v":"3.401", "type":"H"}

The t entry gives us the date and time, the v entry gives us the tide level, and the type is H for high tide or L for low tide.

So we have what we need - the time for each of the high and low tides for the given day. You'll see how this is parsed out later in the code.

Tide Levels Throughout the Day

With a slight modification of the URL, we can get predicted water levels in 6 minute increments over the period of the current day. Here's the URL for that:

Download: file
https://tidesandcurrents.noaa.gov/api/datagetter?date=today&product=predictions&datum=mllw&format=json&units=metric&time_zone=lst_ldt&station=9447130

More data like before, but now much more of it!

With data every 6 minutes, that's 10 per hour, or 240 for the entire day. And now each entry contains simply t and v. So for the given time t, we get the predicted water level v. We can use that to make a neat little plot of water level vs. time for the day. This will give us a graphical representation of the tidal activity.

This guide was first published on Apr 17, 2019. It was last updated on Apr 17, 2019. This page (NOAA Tides Web Service) was last updated on Dec 05, 2019.