⚠️ This library is now archived. Development will continue at phasewalk1/nasa-rs.
Voyager is a swiss army knife library for the NASA Open APIs. It is designed to bundle all the NASA APIs into a single package. Voyager can be used to gather data from a variety of NASA's endpoints, including: Picture of The Day, Solar Flares, Magnetic Storms, Near Earth Objects etc.
Future versions of voyager will strive to incorporate more endpoints, until all of them are integrated.
First create a .env file at the root of your project and add a variable named "API_KEY" with your API key from NASA as it's value. Make sure to add .env to your gitignore!
use voyager_client::{donki, timing};
use voyager_client::response::*;
use serde_json::Value as JsonValue;
fn main() {
// instantiate a base client
let base = donki::SolarFlare::new();
// setup range for query params
let start = String::from("2021-01-01");
let end = String::from("2022-01-01");
// query the endpoint
let res: Response = base.query(start, end).unwrap();
// manipulating responses..
let json: JsonValue = res.json().unwrap();
let bytes_vec: Vec<u8> = res.bytedump().unwrap();
}
This is a very simple program using voyager_client. We instantiate our base client for the Coronal Mass Ejection endpoint, and setup our timing parameters for our query. Then we pass the start and end dates into the query function. This will return a JSON string in prettyfied format.
The entire library can be found in lib.rs, as well as it's documentation. main.rs is a small executable that contains unit-tests for the voyager_client crate. All contributors are welcome! Simply clone this repository and work on a new branch, when you are ready you can open a PR.
The .cargo directory contains a config file that defines some aliases that are handy for test-driven development. In the root directory you can run:
cargo unit-test
This is a quick way to run all unit tests defined in main.rs.
You can also run:
cargo doc-test