View Source MBTA.Api.Vehicle (mbta_sdk v0.1.0)

API calls for all endpoints tagged Vehicle.

Summary

Functions

List of vehicles (buses, ferries, and trains) ## Direction ### World To figure out which way the vehicle is pointing at the location, use /data/{index}/attributes/bearing. This can be the compass bearing, or the direction towards the next stop or intermediate location. ### Trip To get the direction around the stops in the trip use /data/{index}/attributes/direction_id. ## Location ### World Use /data/{index}/attributes/latitude and /data/{index}/attributes/longitude to get the location of a vehicle. ### Trip Use /data/{index}/attributes/current_stop_sequence to get the stop number along the trip. Useful for linear stop indicators. Position relative to the current stop is in /data/{index}/attributes/current_status. ## Movement ### World Use /data/{index}/attributes/speed to get the speed of the vehicle in meters per second.

Single vehicle (bus, ferry, or train) ## Direction ### World To figure out which way the vehicle is pointing at the location, use /data/attributes/bearing. This can be the compass bearing, or the direction towards the next stop or intermediate location. ### Trip To get the direction around the stops in the trip use /data/attributes/direction_id. ## Location ### World Use /data/attributes/latitude and /data/attributes/longitude to get the location of a vehicle. ### Trip Use /data/attributes/current_stop_sequence to get the stop number along the trip. Useful for linear stop indicators. Position relative to the current stop is in /data/attributes/current_status. ## Movement ### World Use /data/attributes/speed to get the speed of the vehicle in meters per second.

Functions

Link to this function

api_web_vehicle_controller_index(connection, opts \\ [])

View Source
@spec api_web_vehicle_controller_index(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, MBTA.Model.Forbidden.t()}
  | {:ok, MBTA.Model.TooManyRequests.t()}
  | {:ok, MBTA.Model.Vehicles.t()}
  | {:ok, MBTA.Model.BadRequest.t()}
  | {:error, Tesla.Env.t()}

List of vehicles (buses, ferries, and trains) ## Direction ### World To figure out which way the vehicle is pointing at the location, use /data/{index}/attributes/bearing. This can be the compass bearing, or the direction towards the next stop or intermediate location. ### Trip To get the direction around the stops in the trip use /data/{index}/attributes/direction_id. ## Location ### World Use /data/{index}/attributes/latitude and /data/{index}/attributes/longitude to get the location of a vehicle. ### Trip Use /data/{index}/attributes/current_stop_sequence to get the stop number along the trip. Useful for linear stop indicators. Position relative to the current stop is in /data/{index}/attributes/current_status. ## Movement ### World Use /data/{index}/attributes/speed to get the speed of the vehicle in meters per second.

Parameters

  • connection (MBTA.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :"page[offset]" (integer()): Offset (0-based) of first element in the page
    • :"page[limit]" (integer()): Max number of elements to return
    • :sort (String.t): Results can be sorted by the id or any /data/{index}/attributes key. Assumes ascending; may be prefixed with '-' for descending | JSON pointer | Direction | sort | |--------------|-----------|------------| | /data/{index}/attributes/bearing | ascending | bearing | | /data/{index}/attributes/bearing | descending | -bearing | | /data/{index}/attributes/carriages | ascending | carriages | | /data/{index}/attributes/carriages | descending | -carriages | | /data/{index}/attributes/current_status | ascending | current_status | | /data/{index}/attributes/current_status | descending | -current_status | | /data/{index}/attributes/current_stop_sequence | ascending | current_stop_sequence | | /data/{index}/attributes/current_stop_sequence | descending | -current_stop_sequence | | /data/{index}/attributes/direction_id | ascending | direction_id | | /data/{index}/attributes/direction_id | descending | -direction_id | | /data/{index}/attributes/label | ascending | label | | /data/{index}/attributes/label | descending | -label | | /data/{index}/attributes/latitude | ascending | latitude | | /data/{index}/attributes/latitude | descending | -latitude | | /data/{index}/attributes/longitude | ascending | longitude | | /data/{index}/attributes/longitude | descending | -longitude | | /data/{index}/attributes/occupancy_status | ascending | occupancy_status | | /data/{index}/attributes/occupancy_status | descending | -occupancy_status | | /data/{index}/attributes/speed | ascending | speed | | /data/{index}/attributes/speed | descending | -speed | | /data/{index}/attributes/updated_at | ascending | updated_at | | /data/{index}/attributes/updated_at | descending | -updated_at |

    • :"fields[vehicle]" (String.t): Fields to include with the response. Multiple fields MUST be a comma-separated (U+002C COMMA, ",") list. Note that fields can also be selected for included data types: see the V3 API Best Practices for an example.
    • :include (String.t): Relationships to include. trip stop route The value of the include parameter MUST be a comma-separated (U+002C COMMA, ",") list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, ".") list of relationship names. JSONAPI "include" behavior | include | Description | |---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | trip | The trip which the vehicle is currently operating. | | stop | The vehicle's current (when current_status is STOPPED_AT) or next* stop. | | route | The one route that is designated for that trip, as in GTFS trips.txt. A trip might also provide service on other routes, identified by the MBTA's multi_route_trips.txt GTFS extension. filter[route] does consider the multi_route_trips GTFS extension, so it is possible to filter for one route and get a different route included in the response. |

    • :"filter[id]" (String.t): Filter by multiple IDs. Multiple IDs MUST be a comma-separated (U+002C COMMA, ",") list. Cannot be combined with any other filter.
    • :"filter[trip]" (String.t): Filter by /data/{index}/relationships/trip/data/id. Multiple /data/{index}/relationships/trip/data/id MUST be a comma-separated (U+002C COMMA, ",") list. Cannot be combined with any other filter.
    • :"filter[label]" (String.t): Filter by label. Multiple label MUST be a comma-separated (U+002C COMMA, ",") list.
    • :"filter[route]" (String.t): Filter by route. If the vehicle is on a multi-route trip, it will be returned for any of the routes. Multiple route_id MUST be a comma-separated (U+002C COMMA, ",") list.
    • :"filter[direction_id]" (String.t): Filter by direction of travel along the route. Must be used in conjuction with filter[route] to apply. The meaning of direction_id varies based on the route. You can programmatically get the direction names from /routes /data/{index}/attributes/direction_names or /routes/{id} /data/attributes/direction_names. Only used if filter[route] is also present.
    • :"filter[route_type]" (String.t): Filter by route_type: https://developers.google.com/transit/gtfs/reference/routes-file. Multiple route_type MUST be a comma-separated (U+002C COMMA, ",") list.

Returns

  • {:ok, MBTA.Model.Vehicles.t} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

api_web_vehicle_controller_show(connection, id, opts \\ [])

View Source
@spec api_web_vehicle_controller_show(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, MBTA.Model.NotAcceptable.t()}
  | {:ok, MBTA.Model.Forbidden.t()}
  | {:ok, MBTA.Model.TooManyRequests.t()}
  | {:ok, MBTA.Model.Vehicle.t()}
  | {:ok, MBTA.Model.NotFound.t()}
  | {:error, Tesla.Env.t()}

Single vehicle (bus, ferry, or train) ## Direction ### World To figure out which way the vehicle is pointing at the location, use /data/attributes/bearing. This can be the compass bearing, or the direction towards the next stop or intermediate location. ### Trip To get the direction around the stops in the trip use /data/attributes/direction_id. ## Location ### World Use /data/attributes/latitude and /data/attributes/longitude to get the location of a vehicle. ### Trip Use /data/attributes/current_stop_sequence to get the stop number along the trip. Useful for linear stop indicators. Position relative to the current stop is in /data/attributes/current_status. ## Movement ### World Use /data/attributes/speed to get the speed of the vehicle in meters per second.

Parameters

  • connection (MBTA.Connection): Connection to server
  • id (String.t): Unique identifier for a vehicle
  • opts (keyword): Optional parameters
    • :"fields[vehicle]" (String.t): Fields to include with the response. Multiple fields MUST be a comma-separated (U+002C COMMA, ",") list. Note that fields can also be selected for included data types: see the V3 API Best Practices for an example.
    • :include (String.t): Relationships to include. trip stop route The value of the include parameter MUST be a comma-separated (U+002C COMMA, ",") list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, ".") list of relationship names. JSONAPI "include" behavior | include | Description | |---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | trip | The trip which the vehicle is currently operating. | | stop | The vehicle's current (when current_status is STOPPED_AT) or next* stop. | | route | The one route that is designated for that trip, as in GTFS trips.txt. A trip might also provide service on other routes, identified by the MBTA's multi_route_trips.txt GTFS extension. filter[route] does consider the multi_route_trips GTFS extension, so it is possible to filter for one route and get a different route included in the response. |

Returns

  • {:ok, MBTA.Model.Vehicle.t} on success
  • {:error, Tesla.Env.t} on failure