1.8.4 • Published 8 months ago

gtfs-realtime-bindings-transit v1.8.4

Weekly downloads
12
License
-
Repository
github
Last release
8 months ago

JavaScript GTFS-realtime Language Bindings

Provides JavaScript classes generated from the 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 environment, but with some effort, they can probably be used in other JavaScript environments as well.

We use the ProtBuf.js library for JavaScript Protocol Buffer support.

Add the Dependency

To use the gtfs-realtime-bindings classes in your own project, you need to first install our Node.js npm package:

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.

var GtfsRealtimeBindings = require('gtfs-realtime-bindings');
var request = require('request');

var requestSettings = {
  method: 'GET',
  url: 'URL OF YOUR GTFS-REALTIME SOURCE GOES HERE',
  encoding: null
};
request(requestSettings, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    var feed = GtfsRealtimeBindings.FeedMessage.decode(body);
    feed.entity.forEach(function(entity) {
      if (entity.trip_update) {
        console.log(entity.trip_update);
      }
    });
  }
});

For more details on the naming conventions for the Javascript classes generated from the gtfs-realtime.proto, check out the ProtoBuf.js project which we use to handle our Protocol Buffer serialization.

Updating

Note that, to maintain compatability with CommonJS typescript projects, we need to manually change the Long type to the stub type included in the ProtobufJS library.

1.8.4

8 months ago

1.8.2

1 year ago

1.8.3-RC1

1 year ago

1.8.3

1 year ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.4

3 years ago

1.6.3

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago