Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Client for MOTIS API

This is the MOTIS routing API.

Version: v4

Implementations§

Source§

impl Client

Source

pub fn new(baseurl: &str) -> Self

Create a new client.

baseurl is the base URL provided to the internal reqwest::Client, and should include a scheme and hostname, as well as port and a path stem if applicable.

Source

pub fn new_with_client(baseurl: &str, client: Client) -> Self

Construct a new client with an existing reqwest::Client, allowing more control over its configuration.

baseurl is the base URL provided to the internal reqwest::Client, and should include a scheme and hostname, as well as port and a path stem if applicable.

Source§

impl Client

Source

pub fn plan(&self) -> Plan<'_>

Computes optimal connections from one place to another

Sends a GET request to /api/v4/plan

Arguments:

  • additional_transfer_time: Optional. Default is 0 minutes.

Additional transfer time reserved for each transfer in minutes.

  • algorithm: algorithm to use

  • arrive_by: Optional. Default is false.

  • arriveBy=true: the parameters date and time refer to the arrival time

  • arriveBy=false: the parameters date and time refer to the departure time

  • detailed_transfers: - true: Compute transfer polylines and step instructions.

  • false: Only return basic information (start time, end time, duration) for transfers.

  • direct_modes: Optional. Default is WALK which will compute walking routes as direct connections.

Modes used for direction connections from start to destination without using transit. Results will be returned on the direct key.

Note: Direct connections will only be returned on the first call. For paging calls, they can be omitted.

Note: Transit connections that are slower than the fastest direct connection will not show up. This is being used as a cut-off during transit routing to speed up the search. To prevent this, it’s possible to send two separate requests (one with only transitModes and one with only directModes).

Note: the output direct array will stay empty if the input param maxDirectTime makes any direct trip impossible.

Only non-transit modes such as WALK, BIKE, CAR, BIKE_SHARING, etc. can be used.

  • direct_rental_form_factors: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies to direct connections.

A list of vehicle type form factors that are allowed to be used for direct connections. If empty (the default), all form factors are allowed. Example: BICYCLE,SCOOTER_STANDING.

  • direct_rental_propulsion_types: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies to direct connections.

A list of vehicle type form factors that are allowed to be used for direct connections. If empty (the default), all propulsion types are allowed. Example: HUMAN,ELECTRIC,ELECTRIC_ASSIST.

  • direct_rental_providers: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies to direct connections.

A list of rental providers that are allowed to be used for direct connections. If empty (the default), all providers are allowed.

  • elevation_costs: Optional. Default is NONE.

Set an elevation cost profile, to penalize routes with incline.

  • NONE: No additional costs for elevations. This is the default behavior
  • LOW: Add a low cost for increase in elevation and incline along the way. This will prefer routes with less ascent, if small detours are required.
  • HIGH: Add a high cost for increase in elevation and incline along the way. This will prefer routes with less ascent, if larger detours are required.

As using an elevation costs profile will increase the travel duration, routing through steep terrain may exceed the maximal allowed duration, causing a location to appear unreachable. Increasing the maximum travel time for these segments may resolve this issue.

The profile is used for direct routing, on the first mile, and last mile.

Elevation cost profiles are currently used by following street modes:

  • BIKE

  • fastest_direct_factor: Optional. Experimental. Default is 1.0. Factor with which the duration of the fastest direct non-public-transit connection is multiplied. Values > 1.0 allow transit connections that are slower than the fastest direct non-public-transit connection to be found.

  • fastest_slow_direct_factor: Optional. Factor with which the duration of the fastest slowDirect connection is multiplied. Values > 1.0 allow connections that are slower than the fastest direct transit connection to be found. Values < 1.0 will return all slowDirect connections.

  • from_place: `latitude,longitude[,level]` tuple with

  • latitude and longitude in degrees

  • (optional) level: the OSM level (default: 0)

OR

stop id

  • ignore_direct_rental_return_constraints: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Default is false.

If set to true, the routing will ignore rental return constraints for direct connections, allowing the rental vehicle to be parked anywhere.

  • ignore_post_transit_rental_return_constraints: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Default is false.

If set to true, the routing will ignore rental return constraints for the part from the last transit stop to the to coordinate, allowing the rental vehicle to be parked anywhere.

  • ignore_pre_transit_rental_return_constraints: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Default is false.

If set to true, the routing will ignore rental return constraints for the part from the from coordinate to the first transit stop, allowing the rental vehicle to be parked anywhere.

  • join_interlined_legs: Optional. Default is true.

Controls if a journey section with stay-seated transfers is returned:

  • joinInterlinedLegs=false: as several legs (full information about all trip numbers, headsigns, etc.). Legs that do not require a transfer (stay-seated transfer) are marked with interlineWithPreviousLeg=true.

  • joinInterlinedLegs=true (default behavior): as only one joined leg containing all stops

  • language: language tags as used in OpenStreetMap / GTFS (usually BCP-47 / ISO 639-1, or ISO 639-2 if there’s no ISO 639-1)

  • luggage: Optional. Experimental. Number of luggage pieces; base unit: airline cabin luggage (e.g. for ODM or price calculation)

  • max_direct_time: Optional. Default is 30min which is 1800. Maximum time in seconds for direct connections.

  • max_matching_distance: Optional. Default is 25 meters.

Maximum matching distance in meters to match geo coordinates to the street network.

  • max_post_transit_time: Optional. Default is 15min which is 900. Maximum time in seconds for the last street leg.

  • max_pre_transit_time: Optional. Default is 15min which is 900. Maximum time in seconds for the first street leg.

  • max_transfers: The maximum number of allowed transfers (i.e. interchanges between transit legs, pre- and postTransit do not count as transfers). maxTransfers=0 searches for direct transit connections without any transfers. If you want to search only for non-transit connections (FOOT, CAR, etc.), send an empty transitModes parameter instead.

If not provided, the routing uses the server-side default value which is hardcoded and very high to cover all use cases.

Warning: Use with care. Setting this too low can lead to optimal (e.g. the fastest) journeys not being found. If this value is too low to reach the destination at all, it can lead to slow routing performance.

In plan endpoints before v3, the behavior is off by one, i.e. maxTransfers=0 only returns non-transit connections.

  • max_travel_time: The maximum travel time in minutes. If not provided, the routing to uses the value hardcoded in the server which is usually quite high.

Warning: Use with care. Setting this too low can lead to optimal (e.g. the least transfers) journeys not being found. If this value is too low to reach the destination at all, it can lead to slow routing performance.

  • min_transfer_time: Optional. Default is 0 minutes.

Minimum transfer time for each transfer in minutes.

  • num_itineraries: The minimum number of itineraries to compute. This is only relevant if timetableView=true. The default value is 5.

  • page_cursor: Use the cursor to go to the next “page” of itineraries. Copy the cursor from the last response and keep the original request as is. This will enable you to search for itineraries in the next or previous time-window.

  • passengers: Optional. Experimental. Number of passengers (e.g. for ODM or price calculation)

  • pedestrian_profile: Optional. Default is FOOT.

Accessibility profile to use for pedestrian routing in transfers between transit connections, on the first mile, and last mile.

  • post_transit_modes: Optional. Default is WALK. Only applies if the to place is a coordinate (not a transit stop). Does not apply to direct connections (see directModes).

A list of modes that are allowed to be used from the last transit stop to the to coordinate. Example: WALK,BIKE_SHARING.

  • post_transit_rental_form_factors: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies if the to place is a coordinate (not a transit stop). Does not apply to direct connections (see directRentalFormFactors).

A list of vehicle type form factors that are allowed to be used from the last transit stop to the to coordinate. If empty (the default), all form factors are allowed. Example: BICYCLE,SCOOTER_STANDING.

  • post_transit_rental_propulsion_types: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies if the to place is a coordinate (not a transit stop). Does not apply to direct connections (see directRentalPropulsionTypes).

A list of vehicle propulsion types that are allowed to be used from the last transit stop to the to coordinate. If empty (the default), all propulsion types are allowed. Example: HUMAN,ELECTRIC, ELECTRIC_ASSIST.

  • post_transit_rental_providers: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies if the to place is a coordinate (not a transit stop). Does not apply to direct connections (see directRentalProviders).

A list of rental providers that are allowed to be used from the last transit stop to the to coordinate. If empty (the default), all providers are allowed.

  • pre_transit_modes: Optional. Default is WALK. Only applies if the from place is a coordinate (not a transit stop). Does not apply to direct connections (see directModes).

A list of modes that are allowed to be used from the from coordinate to the first transit stop. Example: WALK,BIKE_SHARING.

  • pre_transit_rental_form_factors: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies if the from place is a coordinate (not a transit stop). Does not apply to direct connections (see directRentalFormFactors).

A list of vehicle type form factors that are allowed to be used from the from coordinate to the first transit stop. If empty (the default), all form factors are allowed. Example: BICYCLE,SCOOTER_STANDING.

  • pre_transit_rental_propulsion_types: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies if the from place is a coordinate (not a transit stop). Does not apply to direct connections (see directRentalPropulsionTypes).

A list of vehicle propulsion types that are allowed to be used from the from coordinate to the first transit stop. If empty (the default), all propulsion types are allowed. Example: HUMAN,ELECTRIC, ELECTRIC_ASSIST.

  • pre_transit_rental_providers: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Only applies if the from place is a coordinate (not a transit stop). Does not apply to direct connections (see directRentalProviders).

A list of rental providers that are allowed to be used from the from coordinate to the first transit stop. If empty (the default), all providers are allowed.

  • require_bike_transport: Optional. Default is false.

If set to true, all used transit trips are required to allow bike carriage.

  • require_car_transport: Optional. Default is false.

If set to true, all used transit trips are required to allow car carriage.

  • search_window: Optional. Default is 2 hours which is 7200.

The length of the search-window in seconds. Default value two hours.

  • arriveBy=true: number of seconds between the earliest departure time and latest departure time

  • arriveBy=false: number of seconds between the earliest arrival time and the latest arrival time

  • slow_direct: Optional. Experimental. Adds overtaken direct public transit connections.

  • time: Optional. Defaults to the current time.

Departure time ($arriveBy=false) / arrival date ($arriveBy=true),

  • timeout: Optional. Query timeout in seconds.
  • timetable_view: Optional. Default is true.

Search for the best trip options within a time window. If true two itineraries are considered optimal if one is better on arrival time (earliest wins) and the other is better on departure time (latest wins). In combination with arriveBy this parameter cover the following use cases:

timetable=false = waiting for the first transit departure/arrival is considered travel time:

  • arriveBy=true: event (e.g. a meeting) starts at 10:00 am, compute the best journeys that arrive by that time (maximizes departure time)
  • arriveBy=false: event (e.g. a meeting) ends at 11:00 am, compute the best journeys that depart after that time

timetable=true = optimize “later departure” + “earlier arrival” and give all options over a time window:

  • arriveBy=true: the time window around date and time refers to the arrival time window

  • arriveBy=false: the time window around date and time refers to the departure time window

  • to_place: `latitude,longitude[,level]` tuple with

  • latitude and longitude in degrees

  • (optional) level: the OSM level (default: 0)

OR

stop id

  • transfer_time_factor: Optional. Default is 1.0

Factor to multiply minimum required transfer times with. Values smaller than 1.0 are not supported.

  • transit_modes: Optional. Default is TRANSIT which allows all transit modes (no restriction). Allowed modes for the transit part. If empty, no transit connections will be computed. For example, this can be used to allow only METRO,SUBWAY,TRAM.

  • use_routed_transfers: Optional. Default is false.

Whether to use transfers routed on OpenStreetMap data.

  • via: List of via stops to visit (only stop IDs, no coordinates allowed for now). Also see the optional parameter viaMinimumStay to set a set a minimum stay duration for each via stop.

  • via_minimum_stay: Optional. If not set, the default is 0,0 - no stay required.

For each via stop a minimum stay duration in minutes.

The value 0 signals that it’s allowed to stay in the same trip. This enables via stays without counting a transfer and can lead to better connections with less transfers. Transfer connections can still be found with viaMinimumStay=0.

  • with_fares: Optional. Experimental. If set to true, the response will contain fare information.
  • with_scheduled_skipped_stops: Optional. Include intermediate stops where passengers can not alight/board according to schedule.
 let response = client.plan()
    .additional_transfer_time(additional_transfer_time)
    .algorithm(algorithm)
    .arrive_by(arrive_by)
    .detailed_transfers(detailed_transfers)
    .direct_modes(direct_modes)
    .direct_rental_form_factors(direct_rental_form_factors)
    .direct_rental_propulsion_types(direct_rental_propulsion_types)
    .direct_rental_providers(direct_rental_providers)
    .elevation_costs(elevation_costs)
    .fastest_direct_factor(fastest_direct_factor)
    .fastest_slow_direct_factor(fastest_slow_direct_factor)
    .from_place(from_place)
    .ignore_direct_rental_return_constraints(ignore_direct_rental_return_constraints)
    .ignore_post_transit_rental_return_constraints(ignore_post_transit_rental_return_constraints)
    .ignore_pre_transit_rental_return_constraints(ignore_pre_transit_rental_return_constraints)
    .join_interlined_legs(join_interlined_legs)
    .language(language)
    .luggage(luggage)
    .max_direct_time(max_direct_time)
    .max_matching_distance(max_matching_distance)
    .max_post_transit_time(max_post_transit_time)
    .max_pre_transit_time(max_pre_transit_time)
    .max_transfers(max_transfers)
    .max_travel_time(max_travel_time)
    .min_transfer_time(min_transfer_time)
    .num_itineraries(num_itineraries)
    .page_cursor(page_cursor)
    .passengers(passengers)
    .pedestrian_profile(pedestrian_profile)
    .post_transit_modes(post_transit_modes)
    .post_transit_rental_form_factors(post_transit_rental_form_factors)
    .post_transit_rental_propulsion_types(post_transit_rental_propulsion_types)
    .post_transit_rental_providers(post_transit_rental_providers)
    .pre_transit_modes(pre_transit_modes)
    .pre_transit_rental_form_factors(pre_transit_rental_form_factors)
    .pre_transit_rental_propulsion_types(pre_transit_rental_propulsion_types)
    .pre_transit_rental_providers(pre_transit_rental_providers)
    .require_bike_transport(require_bike_transport)
    .require_car_transport(require_car_transport)
    .search_window(search_window)
    .slow_direct(slow_direct)
    .time(time)
    .timeout(timeout)
    .timetable_view(timetable_view)
    .to_place(to_place)
    .transfer_time_factor(transfer_time_factor)
    .transit_modes(transit_modes)
    .use_routed_transfers(use_routed_transfers)
    .via(via)
    .via_minimum_stay(via_minimum_stay)
    .with_fares(with_fares)
    .with_scheduled_skipped_stops(with_scheduled_skipped_stops)
    .send()
    .await;
Source

pub fn one_to_many(&self) -> OneToMany<'_>

Street routing from one to many places or many to one. The order in the response array corresponds to the order of coordinates of the `many` parameter in the query.

Sends a GET request to /api/v1/one-to-many

Arguments:

  • arrive_by: true = many to one false = one to many

  • elevation_costs: Optional. Default is NONE.

Set an elevation cost profile, to penalize routes with incline.

  • NONE: No additional costs for elevations. This is the default behavior
  • LOW: Add a low cost for increase in elevation and incline along the way. This will prefer routes with less ascent, if small detours are required.
  • HIGH: Add a high cost for increase in elevation and incline along the way. This will prefer routes with less ascent, if larger detours are required.

As using an elevation costs profile will increase the travel duration, routing through steep terrain may exceed the maximal allowed duration, causing a location to appear unreachable. Increasing the maximum travel time for these segments may resolve this issue.

Elevation cost profiles are currently used by following street modes:

  • BIKE

  • many: geo locations as latitude;longitude,latitude;longitude,…

  • max: maximum travel time in seconds

  • max_matching_distance: maximum matching distance in meters to match geo coordinates to the street network

  • mode: routing profile to use (currently supported: `WALK`, `BIKE`, `CAR`)

  • one: geo location as latitude;longitude

 let response = client.one_to_many()
    .arrive_by(arrive_by)
    .elevation_costs(elevation_costs)
    .many(many)
    .max(max)
    .max_matching_distance(max_matching_distance)
    .mode(mode)
    .one(one)
    .send()
    .await;
Source

pub fn one_to_all(&self) -> OneToAll<'_>

Computes all reachable locations from a given stop within a set duration. Each result entry will contain the fastest travel duration and the number of connections used.

Sends a GET request to /api/v1/one-to-all

Arguments:

  • additional_transfer_time: Optional. Default is 0 minutes.

Additional transfer time reserved for each transfer in minutes.

  • arrive_by: true = all to one, false = one to all

  • elevation_costs: Optional. Default is NONE.

Set an elevation cost profile, to penalize routes with incline.

  • NONE: No additional costs for elevations. This is the default behavior
  • LOW: Add a low cost for increase in elevation and incline along the way. This will prefer routes with less ascent, if small detours are required.
  • HIGH: Add a high cost for increase in elevation and incline along the way. This will prefer routes with less ascent, if larger detours are required.

As using an elevation costs profile will increase the travel duration, routing through steep terrain may exceed the maximal allowed duration, causing a location to appear unreachable. Increasing the maximum travel time for these segments may resolve this issue.

The profile is used for routing on both the first and last mile.

Elevation cost profiles are currently used by following street modes:

  • BIKE

  • max_matching_distance: Optional. Default is 25 meters.

Maximum matching distance in meters to match geo coordinates to the street network.

  • max_post_transit_time: Optional. Default is 15min which is 900.

  • arriveBy=true: Maximum time in seconds for the street leg at one location.

  • arriveBy=false: Currently not used

  • max_pre_transit_time: Optional. Default is 15min which is 900.

  • arriveBy=true: Currently not used

  • arriveBy=false: Maximum time in seconds for the street leg at one location.

  • max_transfers: The maximum number of allowed transfers (i.e. interchanges between transit legs, pre- and postTransit do not count as transfers). maxTransfers=0 searches for direct transit connections without any transfers. If you want to search only for non-transit connections (FOOT, CAR, etc.), send an empty transitModes parameter instead.

If not provided, the routing uses the server-side default value which is hardcoded and very high to cover all use cases.

Warning: Use with care. Setting this too low can lead to optimal (e.g. the fastest) journeys not being found. If this value is too low to reach the destination at all, it can lead to slow routing performance.

In plan endpoints before v3, the behavior is off by one, i.e. maxTransfers=0 only returns non-transit connections.

  • max_travel_time: The maximum travel time in minutes. Defaults to 90. The limit may be increased by the server administrator using onetoall_max_travel_minutes option in config.yml. See documentation for details.
  • min_transfer_time: Optional. Default is 0 minutes.

Minimum transfer time for each transfer in minutes.

  • one: `latitude,longitude[,level]` tuple with
  • latitude and longitude in degrees
  • (optional) level: the OSM level (default: 0)

OR

stop id

  • pedestrian_profile: Optional. Default is FOOT.

Accessibility profile to use for pedestrian routing in transfers between transit connections and the first and last mile respectively.

  • post_transit_modes: Optional. Default is WALK. The behavior depends on whether arriveBy is set:
  • arriveBy=true: Only applies if the one place is a coordinate (not a transit stop).
  • arriveBy=false: Currently not used

A list of modes that are allowed to be used from the last transit stop to the to coordinate. Example: WALK,BIKE_SHARING.

  • pre_transit_modes: Optional. Default is WALK. The behavior depends on whether arriveBy is set:
  • arriveBy=true: Currently not used
  • arriveBy=false: Only applies if the one place is a coordinate (not a transit stop).

A list of modes that are allowed to be used from the last transit stop to the to coordinate. Example: WALK,BIKE_SHARING.

  • require_bike_transport: Optional. Default is false.

If set to true, all used transit trips are required to allow bike carriage.

  • require_car_transport: Optional. Default is false.

If set to true, all used transit trips are required to allow car carriage.

  • time: Optional. Defaults to the current time.

Departure time ($arriveBy=false) / arrival date ($arriveBy=true),

  • transfer_time_factor: Optional. Default is 1.0

Factor to multiply minimum required transfer times with. Values smaller than 1.0 are not supported.

  • transit_modes: Optional. Default is TRANSIT which allows all transit modes (no restriction). Allowed modes for the transit part. If empty, no transit connections will be computed. For example, this can be used to allow only METRO,SUBWAY,TRAM.

  • use_routed_transfers: Optional. Default is false.

Whether to use transfers routed on OpenStreetMap data.

 let response = client.one_to_all()
    .additional_transfer_time(additional_transfer_time)
    .arrive_by(arrive_by)
    .elevation_costs(elevation_costs)
    .max_matching_distance(max_matching_distance)
    .max_post_transit_time(max_post_transit_time)
    .max_pre_transit_time(max_pre_transit_time)
    .max_transfers(max_transfers)
    .max_travel_time(max_travel_time)
    .min_transfer_time(min_transfer_time)
    .one(one)
    .pedestrian_profile(pedestrian_profile)
    .post_transit_modes(post_transit_modes)
    .pre_transit_modes(pre_transit_modes)
    .require_bike_transport(require_bike_transport)
    .require_car_transport(require_car_transport)
    .time(time)
    .transfer_time_factor(transfer_time_factor)
    .transit_modes(transit_modes)
    .use_routed_transfers(use_routed_transfers)
    .send()
    .await;
Source

pub fn reverse_geocode(&self) -> ReverseGeocode<'_>

Translate coordinates to the closest address(es)/places/stops

Sends a GET request to /api/v1/reverse-geocode

Arguments:

  • place: latitude, longitude in degrees
  • type_: Optional. Default is all types.

Only return results of the given type. For example, this can be used to allow only ADDRESS and STOP results.

 let response = client.reverse_geocode()
    .place(place)
    .type_(type_)
    .send()
    .await;
Source

pub fn geocode(&self) -> Geocode<'_>

Autocompletion & geocoding that resolves user input addresses including coordinates

Sends a GET request to /api/v1/geocode

Arguments:

  • language: language tags as used in OpenStreetMap (usually ISO 639-1, or ISO 639-2 if there’s no ISO 639-1)

  • place: Optional. Used for biasing results towards the coordinate.

Format: latitude,longitude in degrees

  • place_bias: Optional. Used for biasing results towards the coordinate. Higher number = higher bias.

  • text: the (potentially partially typed) address to resolve

  • type_: Optional. Default is all types.

Only return results of the given types. For example, this can be used to allow only ADDRESS and STOP results.

 let response = client.geocode()
    .language(language)
    .place(place)
    .place_bias(place_bias)
    .text(text)
    .type_(type_)
    .send()
    .await;
Source

pub fn trip(&self) -> Trip<'_>

Get a trip as itinerary

Sends a GET request to /api/v4/trip

Arguments:

  • join_interlined_legs: Optional. Default is true.

Controls if a trip with stay-seated transfers is returned:

  • joinInterlinedLegs=false: as several legs (full information about all trip numbers, headsigns, etc.). Legs that do not require a transfer (stay-seated transfer) are marked with interlineWithPreviousLeg=true.

  • joinInterlinedLegs=true (default behavior): as only one joined leg containing all stops

  • language: language tags as used in OpenStreetMap / GTFS (usually BCP-47 / ISO 639-1, or ISO 639-2 if there’s no ISO 639-1)

  • trip_id: trip identifier (e.g. from an itinerary leg or stop event)

  • with_scheduled_skipped_stops: Optional. Include intermediate stops where passengers can not alight/board according to schedule.

 let response = client.trip()
    .join_interlined_legs(join_interlined_legs)
    .language(language)
    .trip_id(trip_id)
    .with_scheduled_skipped_stops(with_scheduled_skipped_stops)
    .send()
    .await;
Source

pub fn stoptimes(&self) -> Stoptimes<'_>

Get the next N departures or arrivals of a stop sorted by time

Sends a GET request to /api/v4/stoptimes

Arguments:

  • arrive_by: Optional. Default is false.

  • arriveBy=true: the parameters date and time refer to the arrival time

  • arriveBy=false: the parameters date and time refer to the departure time

  • direction: This parameter will be ignored in case pageCursor is set.

Optional. Default is

  • LATER for arriveBy=false
  • EARLIER for arriveBy=true

The response will contain the next n arrivals / departures in case EARLIER is selected and the previous n arrivals / departures if LATER is selected.

  • exact_radius: Optional. Default is false.

If set to true, only stations that are phyiscally in the radius are considered. If set to false, additionally to the stations in the radius, equivalences with the same name and children are considered.

  • fetch_stops: Experimental. Expect unannounced breaking changes (without version bumps).

Optional. Default is false. If set to true, the following stops are returned for departures and the previous stops are returned for arrivals.

  • language: language tags as used in OpenStreetMap / GTFS (usually BCP-47 / ISO 639-1, or ISO 639-2 if there’s no ISO 639-1)

  • mode: Optional. Default is all transit modes.

Only return arrivals/departures of the given modes.

  • n: the number of events

  • page_cursor: Use the cursor to go to the next “page” of stop times. Copy the cursor from the last response and keep the original request as is. This will enable you to search for stop times in the next or previous time-window.

  • radius: Optional. Radius in meters.

Default is that only stop times of the parent of the stop itself and all stops with the same name (+ their child stops) are returned.

If set, all stops at parent stations and their child stops in the specified radius are returned.

  • stop_id: stop id of the stop to retrieve departures/arrivals for

  • time: Optional. Defaults to the current time.

  • with_scheduled_skipped_stops: Optional. Include stoptimes where passengers can not alight/board according to schedule.

 let response = client.stoptimes()
    .arrive_by(arrive_by)
    .direction(direction)
    .exact_radius(exact_radius)
    .fetch_stops(fetch_stops)
    .language(language)
    .mode(mode)
    .n(n)
    .page_cursor(page_cursor)
    .radius(radius)
    .stop_id(stop_id)
    .time(time)
    .with_scheduled_skipped_stops(with_scheduled_skipped_stops)
    .send()
    .await;
Source

pub fn trips(&self) -> Trips<'_>

Given a area frame (box defined by top right and bottom left corner) and a time frame, it returns all trips and their respective shapes that operate in this area + time frame. Trips are filtered by zoom level. On low zoom levels, only long distance trains will be shown while on high zoom levels, also metros, buses and trams will be returned.

Sends a GET request to /api/v4/map/trips

Arguments:

  • end_time: end if the time window
  • max: latitude,longitude pair of the upper left coordinate
  • min: latitude,longitude pair of the lower right coordinate
  • start_time: start of the time window
  • zoom: current zoom level
 let response = client.trips()
    .end_time(end_time)
    .max(max)
    .min(min)
    .start_time(start_time)
    .zoom(zoom)
    .send()
    .await;
Source

pub fn initial(&self) -> Initial<'_>

initial location to view the map at after loading based on where public transport should be visible

Sends a GET request to /api/v1/map/initial

 let response = client.initial()
    .send()
    .await;
Source

pub fn stops(&self) -> Stops<'_>

Get all stops for a map section

Sends a GET request to /api/v1/map/stops

Arguments:

  • max: latitude,longitude pair of the upper left coordinate
  • min: latitude,longitude pair of the lower right coordinate
 let response = client.stops()
    .max(max)
    .min(min)
    .send()
    .await;
Source

pub fn levels(&self) -> Levels<'_>

Get all available levels for a map section

Sends a GET request to /api/v1/map/levels

Arguments:

  • max: latitude,longitude pair of the upper left coordinate
  • min: latitude,longitude pair of the lower right coordinate
 let response = client.levels()
    .max(max)
    .min(min)
    .send()
    .await;
Source

pub fn transfers(&self) -> Transfers<'_>

Prints all transfers of a timetable location (track, bus stop, etc.)

Sends a GET request to /api/debug/transfers

Arguments:

  • id: location id
 let response = client.transfers()
    .id(id)
    .send()
    .await;

Trait Implementations§

Source§

impl ClientHooks for &Client

Source§

async fn pre<E>( &self, request: &mut Request, info: &OperationInfo, ) -> Result<(), Error<E>>

Runs prior to the execution of the request. This may be used to modify the request before it is transmitted.
Source§

async fn post<E>( &self, result: &Result<Response, Error>, info: &OperationInfo, ) -> Result<(), Error<E>>

Runs after completion of the request.
Source§

async fn exec( &self, request: Request, info: &OperationInfo, ) -> Result<Response, Error>

Execute the request. Note that for almost any reasonable implementation this will include code equivalent to this: Read more
Source§

impl ClientInfo<()> for Client

Source§

fn api_version() -> &'static str

Get the version of this API. Read more
Source§

fn baseurl(&self) -> &str

Get the base URL to which requests are made.
Source§

fn client(&self) -> &Client

Get the internal reqwest::Client used to make requests.
Source§

fn inner(&self) -> &()

Get the inner value of type T if one is specified.
Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more