Skip to content

derhuerst/print-gtfs-rt-cli

Repository files navigation

print-gtfs-rt-cli

Read a GTFS Realtime (GTFS-RT) feed from stdin, print human-readable or as JSON.

npm version ISC-licensed support me via GitHub Sponsors chat with me on Twitter

Installing

npm install -g print-gtfs-rt-cli

Or use npx. ✨

Getting Started

With the example feed example-feed.pbf, the first FeedEntity can be obtained as JSON and pretty-printed using jq like this:

print-gtfs-rt <example-feed.pbf | head -n 1 | jq -r --tab
{
    "id": "8.TA.40-11-Y-j18-1.7.H",
    "trip_update": {
        "trip": {
            "trip_id": "8.TA.40-11-Y-j18-1.7.H",
            "start_time": "12:00:00",
            "start_date": "20180907",
            "schedule_relationship": 0,
            "route_id": "40-11-Y-j18-1"
        },
        "stop_time_update": [
            {
                "stop_sequence": 1,
                "departure": {
                    "delay": 120
                },
                "stop_id": "8507492:0:7",
                "schedule_relationship": 0
            },
            {
                "stop_sequence": 4,
                "arrival": {
                    "delay": 0
                },
                "departure": {
                    "delay": 60
                },
                "stop_id": "8507100:0:2",
                "schedule_relationship": 0
            },
            {
                "stop_sequence": 5,
                "arrival": {
                    "delay": 0
                },
                "departure": {
                    "delay": 0
                },
                "stop_id": "8507000:0:6",
                "schedule_relationship": 0
            },
            {
                "stop_sequence": 7,
                "arrival": {
                    "delay": 60
                },
                "departure": {
                    "delay": 120
                },
                "stop_id": "8500218:0:7",
                "schedule_relationship": 0
            },
            {
                "stop_sequence": 8,
                "arrival": {
                    "delay": 60
                },
                "departure": {
                    "delay": 60
                },
                "stop_id": "8500023:0:3",
                "schedule_relationship": 0
            },
            {
                "stop_sequence": 9,
                "arrival": {
                    "delay": -60
                },
                "departure": {
                    "delay": 0
                },
                "stop_id": "8500010:0:10",
                "schedule_relationship": 0
            }
        ]
    }
}

Usage

Usage:
    cat gtfs-rt-feed.pbf | print-gtfs-rt
Options:
    --length-prefixed  -l  Read input as length-prefixed.
                           See https://www.npmjs.com/package/length-prefixed-stream
    --json             -j  Output newline-delimeted JSON (http://ndjson.org).
    --single-json -s       Output a single JSON array.
    --depth            -d  Number of nested levels to print. Default: infinite
    --include-all      -a  Print the entire FeedMessage, including its header.
    --gtfs-rt-bindings     Path to GTFS-RT bindings. Must be compatible with
                           those generated by protobufjs.
Examples:
    curl 'https://example.org/gtfs-rt.pbf' -H 'User-Agent: <your name>' -fsSL | print-gtfs-rt

Contributing

If you have a question or have difficulties using print-gtfs-rt-cli, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Example feed

The example feed example-feed.pbf is taken from the Swiss open GTFS-RT feed, licensed under their open data license.

About

Read a GTFS Realtime feed from stdin, print human-readable or as JSON.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 3

  •  
  •  
  •