{"id":33044440,"url":"https://github.com/Intersection/gtfs-realtime-translators","last_synced_at":"2025-11-16T20:01:49.466Z","repository":{"id":38192412,"uuid":"187098025","full_name":"Intersection/gtfs-realtime-translators","owner":"Intersection","description":"A set of open source Python libraries for translating custom real-time transit data to the GTFS-rt format","archived":false,"fork":false,"pushed_at":"2025-10-27T19:26:52.000Z","size":309,"stargazers_count":21,"open_issues_count":2,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-10-27T20:36:28.162Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ixn.intersection.com/found-in-translation-announcing-a-library-of-gtfs-realtime-translators-1d196857dded","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Intersection.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-16T20:37:42.000Z","updated_at":"2025-10-27T19:25:52.000Z","dependencies_parsed_at":"2023-12-18T21:14:06.468Z","dependency_job_id":"98e51932-5603-4945-a9ce-ad9e37a2eecd","html_url":"https://github.com/Intersection/gtfs-realtime-translators","commit_stats":null,"previous_names":[],"tags_count":111,"template":false,"template_full_name":null,"purl":"pkg:github/Intersection/gtfs-realtime-translators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intersection%2Fgtfs-realtime-translators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intersection%2Fgtfs-realtime-translators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intersection%2Fgtfs-realtime-translators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intersection%2Fgtfs-realtime-translators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Intersection","download_url":"https://codeload.github.com/Intersection/gtfs-realtime-translators/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Intersection%2Fgtfs-realtime-translators/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284767947,"owners_count":27060132,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-11-14T00:00:28.414Z","updated_at":"2025-11-16T20:01:49.454Z","avatar_url":"https://github.com/Intersection.png","language":"Python","funding_links":[],"categories":["Producing Data","Uncategorized"],"sub_categories":["GTFS Realtime","Uncategorized"],"readme":"# gtfs-realtime-translators\n\n[![Build Status](https://travis-ci.org/Intersection/gtfs-realtime-translators.svg?branch=master)](https://travis-ci.org/Intersection/gtfs-realtime-translators) [![Total alerts](https://img.shields.io/lgtm/alerts/g/Intersection/gtfs-realtime-translators.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/Intersection/gtfs-realtime-translators/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/Intersection/gtfs-realtime-translators.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/Intersection/gtfs-realtime-translators/context:python)\n\n`gtfs-realtime-translators` translates custom arrivals formats to GTFS-realtime. It uses the Google [`gtfs-realtime-bindings`](https://github.com/google/gtfs-realtime-bindings/tree/master/python) for Python, supplemented by Intersection extensions.\n\n## Overview\n\nFollowing the [GTFS-realtime spec](https://developers.google.com/transit/gtfs-realtime/), its three pillars are:\n- `TripUpdate`\n- `VehiclePosition`\n- `Alert`\n\nA `FeedMessage` is a list of _entities_, each of which is one of the types above. A `FeedMessage` may have entities of different types.\n\nAs of 2019-06-15, only `TripUpdate` is supported.\n\n## Installation\n```\npip install -e git+https://github.com/Intersection/gtfs-realtime-translators.git@\u003cTAG\u003e#egg=gtfs-realtime-translators\n```\n\n## Usage\n\n### Registry\nThe registry is used to return a translator for a given translator key. This is useful to decouple the translator lookup via external systems from its implementation.\n```\nfrom gtfs_realtime_translators.registry import TranslatorRegistry\n\ntranslator_klass = TranslatorRegistry.get('la-metro')\ntranslator = translator_klass(**kwargs)\n```\n\n### Translators\n```\nfrom gtfs_realtime_translators.translators import LaMetroGtfsRealtimeTranslator\n\ntranslator = LaMetroGtfsRealtimeTranslator(stop_id='80122')\nfeed_message = translator(la_metro_rail_input_data)\n```\nAt this point, `feed_message` is a standard protocol buffer object and adheres to the normal [Python Protocol Buffer interface](https://developers.google.com/protocol-buffers/docs/pythontutorial).\n```\nfeed_bytes = feed_message.SerializeToString()\n```\n\n### Factories\nNew translators should be contributed back to this library.\n```\nfrom gtfs_realtime_translators.factories import TripUpdate, FeedMessage\n\ntrip_update = TripUpdate.create(entity_id=entity_id,\n                                arrival_time=arrival_time,\n                                departure_time=departure_time,\n                                trip_id=trip_id,\n                                stop_id=stop_id,\n                                route_id=route_id)\n\nentities = [ trip_update ]\n\nfeed_message = FeedMessage.create(entities=entities)\n```\n\n## GTFS-Realtime Bindings\n\n### Source `gtfs-realtime.proto`\nThe GTFS-realtime spec is maintained in the [google/transit](https://github.com/google/transit.git) repository. Currently, since there is no versioned way to programmatically include this in our projects, we must clone it as a manual dependency.\n```\ngit clone https://github.com/google/transit.git ../google-transit\ncp ../google-transit/gtfs-realtime/proto/gtfs-realtime.proto gtfs_realtime_translators/bindings/\n```\n\n### Re-generate Bindings\nFor our Python libraries to understand the interface specified by the GTFS-realtime spec, we must generate language bindings.\n```\nvirtualenv ~/.env/gtfs-realtime-bindings\nsource ~/.env/gtfs-realtime-bindings/bin/activate\npip install grpcio-tools\npython3 -m grpc_tools.protoc -I gtfs_realtime_translators/bindings/ --python_out=gtfs_realtime_translators/bindings/ gtfs_realtime_translators/bindings/intersection.proto\n```\nSince we are using the published spec bindings, we must do one more step. Inside the generated file, `gtfs_realtime_translators/bindings/intersection_pb2.py`, change the following line\n```\nimport gtfs_realtime_pb2 as gtfs__realtime__pb2\n```\nto\n```\nfrom google.transit import gtfs_realtime_pb2 as gtfs__realtime__pb2\n```\n\n## Run Tests Locally\n\n```\npip install -r requirements.txt\npip install -e .\npytest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIntersection%2Fgtfs-realtime-translators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIntersection%2Fgtfs-realtime-translators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIntersection%2Fgtfs-realtime-translators/lists"}