Crate opensky_network

Source
Expand description

§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);
}

Re-exports§

pub use bounding_box::BoundingBox;
pub use flights::Flight;
pub use states::StateVector;
pub use states::States;
pub use tracks::FlightTrack;
pub use tracks::Waypoint;

Modules§

bounding_box
errors
flights
Module for retrieving flight data for a certain time interval.
states
Module for searching state vectors from the OpenSky Network API.
tracks
Module for handling flight tracks by aircraft.

Structs§

OpenSkyApi
The OpenSky Network API https://openskynetwork.github.io/opensky-api