2 unstable releases

0.1.0 Sep 6, 2023
0.0.1 Sep 1, 2023

#14 in #train

Download history 129/week @ 2024-01-01 54/week @ 2024-01-08 16/week @ 2024-01-15 31/week @ 2024-01-22 26/week @ 2024-02-19 19/week @ 2024-02-26 42/week @ 2024-03-04 60/week @ 2024-03-11 51/week @ 2024-03-18 56/week @ 2024-03-25 47/week @ 2024-04-01 22/week @ 2024-04-08 27/week @ 2024-04-15

154 downloads per month
Used in 3 crates (via amtrak-gtfs-rt)

MIT license

32KB
276 lines

AMTRAK-API crates.io

This project provides developers with a standard and ergonomic Rust API for calling the various endpoints in Amtrak Train API.

Authors

Stefan Bossbaly

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments


lib.rs:

Amtrak Rust API

Amtrak Rust API allows the caller to query the Amtrak API for information about trains and stations in its network.

Note: This library is not affiliated with Amtrak in any way and is an unofficial implementation of the public facing API. Amtrak is a registered trademark of the National Railroad Passenger Corporation.

Example usage

Here is an example of querying trains that have stopped at or will stop at a specific station.

use amtrak_api::Client;

const STATION_CODE: &str = "PHL";

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    Client::new()
        .station(STATION_CODE)
        .await?
        .0
        .values()
        .for_each(|station| {
            println!(
                "Current train scheduled for station \"{}\": {}",
                station.name,
                station.trains.join(", ")
            );
        });

    Ok(())
}

Dependencies

~5–20MB
~275K SLoC