79 releases

0.34.0 May 11, 2023
0.33.1 Feb 16, 2023
0.33.0 Dec 4, 2022
0.32.3 Nov 12, 2022
0.4.2 May 2, 2018

#161 in Parser implementations

Download history 44/week @ 2023-06-07 94/week @ 2023-06-14 244/week @ 2023-06-21 150/week @ 2023-06-28 125/week @ 2023-07-05 47/week @ 2023-07-12 73/week @ 2023-07-19 56/week @ 2023-07-26 37/week @ 2023-08-02 65/week @ 2023-08-09 194/week @ 2023-08-16 166/week @ 2023-08-23 97/week @ 2023-08-30 233/week @ 2023-09-06 82/week @ 2023-09-13 108/week @ 2023-09-20

539 downloads per month
Used in 2 crates

MIT license

2.5K SLoC

Contains (Zip file, 4KB) fixtures/zips/macosx.zip, (Zip file, 3KB) fixtures/zips/gtfs.zip, (Zip file, 3KB) fixtures/zips/gtfs_with_bom.zip, (Zip file, 3KB) fixtures/zips/subdirectory.zip

GTFS Model crates.io

The General Transit Feed Specification (GTFS) is a commonly used model to represent public transit data.

This crates brings serde structures of this model and helpers to read GTFS archives.


This crates has 2 main entry-points.


The most common one is to create a gtfs_structures::Gtfs:

// Gtfs::new will try to guess if you provide a path, a local zip file or a remote zip file.
// You can also use Gtfs::from_path or Gtfs::from_url
let gtfs = gtfs_structures::Gtfs::new("path_of_a_zip_or_directory_or_url")?;
println!("there are {} stops in the gtfs", gtfs.stops.len());

// This structure is the easiest to use as the collections are `HashMap`,
// thus you can access an object by its id.
let route_1 = gtfs.routes.get("1").expect("no route 1");
println!("{}: {:?}", route_1.short_name, route_1);


If you want a lower level model, you can use gtfs_structures::RawGtfs:

let raw_gtfs = RawGtfs::new("fixtures/basic").expect("impossible to read gtfs");
for stop in raw_gtfs.stops.expect("impossible to read stops.txt") {
    println!("stop: {}", stop.name);

Instead of easy to use HashMap, each collection is a Result with an error if something went wrong during the reading.

This makes it possible for example for a GTFS validator to display better error messages.

Feature 'read-url'

By default the feature 'read-url' is activated. It makes it possible to read a Gtfs from an url.

let gtfs = gtfs_structures::Gtfs::new("http://www.metromobilite.fr/data/Horaires/SEM-GTFS.zip")?;

Or you can use the explicit constructor:

let gtfs = gtfs_structures::Gtfs::from_url("http://www.metromobilite.fr/data/Horaires/SEM-GTFS.zip")?;

If you don't want the dependency to reqwest, you can remove this feature.


You need an up to date rust tool-chain (commonly installed with rustup).

Building is done with:

cargo build

You can also run the unit tests:

cargo test

And run the examples by giving their names:

cargo run --example gtfs_reading


If you are interested in transit data, you can also use the really nice crate transit_model that can also handle GTFS data.

The price to pay is a steeper learning curve (and a documentation that could be improved 🙄), but this crate provides very nice ergonomics to handle transit data and lots of utilities like data format conversions, datasets merge, ...


~295K SLoC