{"id":29390832,"url":"https://github.com/ishantanu/tfl-rust","last_synced_at":"2025-07-10T08:30:20.234Z","repository":{"id":179096401,"uuid":"657080206","full_name":"ishantanu/tfl-rust","owner":"ishantanu","description":"API wrapper written in rust for interacting with TFL API :crab:","archived":false,"fork":false,"pushed_at":"2025-04-08T10:30:11.000Z","size":162,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-10T07:06:04.833Z","etag":null,"topics":["crate","rust","tfl"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ishantanu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-22T09:19:44.000Z","updated_at":"2025-04-08T10:30:09.000Z","dependencies_parsed_at":"2023-11-06T12:42:47.025Z","dependency_job_id":"fc1879d6-647b-4402-acbb-76c226f41f79","html_url":"https://github.com/ishantanu/tfl-rust","commit_stats":null,"previous_names":["ishantanu/tfl-rust"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ishantanu/tfl-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishantanu%2Ftfl-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishantanu%2Ftfl-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishantanu%2Ftfl-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishantanu%2Ftfl-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ishantanu","download_url":"https://codeload.github.com/ishantanu/tfl-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishantanu%2Ftfl-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264551644,"owners_count":23626536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crate","rust","tfl"],"created_at":"2025-07-10T08:30:18.914Z","updated_at":"2025-07-10T08:30:20.214Z","avatar_url":"https://github.com/ishantanu.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TFL API Wrapper\n\n[![rust-clippy analyze](https://github.com/ishantanu/tfl-rust/actions/workflows/rust-clippy.yml/badge.svg)](https://github.com/ishantanu/tfl-rust/actions/workflows/rust-clippy.yml)\n\nA rust crate for using the [Transport for London (TFL) API](https://api.tfl.gov.uk).\n\n*Note: Only the Line API is currently supported. Other APIs are work in progress*\n\n## Installation\n\nUsing `cargo`, add this to your project's `Cargo.toml`:\n```toml\n[dependencies]\ntfl-api-wrapper = \"0.1.3\"\n```\n\n## Usage\n\n### Get the Keys from TFL API Portal\n1. If you don't already have an account, register on [TFL API Portal](https://api-portal.tfl.gov.uk/).\n2. Vist the [Products](https://api-portal.tfl.gov.uk/products) link and create a new subscription for `500 Requests per min` (allows 500 requests per min).\n3. Next, visit your [profile](https://api-portal.tfl.gov.uk/profile), scroll down to the `Primary key` section of your subscription, click on `Show` and copy the value. You can use either of `Primary key` or `Secondary key`.\n\n### Use the crate\n\nSet the `APP_KEY` environment variable.\n\nInstantiate the `Client` using:\n\n```rust\nuse tfl_api_wrapper::{Client, RequestBuilder};\nlet client = Client::new(std::env::var(\"APP_KEY\").unwrap());\n```\nHere `APP_KEY` could be either `Primary key` or `Secondary key`.\n\n## Example\n\nGet the API version:\n```rust\nasync fn it_is_version_1() {\n    use tfl_api_wrapper::{Client, RequestBuilder};\n    let client = Client::new(std::env::var(\"APP_KEY\").unwrap());\n    let ver = client.api_version().fetch().await.unwrap();\n}\n```\n\nList valid modes\n```rust\nasync fn list_valid_modes() {\n    use tfl_api_wrapper::{Client, RequestBuilder};\n    use std::env;\n\n    let client = Client::new(env::var(\"APP_KEY\").unwrap().into());\n    let valid_modes = client.list_modes().fetch().await.unwrap();\n}\n```\n\nList severity types\n```rust\nasync fn list_severity_types() {\n    use tfl_api_wrapper::{Client, RequestBuilder};\n    use std::env;\n\n    let client = Client::new(env::var(\"APP_KEY\").unwrap().into());\n    let severity_types = client.list_severity_types().fetch().await.unwrap();\n}\n```\n\nList routes by mode\n```rust\nasync fn list_routes_by_mode() {\n    use tfl_api_wrapper::{Client, RequestBuilder, linemodels, models};\n    use std::env;\n\n    let client = Client::new(env::var(\"APP_KEY\").unwrap().into());\n    let modes: Vec\u003cmodels::Mode\u003e = vec![models::Mode::Bus, models::Mode::Tube];\n    let routes = client\n        .list_lines_routes_by_modes()\n        .mode(modes)\n        .fetch()\n        .await\n        .unwrap();\n}\n```\n\nGet arrival predictions by lines\n```rust\nasync fn get_arrivals_by_lines() {\n    use tfl_api_wrapper::{Client, RequestBuilder, linemodels};\n    use std::env;\n\n    let client = Client::new(env::var(\"APP_KEY\").unwrap().into());\n    let lines: Vec\u003clinemodels::LineID\u003e = vec![linemodels::LineID::Bakerloo, linemodels::LineID::Jubilee];\n    let arrivals = client\n        .arrival_predictions_by_lines()\n        .line(lines)\n        .fetch()\n        .await\n        .unwrap();\n}\n```\n\nFetch disruptions by mode\n```rust\nasync fn get_disruptions_by_lines() {\n    use tfl_api_wrapper::{Client, RequestBuilder, linemodels, models};\n    use std::env;\n\n    let client = Client::new(env::var(\"APP_KEY\").unwrap().into());\n    let modes: Vec\u003cmodels::Mode\u003e = vec![models::Mode::Bus, models::Mode::Tube];\n    let disruptions = client\n        .disruptions_by_mode()\n        .mode(modes)\n        .fetch()\n        .await\n        .unwrap();\n}\n```\n\n## Tests\nYou can run the tests by running:\n```sh\nAPP_KEY=hjdhajsdas cargo test\n```\n\n## Developer\n\nAs this library maintains a `LineID` enum, we have a tool to compare this with\nthe API's list of valid routes. It reports on the status of `LineID`, listing\nwhich lines are missing, which have a mismatched `to_string()` mapping and\nwhich are no longer in use.\n\nRun:\n\n```sh\nAPP_KEY=hjdhajsdas cargo run --bin line-id-check\n```\n\n## Implemented APIs\n- Version - Shows the API version\n- Line\n    - Get all valid routes for all lines, including the name and id of the originating and terminating stops for each route.\n    - Get all valid routes for given line ids, including the name and id of the originating and terminating stops for each route.\n    - Get disruptions for all lines of the given modes.\n    - Get disruptions for the given line ids.\n    - Get the list of arrival predictions for given line ids based at the given stop\n    - Gets a list of the stations that serve the given line id\n    - Gets a list of valid disruption categories\n    - Gets a list of valid modes\n    - Gets a list of valid ServiceTypes to filter on\n    - Gets a list of valid severity codes\n    - Gets all lines and their valid routes for given modes, including the name and id of the originating and terminating stops for each route\n    - Gets all valid routes for given line id, including the sequence of stops on each route.\n    - Gets lines that match the specified line ids\n    - Gets lines that serve the given modes.\n    - Gets the line status for all lines with a given severity\n    - Gets the line status for given line ids during the provided dates e.g Minor Delays\n    - Gets the line status of for all lines for the given modes\n    - Gets the line status of for given line ids e.g Minor Delays\n    - Gets the timetable for a specified station on the give line\n    - Gets the timetable for a specified station on the give line with specified destination\n    - Search for lines or routes matching the query string\n\n## Limitations\n- Currently, the enum types created for Lines does not contain buses starting with numeric characters (e.g. 101).\n\n## References/Credits\n1. Existing tfl wrappers\n   1. [tfl-api-wrapper](https://github.com/ZackaryH8/tfl-api-wrapper) - NodeJS wrapper for TFL API, made with TypeScript.\n   2. [tfl-api-wrapper-py](https://github.com/ZackaryH8/tfl-api-wrapper-py) - Python wrapper for TFL API\n   3. [go-tfl](https://github.com/ZackaryH8/go-tfl) - Go client for TFL API\n2. [Adzuna-rs](https://github.com/kamui-fin/adzuna-rs) - For existing wrapper implementation for Adzuna API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishantanu%2Ftfl-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishantanu%2Ftfl-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishantanu%2Ftfl-rust/lists"}