The gtfs command can import and export SQLite data and refresh GTFS-Realtime
feeds. PostgreSQL and MySQL connections use the JavaScript API.
gtfs --help
gtfs import --help
gtfs export --help
gtfs realtime refresh --helpPut options after the command they apply to, for example gtfs import --input.
gtfs import --input ./feed.zip --database ./transit.sqlite
gtfs import --url https://example.com/gtfs.zip --database ./transit.sqlite
gtfs import --config ./config.json| Option | Meaning |
|---|---|
--input <path> |
Local ZIP or directory. |
--url <url> |
Download a Schedule ZIP. Use instead of --input. |
--database <path> |
SQLite file to use. Specify a path for persistent data. |
--source-id <id> |
Identity for a direct --input or --url; defaults to default. |
Direct --input or --url replaces the entire configured sources list.
For sources in a config file, set sources[].sourceId in that file rather
than passing --source-id.
Import requires --database or database.path in your configuration. Use a
file path to keep the imported data. Explicit --database :memory: is allowed,
but all imported data is discarded when the command finishes.
Export refuses an existing destination unless export.overwrite is true
in your config file. Replacement happens after the new files are generated
and removes the entire old destination. Use a dedicated folder. See
export safety.
gtfs export --database ./transit.sqlite --output ./exported-feed
gtfs export --database ./transit.sqlite --source-id metro --output ./metro-feed| Option | Meaning |
|---|---|
--database <path> |
SQLite file containing imported data. |
--source-id <id> |
Export this source; required when multiple sources would match. |
--output <directory> |
Destination for exported files. |
gtfs realtime refresh --config ./config.jsonThe config must enable gtfs-realtime and define GTFS-Realtime feeds. A command
fetches them once and exits; use your own scheduler for regular refreshes.
There is no command-line GTFS-Realtime feed URL override for GTFS-Realtime.
| Option | Short form | Applies to |
|---|---|---|
--config <path> |
-c |
Import, export, refresh. |
--log-level <level> |
-l |
Import, export, refresh. Values: silent, error, warn, info. |
--database <path> |
— | Import, export, refresh. |
--help |
-h |
Every command and command group. |
--version |
-v |
Every command and command group. |
Without --config, the CLI reads ./config.json if it exists. Explicit CLI
values override the corresponding config values. Direct input/database flags
can be used without a config file, but do not prevent an existing default
config file from being read.
Progress, warnings, and errors go to stderr; help and version output go to stdout. Interactive terminals show animated progress. Redirected output uses plain lines.
gtfs import --config ./config.json --log-level warnThrown failures exit with status 1. If you configure a Schedule source to
continue after errors, use the JavaScript result’s success and errors
fields when your automation needs to detect partial failures; a returned
unsuccessful import result does not itself set a failing CLI exit status.