This gem is a thin wrapper around the public transportation web APIs provided by Samtrafiken. Its classes and methods correspond to the different APIs and their HTTP endpoints.
Please see the following pages to get an idea of what each API provides.
- ResRobot Sök Resa
(implemented by
SamtrafikenAPI::Resrobot
) - ResRobot Stolptidtabeller
(implemented by
SamtrafikenAPI::ResrobotStops
) - Samtrafiken Stationsinfo
(implemented by
SamtrafikenAPI::Stationinfo
)
The methods return the raw json data provided by the APIs, parsed into Ruby objects.
You need to sign up with Trafiklab and get API keys for each of the APIs that you are going to use.
Please see the class documentation and the test suite for examples of how the gem is used.
Samtrafiken API uses rspec for testing. These environment variables need to be defined in order to run the test suite.
RESROBOT_API_KEY
– a "Resrobot Sök Resa" API key. See http://www.trafiklab.se/api/resrobot-sok-resa/dokumentation-resrobot-sok-resa-0RESROBOT_STOPS_API_KEY
– a "Resrobot Stolptidtabeller" API key. See http://www.trafiklab.se/api/resrobot-stolptidtabeller/dokumentation-stolptidtabellerSTATIONSINFO_API_KEY
– a "Samtrafiken Stationsinfo" API key. See http://www.trafiklab.se/api/samtrafiken-stationsinfo/sammanfattande-dokumentation-stationsinfo
Example:
RESROBOT_API_KEY=MY-KEY RESROBOT_STOPS_API_KEY=MY-OTHER-KEY STATIONSINFO_API_KEY=MY-THIRD-KEY bundle exec rake test