Skip to content

cyeganeh01248/MetroStatus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WMATA Metro Status

This Rust program is designed to retrieve information about upcoming trains arriving at a specified station. It utilizes the Washington Metropolitan Area Transit Authority (WMATA) API to fetch real-time train predictions.

This project was developed in a 24 hour code challenge for a Job Interview.

Installation

Ensure you have Rust installed on your system. If not, you can install it from Rust's official website.

Clone this repository to your local machine and navigate into it:

git clone https://github.com/cyeganeh01248/MetroStatus.git
cd MetroStatus

Local Install

In order to install locally, run the following script.

cargo build --release

Docker

In order to install via Docker, run the following script.

docker build -t metro_status .

Configuration

Before running the program, you need to obtain an API key from WMATA. You can register for an API key here.

Once you have the API key, you can pass it as a command-line argument.

If you do not obtain one, you may leave the argument out. The default public demo key will be used. This key has significantly low limits and is more used for testing purposes.

Running the Program

To run the program locally, execute the following command:

cargo run -- [--api-key YOUR_API_KEY] [--target-station TARGET_STATION_NAME]

To then run the program with docker, execute the following command:

docker run --rm -it metro_status [--api-key YOUR_API_KEY] [--target-station TARGET_STATION_NAME]

If desired, replace YOUR_API_KEY with your WMATA API Key and TARGET_STATION_NAME with the name of the station you want to fetch train schedules for. Leaving off the TARGET_STATION_NAME will default to Huntington Station.

You may also provide your API key by providing a value to the API_KEY environment variable.

Command-line Options

  • --api-key / -a: The WMATA API key to use. Defaults to a public demo key if not provided.
  • --target-station / -t: The name of the station to look for. Defaults to "Huntington" if not provided.

Dependencies

This program utilizes the following external crates:

  • clap: A command-line argument parsing library for parsing command-line options.
  • tokio: An async framework for rust for running async functions such as the reqwest lib.
  • reqwest: An Async Rust HTTP client for making requests to the WMATA API.
  • serde: A serialization/deserialization library for converting JSON responses into Rust structs.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published