#client #bundle #nasa #base #picture #open

voyager_client

Crate that contains base clients for interacting with the NASA Open APIs

1 unstable release

Uses new Rust 2021

0.3.4 Jan 14, 2022
0.3.3 Jan 14, 2022
0.2.9 Jan 12, 2022
0.1.7 Dec 23, 2021

#129 in Science

Download history 102/week @ 2021-12-21 6/week @ 2021-12-28 128/week @ 2022-01-04 116/week @ 2022-01-11

352 downloads per month

MIT license

145KB
473 lines

version-shield downloads-shield docs-build-shield contributors-shield license-shield issues-shield

Voyager

Overview

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.

Crate Usage

Key Store

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!

Sample progam with voyager_client

    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.

Contributing

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

Dependencies

~3.5–4.5MB
~109K SLoC

a