{"id":21862676,"url":"https://github.com/etalab/transpo-rt","last_synced_at":"2025-04-14T19:42:05.635Z","repository":{"id":48849500,"uuid":"158520204","full_name":"etalab/transpo-rt","owner":"etalab","description":"Simple API for public transport realtime data ","archived":false,"fork":false,"pushed_at":"2021-07-08T16:25:17.000Z","size":592,"stargazers_count":20,"open_issues_count":13,"forks_count":9,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-05-16T19:04:42.856Z","etag":null,"topics":["gtfs-rt","realtime-data","siri-lite"],"latest_commit_sha":null,"homepage":"https://tr.transport.data.gouv.fr/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etalab.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-11-21T09:05:10.000Z","updated_at":"2023-09-16T09:24:51.000Z","dependencies_parsed_at":"2022-08-31T16:31:39.291Z","dependency_job_id":null,"html_url":"https://github.com/etalab/transpo-rt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etalab%2Ftranspo-rt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etalab%2Ftranspo-rt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etalab%2Ftranspo-rt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etalab%2Ftranspo-rt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etalab","download_url":"https://codeload.github.com/etalab/transpo-rt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248948747,"owners_count":21187926,"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":["gtfs-rt","realtime-data","siri-lite"],"created_at":"2024-11-28T03:16:52.192Z","updated_at":"2025-04-14T19:42:05.608Z","avatar_url":"https://github.com/etalab.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# transpo-rt\n\nSimple API for public transport realtime data.\n\nThis API reads a public transport base schedule (a [GTFS](http://gtfs.org/)) and some realtime data (for the moment in [GTFS_RT](https://developers.google.com/transit/gtfs-realtime/)) to provide realtime feeds in [siri lite](http://www.normes-donnees-tc.org/format-dechange/donnees-temps-reel/).\n\n### Using\n\nA [hosted version](https://tr.transport.data.gouv.fr/) of this API, with some french datasets can be freely used.\n\nThe API provides several routes:\n\n* `GET` `/`: list the available datasets - [example call](https://tr.transport.data.gouv.fr/)\n* `GET` `/spec`: [OpenApi](https://www.openapis.org/) [v3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) description of this API - [example call](https://tr.transport.data.gouv.fr/spec)\n* `GET` `/{id}/gtfs-rt`: get the gtfs-rt as binary - [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/gtfs-rt)\n* `GET` `/{id}/gtfs-rt.json`: get the gtfs-rt as json - [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/gtfs-rt.json)\n* `GET` `/{id}/siri/2.0/`: get the list of available siri-lite links [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/siri/2.0)\n* `GET` `/{id}/siri/2.0/stop-monitoring.json`: get a siri-lite stop monitoring response - [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/siri/2.0/stop-monitoring.json?MonitoringRef=4235)\n* `GET` `/{id}/siri/2.0/stoppoints-discovery.json`: get a siri-lite stoppoint discovery response - [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/siri/2.0/stoppoints-discovery.json?q=mairie)\n* `GET` `/{id}/siri/2.0/general-message.json`: get a siri-lite general message response - [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/siri/2.0/general-message.json)\n* `GET` `/{id}/`: simple status on the dataset - [example call](https://tr.transport.data.gouv.fr/horaires-theoriques-du-reseau-tag/)\n\n#### API details\n\n##### /siri/2.0/stop-monitoring.json\n\nThe API follows the [Siri-lite specification](http://www.chouette.mobi/irys/wp-content/uploads/20151023-Siri-Lite-Sp%C3%A9cification-Interfaces-V1.4.pdf) (documentation in french).\n\nA formal description of the supported parameters and of the response can be seen in the [OpenAPI endpoint](https://tr.transport.data.gouv.fr/spec/).\n\n##### /siri/2.0/stoppoints-discovery.json\n\nThe API follow the [Siri-lite specification](http://www.chouette.mobi/irys/wp-content/uploads/20151023-Siri-Lite-Sp%C3%A9cification-Interfaces-V1.4.pdf) (documentation in french).\n\nA formal description of the supported parameters and of the response can be seen in the [OpenAPI endpoint](https://tr.transport.data.gouv.fr/spec/).\n\n## Developping\n\n### Building\n\nTo build the api, you need an up to date Rust version:\n\nIf you don't already have it, install Rust:\n```\ncurl https://sh.rustup.rs -sSf | sh\n```\n\nOr update it:\n```\nrustup update\n```\n\nThen you can build it:\n```\ncargo build\n```\n\n### Configuring \u0026 Running\n\nYou can check the needed cli parameters with the `-h` option:\n```\ncargo run --release -- -h\n```\n\nIn particular, the application expects a config file from you, to define which datasets (GTFS + GTFS RT) should be handled.\n\nThis can be configured via a local file, or a HTTP url (see `-h` output for exact details).\n\nAn example configuration file can be found in [here](example_configuration_file.yml), which you can use like this (in debug mode):\n\n```\ncargo run -- -c example_configuration_file.yml\n```\n\nAfter a bit of time preparing the datasets, an url will appear in the logs (`http://localhost:8080`), showing which datasets are served.\n\nAlternatively, you can use:\n\n```\ncargo run -- --gtfs \u003cpath or url of gtfs\u003e --url \u003curl fo the gtfs rt\u003e\n```\n\n### Testing\n\nYou can run all the tests (unit test, integration, clippy and fmt) with:\n```\nmake check\n```\n\nIt will save you some time for the code review and continous integration ;)\n\n### Manual testing\n\nOne useful trick to experiment locally is to [serve a local folder via HTTP](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server#running_a_simple_local_http_server), using:\n\n```\nmkdir data\ncd data\n# here download files with curl or manually, then start server\npython3 -m http.server\n```\n\nYou can use the corresponding urls in a custom `.yml` configuration file. This makes it easier to simulate 404 errors for instance (by simply renaming the files).\n\n## Architecture\n\nThe API has been made with [actix-web](https://github.com/actix/actix-web). This makes it possible to have a multithreaded API with data reloading and realtime updates without dataraces (thanks to [rust](https://www.rust-lang.org/)), nor mutexes (thanks to the [actix](https://github.com/actix/actix) [actor model](https://en.wikipedia.org/wiki/Actor_model)).\n\nTo achieve this there is an `Actor` in charge of the data (`DatasetActor`). The api workers query this actor to get the latest data. The `DatasetActor` does not return directly the data, but a `Arc` to them (a rust shared pointer).\n\nIn the background, 2 actors are in charge of periodic data reloading:\n* `BaseScheduleReloader` reloads once in a while the baseschedule dataset\n* `RealTimeReloader` reloads frequently the realtime dataset\n\nOnce the data (baseschedule or realtime) has been reloaded, it is send to the `DatasetActor` via a message. When the `DatasetActor` processes this message, it replaces it's `Arc` to this data, dropping the references. The API workers that have aquired an `Arc` to those data can continue their work on those data. The old data will be deleted when all workers have finished their work on them (thus noboby owns an `Arc` to those data anymore).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetalab%2Ftranspo-rt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetalab%2Ftranspo-rt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetalab%2Ftranspo-rt/lists"}