| Crates.io | noaa-tides |
| lib.rs | noaa-tides |
| version | 0.0.1 |
| created_at | 2026-01-04 18:57:30.803099+00 |
| updated_at | 2026-01-04 20:02:22.377428+00 |
| description | A library to fetch data from the NOAA tides and currents CO-OPS API |
| homepage | |
| repository | https://github.com/jbandoro/noaa-tides |
| max_upload_size | |
| id | 2022327 |
| size | 76,906 |
Library to fetch NOAA tide and currents data from their CO-OPS API.
The CO-OPS API is a single endpoint that supports multiple products with different response formats that can be requested with different combinations of query parameters. This library was built to provide a type-safe interface for building requests and deserializing responses into dedicated structs for each product.
This library currently supports the following products:
predictions: includes predicted tide heights for specified stations and date ranges. Supports
various options for datum, time zones, intervals and units. Returns a vector of tide predictions with
dateime, height an optional tide type if the Interval::HighLow parameter is used.
Below is an example using the predictions product to fetch hourly tide predictions for the San
Francisco Golden Gate station for the month of January 2026. More examples can be found in the
examples/ directory.
use noaa_tides::{NoaaTideClient, Datum, DateRange, Interval, PredictionsRequest, Timezone, Units};
use chrono::NaiveDate;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = NoaaTideClient::new();
let request = PredictionsRequest {
station: "9414290".into(),
date_range: DateRange {
begin_date: NaiveDate::from_ymd_opt(2026, 1, 1).unwrap(),
end_date: NaiveDate::from_ymd_opt(2026, 1, 31).unwrap(),
},
datum: Datum::MLLW,
time_zone: Timezone::LST_LDT,
interval: Interval::Hourly,
units: Units::English,
};
let data = client.fetch(&request).await?;
for prediction in data.predictions.iter() {
println!("{}: {:+.2} ft", prediction.datetime, prediction.height);
}
Ok(())
}