{"id":34107851,"url":"https://github.com/tducret/trainline-python","last_synced_at":"2026-04-08T12:05:28.176Z","repository":{"id":57476876,"uuid":"145239383","full_name":"tducret/trainline-python","owner":"tducret","description":"Non-official Python wrapper and CLI tool for Trainline","archived":false,"fork":false,"pushed_at":"2020-10-23T16:56:44.000Z","size":535,"stargazers_count":60,"open_issues_count":5,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-08-29T13:45:55.052Z","etag":null,"topics":["api","parser","python-wrapper","scraper","sncf","train","trainline"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/tducret.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}},"created_at":"2018-08-18T17:25:42.000Z","updated_at":"2025-06-07T13:29:19.000Z","dependencies_parsed_at":"2022-09-12T14:50:18.259Z","dependency_job_id":null,"html_url":"https://github.com/tducret/trainline-python","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tducret/trainline-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tducret%2Ftrainline-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tducret%2Ftrainline-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tducret%2Ftrainline-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tducret%2Ftrainline-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tducret","download_url":"https://codeload.github.com/tducret/trainline-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tducret%2Ftrainline-python/sbom","scorecard":{"id":871214,"data":{"date":"2025-08-11","repo":{"name":"github.com/tducret/trainline-python","commit":"e4f88ff2c82c53367dd24a6798a83cb8d43314e4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":2,"reason":"Found 5/23 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: Dockerfile:1","Warn: containerImage not pinned by hash: Dockerfile:12: pin your Docker image by updating gcr.io/distroless/python3 to gcr.io/distroless/python3@sha256:9d3def4c1a9d9dc98927db1515fc8d5c3c169eef338161fbe0479207d9928d14","Warn: pipCommand not pinned by hash: Dockerfile:9-10","Info:   0 out of   2 containerImage dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2023-74 / GHSA-j8r2-6x86-q33q","Warn: Project is vulnerable to: PYSEC-2018-28 / GHSA-x84v-xcm2-53pg"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T04:16:31.156Z","repository_id":57476876,"created_at":"2025-08-24T04:16:31.157Z","updated_at":"2025-08-24T04:16:31.157Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31554163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","parser","python-wrapper","scraper","sncf","train","trainline"],"created_at":"2025-12-14T18:10:05.621Z","updated_at":"2026-04-08T12:05:28.165Z","avatar_url":"https://github.com/tducret.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trainline\n\n[![Travis](https://img.shields.io/travis/tducret/trainline-python.svg)](https://travis-ci.org/tducret/trainline-python)\n[![Coveralls github](https://img.shields.io/coveralls/github/tducret/trainline-python.svg)](https://coveralls.io/github/tducret/trainline-python)\n[![PyPI](https://img.shields.io/pypi/v/trainline.svg)](https://pypi.org/project/trainline/)\n[![Docker Image size](https://img.shields.io/microbadger/image-size/thibdct/trainline.svg)](https://hub.docker.com/r/thibdct/trainline/)\n![License](https://img.shields.io/github/license/tducret/trainline-python.svg)\n\n## Description\n\nNon-official Python wrapper and CLI tool for Trainline\n\nI wrote a French blog post about it [here](https://www.tducret.com/scraping/2018/09/05/trouvez-le-billet-de-train-le-moins-cher-grace-a-ce-module-python.html)\n\n🎁 I added [a tiny Docker image](#docker) to use the tool very easily\n\n# Requirements\n\n- Python 3\n- pip3\n\n## Installation\n\n```bash\npip3 install -U trainline\n```\n\n## CLI tool usage\n\n```bash\ntrainline_cli.py --help\n```\n\nExamples :\n\n```bash\ntrainline_cli.py --departure=\"Toulouse\" --arrival=\"Bordeaux\" --next=12hours\ntrainline_cli.py --departure=\"Paris\" --arrival=\"Marseille\" --next=1day\n```\n\nor the shorter call :\n\n```bash\ntrainline_cli.py -d Toulouse -a Bordeaux -n 12h\ntrainline_cli.py -d Paris -a Marseille -n 1d\n```\n\nExample output :\n\n```bash\ndeparture_date;arrival_date;duration;number_of_segments;price;currency;transportation_mean;bicycle_reservation\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;36,0;EUR;train;30,0\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;37,5;EUR;train;30,0\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;95,5;EUR;train;30,0\n[...]\n```\n\nYou can then open it with your favorite spreadsheet editor (and play with the filters) :\n\n![snapshot trainline_cli.py output in Excel](cli_tool_csv_in_Excel.png)\n\n## Package usage\n\n```python\n# -*- coding: utf-8 -*-\nimport trainline\n\nresults = trainline.search(\n\tdeparture_station=\"Toulouse\",\n\tarrival_station=\"Bordeaux\",\n\tfrom_date=\"15/10/2018 08:00\",\n\tto_date=\"15/10/2018 21:00\")\n\nprint(results.csv())\n```\n\nExample output :\n\n```bash\ndeparture_date;arrival_date;duration;number_of_segments;price;currency;transportation_mean;bicycle_reservation\n15/10/2018 08:00;15/10/2018 10:55;02h55;1;5,0;EUR;coach;unavailable\n15/10/2018 08:00;15/10/2018 10:50;02h50;1;4,99;EUR;coach;unavailable\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;20,5;EUR;train;10,0\n[...]\n```\n\n```python\n# -*- coding: utf-8 -*-\nimport trainline\n\nPierre = trainline.Passenger(birthdate=\"01/01/1980\", cards=[trainline.AVANTAGE_FAMILLE])\nSophie = trainline.Passenger(birthdate=\"01/02/1981\")\nEnzo = trainline.Passenger(birthdate=\"01/03/2012\")\nNicolas = trainline.Passenger(birthdate=\"01/01/1996\", cards=[trainline.AVANTAGE_JEUNE])\nNicolas.add_special_card(trainline.TGVMAX, \"YourCardNumber\")\n\nresults = trainline.search(\n\tpassengers=[Pierre, Sophie, Enzo, Nicolas],\n\tdeparture_station=\"Toulouse\",\n\tarrival_station=\"Bordeaux\",\n\tfrom_date=\"15/10/2018 08:00\",\n\tto_date=\"15/10/2018 21:00\",\n\tbicycle_with_or_without_reservation=True)\n\nprint(results.csv())\n```\n\nExample output :\n\n```bash\ndeparture_date;arrival_date;duration;number_of_segments;price;currency;transportation_mean;bicycle_reservation\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;36,0;EUR;train;30,0\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;37,5;EUR;train;30,0\n15/10/2018 08:19;15/10/2018 10:26;02h07;1;95,5;EUR;train;30,0\n[...]\n```\n\n# Docker\n\nYou can use the `trainline` tool with the [Docker image](https://hub.docker.com/r/thibdct/trainline/)\n\nYou may execute :\n\n`docker run -it --rm thibdct/trainline --departure=\"Toulouse\" --arrival=\"Bordeaux\" --next=12hours`\n\n\u003e The Docker image is built on top of [Google Distroless image](https://github.com/GoogleContainerTools/distroless), so it is tiny :)\n\n## 🤘 The easy way 🤘\n\nI also built a bash wrapper to execute the Docker container easily.\n\nInstall it with :\n\n```bash\ncurl -s https://raw.githubusercontent.com/tducret/trainline-python/master/trainline.sh \\\n\u003e /usr/local/bin/trainline \u0026\u0026 chmod +x /usr/local/bin/trainline\n```\n*You may replace `/usr/local/bin` with another folder that is in your $PATH*\n\nCheck that it works :\n\n```bash\ntrainline --help\ntrainline --departure=\"Toulouse\" --arrival=\"Bordeaux\" --next=12hours\n```\n\nYou can upgrade the app with :\n\n```bash\ntrainline --upgrade\n```\n\nand even uninstall with :\n\n```bash\ntrainline --uninstall\n```\n\n# TODO\n\n- [ ] Create a sort function in Folders class (to get the cheapest trips first for example)\n- [ ] Add filter for class (first, second), for max_duration\n- [X] Implement `get_station_id`\n- [X] Implement the use of passengers during search\n- [X] Calculate total price with bicycle reservation if search 'with_bicyle' (and export it in csv)\n- [X] Calculate total price for all the passengers (and export it in csv) =\u003e may need to create a class for Folder \n- [X] Create the CLI tool and update README\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftducret%2Ftrainline-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftducret%2Ftrainline-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftducret%2Ftrainline-python/lists"}