# gtfs-realtime-bindings

> Javascript classes generated from the GTFS-realtime protocol buffer specification.

Latest version **2.2.0** (published 2026-07-29) · 19.7K weekly downloads

## Install

```sh
npm install gtfs-realtime-bindings
pnpm add gtfs-realtime-bindings
yarn add gtfs-realtime-bindings
bun add gtfs-realtime-bindings
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-07-29 |
| First published | 2015-01-22 |
| Weekly downloads | 19.7K |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=22 |
| Dependencies | 2 |
| Unpacked size | 671.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 441 |
| Author | MobilityData |
| Maintainers | bdferris, barbeau, isabelledr, jameslinjl, mobilitydataitowneraccount |

## Links

- npm: https://www.npmjs.com/package/gtfs-realtime-bindings
- Repository: https://github.com/MobilityData/gtfs-realtime-bindings
- Homepage: https://github.com/MobilityData/gtfs-realtime-bindings#readme
- Issues: https://github.com/MobilityData/gtfs-realtime-bindings/issues
- npm.io page: https://npm.io/package/gtfs-realtime-bindings

## Dependencies (2)

- [protobufjs](https://npm.io/package/protobufjs.md) ^8.2.1
- [protobufjs-cli](https://npm.io/package/protobufjs-cli.md) ^2.2.1

## Recent versions

- 2.2.0 (latest) — 2026-07-29
- 2.1.0 — 2026-07-02
- 2.0.0 — 2026-05-21
- 1.1.1 — 2023-01-17
- 1.1.0 — 2023-01-17
- 1.0.0 — 2023-01-17
- 0.0.6 — 2020-09-11
- 0.0.5 — 2019-04-23
- 0.0.4 — 2015-02-27
- 0.0.3 — 2015-01-30
- 0.0.2 — 2015-01-28
- 0.0.1 — 2015-01-22

## README

# JavaScript GTFS-realtime Language Bindings

[![npm version](https://badge.fury.io/js/gtfs-realtime-bindings.svg)](http://badge.fury.io/js/gtfs-realtime-bindings)

Provides JavaScript classes and their associated types generated from the
[GTFS-realtime](https://github.com/google/transit/tree/master/gtfs-realtime) Protocol
Buffer specification.  These classes will allow you to parse a binary Protocol
Buffer GTFS-realtime data feed into JavaScript objects.

These bindings are designed to be used in the [Node.js](http://nodejs.org/)
environment, but with some effort, they can probably be used in other
JavaScript environments as well.

We use the [ProtoBuf.js](https://github.com/protobufjs/protobuf.js) library for
JavaScript Protocol Buffer support.

## Breaking Changes

### Version 2.0.0

Version 2.0.0 requires **Node.js 22 or later**. If you are using an older version of Node.js, please continue using version `1.x`.

## Add the Dependency

To use the `gtfs-realtime-bindings` classes in your own project, you need to
first install our [Node.js npm package](https://www.npmjs.com/package/gtfs-realtime-bindings):

```
npm install gtfs-realtime-bindings
```

## Example Code

The following Node.js code snippet demonstrates downloading a GTFS-realtime
data feed from a particular URL, parsing it as a FeedMessage (the root type of
the GTFS-realtime schema), and iterating over the results.

In order to make this example work, you must first install `node-fetch` with NPM.

_Note: this exemple is using ES modules (`import`/`export` syntax) and is not compatible
with CommonJS (`require` syntax). You can use CommonJS by converting `import` to `require`
and installing `node-fetch@2`. Learn more about ES modules [here](https://nodejs.org/api/esm.html)._

```javascript
import GtfsRealtimeBindings from "gtfs-realtime-bindings";
import fetch from "node-fetch";

(async () => {
  try {
    const response = await fetch("<GTFS-realtime source URL>", {
      headers: {
        "x-api-key": "<redacted>",
        // replace with your GTFS-realtime source's auth token
        // e.g. x-api-key is the header value used for NY's MTA GTFS APIs
      },
    });
    if (!response.ok) {
      const error = new Error(`${response.url}: ${response.status} ${response.statusText}`);
      error.response = response;
      throw error;
      process.exit(1);
    }
    const buffer = await response.arrayBuffer();
    const feed = GtfsRealtimeBindings.transit_realtime.FeedMessage.decode(
      new Uint8Array(buffer)
    );
    feed.entity.forEach((entity) => {
      if (entity.tripUpdate) {
        console.log(entity.tripUpdate);
      }
    });
  }
  catch (error) {
    console.log(error);
    process.exit(1);
  }
})();
```

For more details on the naming conventions for the JavaScript classes generated
from the
[gtfs-realtime.proto](https://github.com/google/transit/blob/master/gtfs-realtime/proto/gtfs-realtime.proto),
check out the [ProtoBuf.js project](https://github.com/protobufjs/protobuf.js)
which we use to handle our Protocol Buffer serialization.

---
_Source: https://npm.io/package/gtfs-realtime-bindings · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
