#networking #vector #api #flight #state #aircraft #open-sky

opensky-network

A simple Rust wrapper library around the OpenSky Network API

2 releases

0.2.1 Dec 13, 2024
0.2.0 Dec 13, 2024

#1466 in Network programming

Download history 217/week @ 2024-12-12

217 downloads per month

MIT license

42KB
720 lines

opensky-network-rs

Fork from https://github.com/newcomb-luke/opensky_api.rs

Crates.io Documentation Build Status License

A brief description of your crate.

Rust bindings for the OpenSky Network API for getting realtime and historical flight data for non-commercial purposes.

Currently only aircraft State Vectors can be accessed, and flights/arrivals/departures will be implemented in the future.


lib.rs:

OpenSky Network API

This is a Rust library for interacting with the OpenSky Network API. The OpenSky Network is a community-based receiver network which continuously collects air traffic surveillance data. Unlike other networks, OpenSky keeps the collected data forever and makes it available to researchers and developers. The OpenSky Network API provides a way to access the collected data.

Please follow The OpenSky Network API documentation for more information.

Example

Get the state vectors of aircraft.

use opensky_network::OpenSkyApi;
#[tokio::main]
async fn main() {
    let api = OpenSkyApi::new();
    let request = api
        .get_states()
        .at_time(1458564121)
        .with_icao24("3c6444".to_string());
    let result = request.send().await.expect("Failed to get states");
    println!("{:#?}", result);
}

Get the flight data of aircraft.

use opensky_network::OpenSkyApi;
use std::env;
#[tokio::main]
async fn main() {
    dotenv::dotenv().ok();
    // setup OPENSKY_USER and OPENSKY_PASS in .env file
    let username = env::var("OPENSKY_USER").expect("OPENSKY_USER environment variable not set");
    let password = env::var("OPENSKY_PASS").expect("OPENSKY_PASS environment variable not set");
    let api = OpenSkyApi::with_login(username, password);

    let now = std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap()
        .as_secs();
    let mut request = api.get_flights(now - 7 * 24 * 60 * 60, now);
    request.by_aircraft("8990ed".to_string());
    let result = request.send().await.expect("Failed to get flights");
    println!("{:#?}", result);
}

Dependencies

~4–15MB
~200K SLoC