6 releases

0.1.0-alpha.6 Jun 9, 2021
0.1.0-alpha.5 Apr 26, 2021
0.1.0-alpha.4 Mar 29, 2021
0.1.0-alpha.3 Mar 28, 2021
0.1.0-alpha.1 Mar 16, 2021

#29 in #json-response

Custom license

59KB
1K SLoC

SpaceTraders

This is a rust API wrapper for https://spacetraders.io

View documentation here https://docs.rs/spacetraders/

When running without optimizations (I.E. without --release) the library will not error if there are extra fields in the JSON responses. In debug mode if the JSON contains extra fields an error will be emitted. This is done intentionally to hopefully provide the most correct client possible. If you come across one of these errors please submit a PR to add the additional fields! Thanks!

Example

You can view my spacetraders bot here https://github.com/bloveless/spacemonger-api which has a full example of how to use this crate.

A brief example is included below.

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let http_client = client::get_http_client();
    let client = Client::new(
        http_client,
        "your-username".to_string(),
        "your-token".to_string(),
    );

    let mut current_user_info = client.get_user_info().await?;
    println!("Current user info {:?}", current_user_info);

    // Continue calling other functions and build cool things!
}

Dependencies

~7–20MB
~302K SLoC