{"id":19831976,"url":"https://github.com/gerardcl/renfe-cli","last_synced_at":"2025-04-07T05:10:20.415Z","repository":{"id":34852643,"uuid":"182556089","full_name":"gerardcl/renfe-cli","owner":"gerardcl","description":"Python CLI written in Rust for fast Renfe search website trains timetables retrieval","archived":false,"fork":false,"pushed_at":"2024-10-15T14:09:38.000Z","size":287,"stargazers_count":39,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T04:07:30.725Z","etag":null,"topics":["cli","ffi","gtfs","horarios","horaris","maturin","pyo3","python","python-cli","renfe","renfe-cli","rust","stations","timetable","timetable-defaults","train-stations","trains","trenes","trens"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gerardcl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-21T16:20:19.000Z","updated_at":"2025-01-21T21:03:06.000Z","dependencies_parsed_at":"2025-02-27T13:33:45.496Z","dependency_job_id":null,"html_url":"https://github.com/gerardcl/renfe-cli","commit_stats":{"total_commits":136,"total_committers":5,"mean_commits":27.2,"dds":0.5,"last_synced_commit":"b1d4488c0b166906f7cb0681654eb28229fad5a9"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerardcl%2Frenfe-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerardcl%2Frenfe-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerardcl%2Frenfe-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerardcl%2Frenfe-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gerardcl","download_url":"https://codeload.github.com/gerardcl/renfe-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"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":["cli","ffi","gtfs","horarios","horaris","maturin","pyo3","python","python-cli","renfe","renfe-cli","rust","stations","timetable","timetable-defaults","train-stations","trains","trenes","trens"],"created_at":"2024-11-12T11:35:51.816Z","updated_at":"2025-04-07T05:10:20.392Z","avatar_url":"https://github.com/gerardcl.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CICD](https://github.com/gerardcl/renfe-cli/actions/workflows/CICD.yml/badge.svg)](https://github.com/gerardcl/renfe-cli/actions/workflows/CICD.yml)\n\n# Renfe Timetables CLI\n\nGet faster Renfe trains timetables in your terminal, with Python3.8+ support.\nNo longer need to open the browser! Just keep using your terminal 😀\n\nIt supports both [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia) (default option, as in the web) and [Renfe Cercanías](https://data.renfe.com/dataset/horarios-cercanias)  GTFS datasets.\n\n`renfe-cli` is written in [Rust](https://www.rust-lang.org/) (since v4.0.0) and published to [pypi.org](https://pypi.org/project/renfe-cli/) as a Python package (CLI and library).\n\nIt is provided as a Python package due to historical reasons, but was ported to Rust to showcase Rust's interoperability and performance improvements that can offer to the Python ecosystem. Nevertheless, one can optionally use the built [renfe-cli](https://crates.io/crates/renfe-cli) crate that is publised to crates.io.\n\nSee the [changelog](https://github.com/gerardcl/renfe-cli/blob/master/CHANGELOG.md).\n\n**NOTE** since I am more often using Rodalies trains I have created [rodalies-cli](https://github.com/gerardcl/rodalies-cli). I hope you like it too!\n\n  **DISCLAIMER**: Renfe's GTFS dataset might not be in sync with autonomic train schedules systems (e.g. Rodalies de la Generalitat de Catalunya), hence Renfe Cercanias train types (e.g.: REGIONAL or MD type) might not be accurate, or when using the `cercanias` flag you won't find timetables for the stations belonging to autonomic systems. For that, please use autonomic data/apps (.e.g: [rodalies-cli](https://github.com/gerardcl/rodalies-cli)).\n\n## Installation\n\n### Python package\n\nInstall Python CLI package [renfe-cli](https://pypi.org/project/renfe-cli/)\n\n```bash\npip install renfe-cli --upgrade\n```\n\n### Rust crate (optional)\n\nInstall the Rust crate [renfe-cli](https://crates.io/crates/renfe-cli)\n\n```bash\ncargo install renfe-cli\n```\n\n## Usage (CLI)\n\nThe CLI uses the official and latest Renfe's GTFS dataset, from [Horarios de alta velocidad, larga distancia y media distancia](https://data.renfe.com/dataset/horarios-de-alta-velocidad-larga-distancia-y-media-distancia), by default. Optionally, one can enable searching over [Renfe Cercanías GTFS dataset](https://data.renfe.com/dataset/horarios-cercanias) (expect longer load time in this case).\n\n```bash\n$ renfe-cli -h\nUsage: renfe-cli [options]\n\nOptions:\n    -f ORIGIN           Set From origin station\n    -t DESTINATION      Set To destination station\n    -d, --day DAY       Set the Day (default: today's day)\n    -m, --month MONTH   Set the Month (default: today's month)\n    -y, --year YEAR     Set the Year (default: today's year)\n    -s, --sort          Option to sort the timetable by Duration\n    -c, --cercanias     Option to search over Renfe Cercanías\n    -h, --help          Print this help menu\n```\n\n### **Getting the timetable**\n\nLet's show an example of minimal inputs (origin and destination stations) with specific date and default GTFS dataset:\n\n```bash\n$ renfe-cli  -f girona -t \"puerta de atocha\" -d 30\nLoading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia\nProvided input 'girona' does a match with 'Estación de tren Girona'\nProvided input 'puerta de atocha' does a match with 'Estación de tren Madrid-Puerta de Atocha'\nToday is: 2024-9-29\nSearching timetable for date: 2024-9-30\nOrigin station: Estación de tren Girona\nDestination station: Estación de tren Madrid-Puerta de Atocha\n\n=========================TIMETABLE=========================\n  Train        |   Departure  |   Arrival    |   Duration\n-----------------------------------------------------------\n   AVLO        |    05:46     |    09:20     |    03:34\n-----------------------------------------------------------\n   AVE         |    06:41     |    10:10     |    03:29\n-----------------------------------------------------------\n   AVE         |    08:11     |    11:45     |    03:34\n-----------------------------------------------------------\n   AVE INT     |    11:59     |    15:45     |    03:46\n-----------------------------------------------------------\n   AVE         |    15:11     |    19:12     |    04:01\n-----------------------------------------------------------\n   AVE         |    17:51     |    21:45     |    03:54\n===========================================================\n```\n\nLet's show an example using Renfe Cercanías GTFS dataset:\n\n```bash\n$ renfe-cli -f chamartín -t \"tres cantos\" -c\nLoading Cercanías GTFS data from Renfe web - long load time\nProvided input 'chamartín' does a match with 'Station { name: \"Estación de tren Madrid-Chamartín-Clara Campoamor\", id: \"17000\" }'\nProvided input 'tres cantos' does a match with 'Station { name: \"Estación de tren Tres Cantos (apt)\", id: \"17004\" }'\nToday is: 2024-10-2\nSearching timetable for date: 2024-10-2\nOrigin station: Estación de tren Madrid-Chamartín-Clara Campoamor\nDestination station: Estación de tren Tres Cantos (apt)\n\n=========================TIMETABLE=========================\n  Train        |   Departure  |   Arrival    |   Duration    \n-----------------------------------------------------------\n   C4b         |    05:06     |    05:22     |    00:16     \n-----------------------------------------------------------\n   C4b         |    05:38     |    05:55     |    00:17     \n-----------------------------------------------------------\n   C4b         |    06:10     |    06:27     |    00:17     \n-----------------------------------------------------------\n.........\n.........\n-----------------------------------------------------------\n   C4b         |    21:56     |    22:13     |    00:17     \n-----------------------------------------------------------\n   C4b         |    22:20     |    22:37     |    00:17     \n-----------------------------------------------------------\n   C4b         |    23:16     |    23:33     |    00:17     \n===========================================================\n```\n\n## Usage (Library)\n\n`renfe-cli` can be imported as a python package into your project, offering utilities when willing to deal with the Renfe search web site.\n\n```bash\n$ python\nPython 3.12.6 (main, Sep  8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e import renfe_cli\n\u003e\u003e\u003e renfe = renfe_cli.\nrenfe_cli.Renfe()    renfe_cli.Schedule(  renfe_cli.Station(   renfe_cli.main()     renfe_cli.renfe_cli  \n\u003e\u003e\u003e renfe = renfe_cli.Renfe()\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nTypeError: Renfe.__new__() missing 1 required positional argument: 'cercanias'\n\u003e\u003e\u003e renfe = renfe_cli.Renfe(False)\nLoading default GTFS data from Renfe web - Alta velocidad, Larga distancia y Media distancia\nGTFS data:\n  Read in 2171 ms\n  Stops: 793\n  Routes: 644\n  Trips: 4150\n  Agencies: 1\n  Shapes: 0\n  Fare attributes: 0\n  Feed info: 0\n\u003e\u003e\u003e renfe.filter_station(\"madrid\")\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nValueError: Provided input 'madrid' does match with '[Station { name: \"Estación de tren Madrid-Puerta de Atocha\", id: \"60000\" }, Station { name: \"Estación de tren Madrid - Atocha Cercanias\", id: \"18000\" }, Station { name: \"Estación de tren Madrid-Principe Pio\", id: \"10000\" }, Station { name: \"Estación de tren Madrid-Ramon Y Cajal\", id: \"97201\" }, Station { name: \"Estación de tren Madrid-Nuevos Ministerios\", id: \"18002\" }, Station { name: \"Estación de tren Madrid-Chamartin\", id: \"17000\" }, Station { name: \"Estación de tren Madrid-Recoletos\", id: \"18001\" }]' -\u003e There must be ONLY one match\n\u003e\u003e\u003e renfe.filter_station(\"girona\")\nProvided input 'girona' does a match with 'Station { name: \"Estación de tren Girona\", id: \"79300\" }'\n\u003cbuiltins.Station object at 0x77f04173d070\u003e\n\u003e\u003e\u003e renfe.print_timetable()\n\nNo schedules available...won't print timetable.\n\u003e\u003e\u003e renfe.set_train_schedules(\"79300\", \"60000\", 30, 9, 2024, False)\n\u003e\u003e\u003e renfe.print_timetable()\n\n=========================TIMETABLE=========================\n  Train        |   Departure  |   Arrival    |   Duration\n-----------------------------------------------------------\n   AVLO        |    05:46     |    09:20     |    03:34\n-----------------------------------------------------------\n   AVE         |    06:41     |    10:10     |    03:29\n-----------------------------------------------------------\n   AVE         |    08:11     |    11:45     |    03:34\n-----------------------------------------------------------\n   AVE INT     |    11:59     |    15:45     |    03:46\n-----------------------------------------------------------\n   AVE         |    15:11     |    19:12     |    04:01\n-----------------------------------------------------------\n   AVE         |    17:51     |    21:45     |    03:54\n===========================================================\n\u003e\u003e\u003e ...\n```\n\n---\n\n## Contribute or Report with Issues\n\nIf Renfe's GTFS dataset is being kept not up to date or you find any issue to be fixed or nice enhancements to have, please: [create an issue](https://github.com/gerardcl/renfe-cli/issues).\n\n### Development\n\nThis project makes use of Rust bindings for the Python interpreter thanks to [pyo3](https://pyo3.rs). It is already available as a dependency.\n\nTo develop, build and publish, this project makes use of [maturin](https://www.maturin.rs/) project. See [usage](https://www.maturin.rs/#usage).\n\nExample of first time working with this repository:\n\n```bash\n$ git clone https://github.com/gerardcl/renfe-cli.git \u0026\u0026 cd renfe-cli\n$ python -m venv .venv\n$ . .venv/bin/activate\n$ pip install -U pip\n$ pip install -U maturin\n$ maturin develop\n🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7\n🐍 Not using a specific python interpreter\n📡 Using build options features from pyproject.toml\n   Compiling renfe-cli v5.1.0 (/path/to/renfe-cli)\n    Finished dev [unoptimized + debuginfo] target(s) in 7.07s\n📦 Built wheel for abi3 Python ≥ 3.7 to /tmp/.tmpDsjowL/renfe_cli-5.1.0-cp37-abi3-linux_x86_64.whl\n🛠 Installed renfe-cli-5.1.0\n```\n\nMaturin takes care of compiling the rust code, generating the bindings for python and installing the package for local use (as library or binary/CLI).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerardcl%2Frenfe-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgerardcl%2Frenfe-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerardcl%2Frenfe-cli/lists"}