#esi #eve-online #api-wrapper #user-agent #eve-api #black-rose

eve_esi

Black Rose's API wrapper for interaction with EVE Online's ESI

1 unstable release

0.1.0 Apr 1, 2024

#1466 in Web programming

Download history 97/week @ 2024-03-26 66/week @ 2024-04-02 2/week @ 2024-04-09

165 downloads per month

MIT license

13KB
134 lines

EVE ESI

Black Rose's API wrapper for interaction with EVE Online's ESI.

Implementation

  1. Initialize ESI in your main function using the initialize_eve_esi function which will set the user agent, this includes your application name & contact email if CCP needs to reach out to you for any reason.
  2. Use ESI routes as needed from there.
#[tokio::main]
async fn main() {
    let application_name = "Black Rose EVE ESI Example";
    let application_email = "example@example.com";

    initialize_eve_esi(application_name.to_string(), application_email.to_string());

    let app = Router::new()
        .route("/character", get(get_esi_character))
        .route("/corporation", get(get_esi_corporation));

    let listener = tokio::net::TcpListener::bind("127.0.0.1:8000")
        .await
        .unwrap();

    println!("Test character API at http://localhost:8000/character?id=2114794365");
    axum::serve(listener, app).await.unwrap();
}

async fn get_esi_character(params: Query<GetByIdParams>) -> Response {
    match get_character(params.0.id).await {
        Ok(character) => (StatusCode::OK, Json(character)).into_response(),
        Err(error) => {
            let status_code = StatusCode::from_u16(error.status().unwrap().into()).unwrap();

            (status_code, Json(error.to_string())).into_response()
        }
    }
}

See the axum example.

To test out the example:

  1. Run cargo run --example axum
  2. Head to one of the URLs posted in your console, change the IDs to test out different characters/corporations

Notes

  • More ESI routes will be added as needed, feel free to submit pull requests to add any you may need.
  • Only public ESI routes are available, private routes will be added at a later date.

Dependencies

~5–17MB
~243K SLoC