Meteostat for Rust
The Weather's Record Keeper - In Rust!

This crate provides a convenient asynchronous Rust interface for accessing historical weather and climate data from Meteostat, leveraging their publicly available bulk data interface. It allows fetching data for thousands of weather stations worldwide.
Meteostat is a free and open provider of weather & climate data. They do the hard work of collecting, processing, and providing the data. This crate is simply a Rust client for their bulk API. Please consider supporting Meteostat if you find their data useful: Donate to Meteostat.
Take a look at yesterday's temperatures or discover the weather hundreds of years ago, right from your Rust application.
Key Features
- Fetch by Station ID: Get weather data for a specific Meteostat station ID.
- Fetch by Location: Get weather data for a location, specified by a latitude and longitude.
- Find Nearby Stations: Search for stations near coordinates, optionally filtering by distance and required data availability (inventory).
- Multiple Frequencies: Supports Hourly, Daily, Monthly, and Climate Normals data.
- Efficient Data Handling: Returns data as Polars
LazyFrames, allowing for powerful, memory-efficient filtering and manipulation before collecting results. - Convenient Filtering: Includes a
MeteostatFrameFilterExttrait for easy filtering ofLazyFrames by date, year, or datetime ranges. - Automatic Caching: Downloads and caches station metadata and weather data files locally to speed up subsequent requests and reduce load on Meteostat's servers.
- Asynchronous: Built with
tokiofor non-blocking I/O.
Installation
Add meteostat to your Cargo.toml dependencies:
Basic Usage
Here's a quick example demonstrating fetching data by station ID and by location:
use ;
use *;
use ;
use FromStr; // For parsing DateTime<Utc>
async
(See more examples in the examples directory)
Data Handling
Polars LazyFrame
All weather data fetching methods (from_station, from_location) return a Polars LazyFrame. This allows you to:
- Chain operations: Apply filters, selections, aggregations, etc., without loading the entire dataset into memory immediately.
- Optimize queries: Polars optimizes the plan before execution.
- Collect when ready: Use
.collect()?to execute the plan and get aDataFramein memory.
This is particularly beneficial when dealing with potentially large historical datasets.
Caching
The crate automatically caches downloaded data to avoid redundant downloads and respect Meteostat's resources:
- Station Metadata: The list of all stations (
stations/lite.json.gz) is downloaded once and cached. - Weather Data: Individual station data files (e.g.,
hourly/10637.csv.gz) are downloaded and cached per station and frequency.
By default, cache files are stored in your system's standard cache directory (e.g., ~/.cache/meteostat_rs on Linux,
%LOCALAPPDATA%/meteostat_rs_cache on Windows).
You can specify a custom cache location using Meteostat::with_cache_folder(path).
Filtering Data Frames
The MeteostatFrameFilterExt trait
provides convenient methods for filtering the LazyFrames returned by this crate based on date and time.
use ;
use *;
use ;
async
See the
MeteostatFrameFilterExt documentation
for all available filtering methods (filter_daily, filter_monthly, filter_climate, get_hourly_row, etc.).
Data Source and Attribution
- All weather data is sourced from Meteostat.
- This crate uses Meteostat's free bulk data interface. No API key is required.
API Documentation
Full API documentation is available on docs.rs.
Example: Plotting Data
You can easily use the DataFrame output with plotting libraries like plotlars.
// Requires the 'examples' feature: cargo run --example graph_data --features examples
use Error;
use ;
use ;
use *;
async
To run this specific example, enable the examples feature:
cargo run --example graph_data --features examples
(This will generate a plot similar to the one shown at the top of this README)
Contributing
Contributions, bug reports, and feature requests are welcome! Please feel free to open an issue or submit a pull request on the GitHub repository.
License
This crate is licensed under the Apache License 2.0. See the LICENSE file for details.