Expand description
§Usgs Earthquake API
This crate provides a simple client for interacting with the USGS Earthquake API.
Features:
- Filter earthquakes by time range (
start_time,end_time) - Filter by magnitude range (
min_magnitude,max_magnitude) - Filter by alert level (
AlertLevel) - Order results (
OrderBy) - Filter earthquakes by country code (using
country_boundariesdataset).
§Example
use usgs_client::{UsgsClient, AlertLevel, OrderBy};
#[tokio::main]
async fn main() {
use usgs_earthquake_api::OrderBy;
let client = UsgsClient::new();
let result = client
.query()
.filter_by_country_code("TR")
.start_time(2024, 1, 1, 0, 0)
.end_time(2024, 12, 31, 23, 59)
.min_magnitude(4.0)
.alert_level(AlertLevel::All)
.order_by(OrderBy::Time)
.fetch()
.await;
match result {
Ok(res) => println!("Total earthquakes: {}", res.features.len()),
Err(e) => eprintln!("Error: {}", e),
}
}Structs§
- Usgs
Client - Main USGS API client.
- Usgs
Query - Query builder for the USGS API.
Enums§
- Alert
Level - USGS earthquake alert levels.
- OrderBy