| Crates.io | brightsky |
| lib.rs | brightsky |
| version | 1.0.0 |
| created_at | 2025-11-27 14:45:20.837041+00 |
| updated_at | 2026-01-20 15:59:49.842808+00 |
| description | Type-safe query builders and response types for the Bright Sky weather API |
| homepage | https://github.com/ecklf/brightsky-rs |
| repository | https://github.com/ecklf/brightsky-rs |
| max_upload_size | |
| id | 1953895 |
| size | 205,860 |
Type-safe query builders and response types for the Bright Sky API, providing access to German weather data from the Deutscher Wetterdienst (DWD).
The easiest way to use brightsky with reqwest:
[dependencies]
brightsky = { version = "0.2", features = ["reqwest"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
use brightsky::{CurrentWeatherQueryBuilder, ext::BrightSkyReqwestExt, types::CurrentWeatherResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let query = CurrentWeatherQueryBuilder::new()
.with_lat_lon((52.52, 13.4)) // Berlin
.build()?;
let response: CurrentWeatherResponse = client.get_brightsky(query).await?;
println!("Temperature: {:?}C", response.weather.temperature);
Ok(())
}
If you prefer to handle HTTP yourself:
[dependencies]
brightsky = "0.2"
reqwest = { version = "0.13", features = ["json"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
use brightsky::{CurrentWeatherQueryBuilder, ToBrightSkyUrl, BRIGHT_SKY_API, types::CurrentWeatherResponse};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let query = CurrentWeatherQueryBuilder::new()
.with_lat_lon((52.52, 13.4))
.build()?;
let url = query.to_url(BRIGHT_SKY_API)?;
let response: CurrentWeatherResponse = reqwest::get(url).await?.json().await?;
println!("Temperature: {:?}C", response.weather.temperature);
Ok(())
}
use brightsky::{WeatherQueryBuilder, ext::BrightSkyReqwestExt, types::{WeatherResponse, UnitType}};
use chrono::NaiveDate;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let query = WeatherQueryBuilder::new()
.with_lat_lon((52.52, 13.4))
.with_date(NaiveDate::from_ymd_opt(2025, 1, 15).unwrap())
.with_units(UnitType::Si)
.build()?;
let response: WeatherResponse = client.get_brightsky(query).await?;
println!("Found {} hourly records", response.weather.len());
Ok(())
}
For embedded systems, use to_url_string() with your HTTP client:
use brightsky::{CurrentWeatherQueryBuilder, ToBrightSkyUrl, BRIGHT_SKY_API, types::CurrentWeatherResponse};
let query = CurrentWeatherQueryBuilder::new()
.with_lat_lon((52.52, 13.4))
.build()?;
// Get URL as String (works in no_std)
let url = query.to_url_string(BRIGHT_SKY_API)?;
// Use your HTTP client (reqwless, etc.) to fetch, then deserialize
let response: CurrentWeatherResponse = serde_json::from_slice(&body)?;
| Endpoint | Builder | Response Type |
|---|---|---|
/current_weather |
CurrentWeatherQueryBuilder |
CurrentWeatherResponse |
/weather |
WeatherQueryBuilder |
WeatherResponse |
/radar |
RadarWeatherQueryBuilder |
RadarResponse |
/alerts |
AlertsQueryBuilder |
AlertsResponse |
.with_lat_lon((lat, lon)) or .with_dwd_station_id(vec!["01766"]).with_date(date) and .with_last_date(end_date).with_tz("Europe/Berlin").with_units(UnitType::Si) or .with_units(UnitType::Dwd)| Feature | Description |
|---|---|
std (default) |
Enables url::Url support via to_url() method |
reqwest |
Enables BrightSkyReqwestExt trait for ergonomic reqwest usage |
Without std: Only to_url_string() available (no_std compatible for embedded systems).
All data is sourced from the DWD open data server:
Please refer to the DWD Terms of Use for data usage guidelines.
BrightSky API is provided by Jakob de Maeyer. Consider sponsoring his work!
MIT License - see LICENSE for details.