| Crates.io | stellaria |
| lib.rs | stellaria |
| version | 0.0.1 |
| created_at | 2025-12-12 19:08:37.523532+00 |
| updated_at | 2025-12-13 17:17:46.877502+00 |
| description | An ergonomic Rust library for the NASA Web APIs |
| homepage | |
| repository | https://github.com/aravindakshabalaji/stellaria/ |
| max_upload_size | |
| id | 1982001 |
| size | 81,372 |
Stellaria is an ergonomic Rust client library for NASA's Web APIs. It provides a convenient, type-safe way to concurrently call the endpoints, build state-guaranteed request parameters, and handle the REST API gracefully.
Add the crate to your project using cargo add stellaria.
This crate uses
reqwestfor HTTP. Your binary or test harness should usetokio(see examples below).
use stellaria::StellariaClient;
use stellaria::apod::ApodParams;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Provide your API token (or load from env)
let token = std::env::var("API_TOKEN")?;
let client = StellariaClient::new(token);
// Use the builder (defaults to today's date if no range provided)
let params = ApodParams::builder().build()?;
let resp = client.apod.get(params).await?;
for item in resp {
println!("{} — {}", item.date, item.title);
}
Ok(())
}
use chrono::NaiveDate;
use stellaria::StellariaClient;
use stellaria::apod::ApodParams;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("API_TOKEN")?;
let client = StellariaClient::new(token);
// request a specific date
let date = NaiveDate::from_ymd_opt(2024, 12, 12).unwrap();
let params = ApodParams::builder().date(date).build()?;
let resp = client.apod.get(params).await?;
// request a range
let start = NaiveDate::from_ymd_opt(2024, 01, 01).unwrap();
let end = NaiveDate::from_ymd_opt(2024, 01, 31).unwrap();
let params = ApodParams::builder().date_range(start, end).build()?;
let resp = client.apod.get(params).await?;
// request a count (random selection)
let params = ApodParams::builder().count(5).build()?;
let resp = client.apod.get(params).await?;
Ok(())
}
The repository includes a comprehensive set of unit tests for the parameter builder and integration-style tests that hit the real API. To run tests locally, set API_TOKEN then:
cargo test
Note: tests that contact the real API depend on network access and a valid API key.
The test suites expect an API_TOKEN environment variable (or .env file) containing a valid NASA API key. You can obtain a key at https://api.nasa.gov.
export API_TOKEN=YOUR_NASA_API_KEY
# or use a .env file for tests
Contributions are welcome:
Please run cargo fmt and cargo clippy before opening PRs.
Dual licensed under MIT OR Apache-2.0. See the LICENSE file for details.