go_transit_ruby

Ruby Interface for the Go Transit API


License
MIT
Install
gem install go_transit_ruby -v 0.5.0

Documentation

Go Transit API Ruby Wrapper

Tests Maintainability Test Coverage

This gem is intended to make working with the Go Transit API easier and more consistent. The API endpoints were re-created as close to the API spec wherever possible, but some exceptions do exist. Reference the Go Transit API documenation for details on available fields.

This gem does not parse any of the GTFS feeds. For those I recommend using a gem dedicated to parsing GTFS Real Time feeds since it is a stardized data type.

API Keys

You can get a Go Transit API key here http://api.openmetrolinx.com/OpenDataAPI/Help/Registration/en.

Usage

Import go-transit-ruby and set your API key.

require "go-transit-ruby"
GoTransit.api_key = "YOUR_API_KEY"

This gem exposes the Go Transit API endpoints and hydrates objects related to the returned data.

Stop

Method Reference
GoTransit::Stop.all Link
GoTransit::Stop.details(stop_code: <string>) Link
GoTransit::Stop.next_service(stop_code: <string>) Link
GoTransit::Stop.destinations(stop_code: <string>, from_time: <string>, to_time: <string>) Link

Service Update

Method Reference
GoTransit::ServiceUpdate.service_alerts Link
GoTransit::ServiceUpdate.information_alerts Link
GoTransit::ServiceUpdate.marketing_alerts Link
GoTransit::ServiceUpdate.union_departures Link
GoTransit::ServiceUpdate.service_guarantee(trip_number: <string>, operational_day: <string>) Link
GoTransit::ServiceUpdate::Exceptions.train Link
GoTransit::ServiceUpdate::Exceptions.bus Link
GoTransit::ServiceUpdate::Exceptions.all Link

Service At Glance

Method Reference
GoTransit::ServiceAtAGlance.buses Link
GoTransit::ServiceAtAGlance.trains Link
GoTransit::ServiceAtAGlance.upx Link

Schedule

Method Reference
GoTransit::Schedule.journey(date: <Date>, from_stop_code: <string>, to_stop_code: <string>, start_time: <string>, max_journey: <int>) Link
GoTransit::Schedule.line(date: <Date>, line_code: <string>, line_direction: <string>) Link
GoTransit::Schedule::Line.all(date: <Date>) Link
GoTransit::Schedule::Line.stop(date: <Date>, line_code: <string>, line_direction: <string>) Link
GoTransit::Schedule.trip(date: <Date>, trip_number: <string>) Link

Fare

Method Reference
GoTransit::Fare.get(from_stop_code: <string>, to_stop_code: <string>, operational_day: <nil|string>) Link or Link

Missing Test Data

At the time of development I was unable to get test data for the following endpoints. Some of these seem like they are restricted access endpoints and my key is unable to fetch any data. I'm not sure if the others are caused by API issues. These endpoints should work assuming the documenation is correct, but the lack of data means testing was not possible. If you are able to get data for these endpoints please open a PR and submit it, it would greatly help development.

  • GET api/V1/ServiceataGlance/UPX/All - 204 No Content
  • GET api/V1/ServiceUpdate/ServiceGuarantee/{TripNumber}/{OperationalDay} - 204 No Content
  • GET api/V1/ServiceUpdate/MarketingAlert/All - 204 No Content
  • GET api/V1/Fleet/Consist/All - 403 Forbidden
  • GET api/V1/Fleet/Consist/Engine/{EngineNumber} - 403 Forbidden