Moon-Sun-Tides API

A while ago I needed an API for an astronomical dashboard I designed as a fun bonus feature of my Kings Corner game. This widget showed the dates of the next full and new moons, sunrise and sunset times, and even data on local tides for those in the US living near the coast. However, I was surprised how much digging I had to do to find all this data.

Eventually I found three different API endpoints to build the single data object I needed for that project. These sources of data are:

All of these yielded excellent results. After much parsing and standardizing the data (i.e. all timestamps are now in the UTC timezone), I decided to share it as my own custom API!

Below is a sample endpoint and an explanation of its parameters, as well as what it returns. There is also a map interface for testing at the bottom of this page. For any questions about this or any of my other projects, please send me an email at al@fern.haus.

sample endpoint
https://us-central1-alec-fernandes.cloudfunctions.net/moon_sun_tides_api
?latitude=34.0488&longitude=-118.2518
&date=2022-11-30&time=16:32:09
parameters
latitude The latitude coordinate. (required)
longitude The longitude coordinate. (required)
date
yyyy-mm-dd
A specific date in UTC timezone to search (optional). If left blank, will default to the current date and time.
time
hh:mm:ss
A specific time in UTC timezone to search (optional). If left blank, will default to 12am on the date provided, if any.
response data
meta data A timestamp* of the declared or default date and time parameters and the declared coordinates.
moon Times* of the next full and new moons, the percentage of the moon's illumination, and the status of the moon (either "waxing" or "waning").
sun Sunrise, sunset, and solar noon times* along with the day's length in seconds.
tides Details about the nearest NOAA station and the times* of the next high and low tides.
Play around with the interface below to better understand how the data is structured.
* note: all returned times are in the UTC timezone.

Test & Play

set time (local):
UTC time:
latitude
longitude