spider_sdk library
The Dart SDK for the Spider transit API — trip planning, stop search, and live realtime data behind one typed client.
Classes
- AlertActivePeriod
- A time window an alert is active for. Epoch milliseconds.
- AlertInformedEntity
- What an alert applies to.
- AutoRetryOptions
- Per-surface retry configuration. Retries are opt-in: leave null to disable (the default).
- CoordinateLocation
- DefaultSpiderHttpClient
-
Default SpiderHttpClient backed by
package:http(works on mobile, desktop, and web). - Departure
- A single departure from a stop.
-
Failure<
T> - A failed result carrying error.
- FeatureOptions
- Feature toggles for one surface (routing / stops / realtime).
- FeedFreshness
-
How fresh a realtime feed is. Timestamps are epoch milliseconds;
staleSecondsis age in seconds. - GeoBoundingBox
-
A WGS84 bounding box: south-west corner (
min*) to north-east corner (max*). - GeoPoint
-
A WGS84 point.
lngmirrors the transit-industrylon, but the input side reads as lat/lng. - Itinerary
- A full origin-to-destination itinerary.
- LatLon
- A decoded geographic point.
- Leg
- One leg of an itinerary (a single vehicle ride or walk).
- LiveVehicle
- A vehicle's live position. GTFS-RT producers populate wildly different subsets, so every field is optional.
- LiveVehicleUpdate
-
A single trip's live vehicle plus feed freshness (
vehiclenull = none currently reporting). - Location
- An origin, destination, or via point: either a coordinate or a stop id.
- PassThroughVia
- PlanOptions
- Options for a trip-plan search. departAt/arriveBy are mutually exclusive (arriveBy wins if both set; neither = depart now). allowedTransitModes empty = all modes. searchWindowMinutes defaults to 60.
- Route
- The result of a trip-plan search: a page of itineraries plus paging info and any routing errors.
- RouteEdge
- A paged itinerary with its cursor.
- RoutePageInfo
- Relay-style paging info for a Route.
- RoutingError
- A non-fatal routing problem (e.g. no transit connection in the window).
- ServiceAlert
- A service alert. Text is already resolved to one language; cause/effect/severity are raw GTFS-RT strings.
- ServiceAlerts
- All active alerts for the environment plus feed freshness.
- SpiderClient
- The Spider API client. Construct once with your environment base URL and API key, then reach a surface: routing, stops, realtime. Each surface gets its own transport (own retry config) sharing the same base URL, key, HTTP client and timeout.
- SpiderClientOptions
- Client-wide options: a shared HTTP client + timeout, and per-surface feature toggles.
- SpiderHttpClient
- The HTTP boundary the SDK depends on. Production uses DefaultSpiderHttpClient; tests inject their own.
- SpiderHttpRequest
- SpiderHttpResponse
- SpiderRealtime
-
The realtime surface: live vehicle positions, schedule deviations, and service alerts. Poll-based —
see the
poll*methods (extension below) for change-detecting streams. -
SpiderResult<
T> - The result of every SDK call. Ordinary failures never throw — they surface as Failure. The one exception is a major contract mismatch, which throws SpiderContractMismatchError out of the call.
- SpiderRouting
- The routing surface: trip planning (plan + paging + streaming), stop departures, and single trip detail.
- SpiderStops
- The stops surface: text + administrative-area + geographic stop search, and single-stop lookup.
- Stop
- A stop returned by search.
- StopFilter
- Search criteria. name is a free-text query; the admin fields narrow it by administrative area; the geo fields (near/radiusMeters/bbox/sortByDistance) constrain and order it spatially.
- StopLocation
- StopTimeUpdate
- One stop's realtime deviation within a trip.
-
Success<
T> - A successful result carrying value.
- TripDelay
- A trip's live schedule deviation. Delay values are in seconds.
- TripDelays
- Live deviations for a set of trips, plus the trip ids with no live delay.
- TripDetails
- A single trip's route, stops, and geometry.
- TripStop
- One stop on a trip's timetable.
- VehiclePositions
- Live positions for a set of trips, plus the trip ids that had no live vehicle.
- ViaLocation
- A via constraint on a trip plan: pass through a set of stops, or visit a place with a minimum dwell.
- VisitVia
Enums
- BikesAllowed
- Whether bikes are allowed on a trip. Closed: unknown wire values map to null.
- InputField
- Which input a routing error refers to. Open: unrecognized values map to InputField.unknown.
- OccupancyStatus
-
GTFS-RT vehicle occupancy. Open: unrecognized values map to OccupancyStatus.unknown;
NO_DATA_AVAILABLEmaps to null. - RealtimeState
- The realtime state of a departure/leg. Open: unrecognized values map to RealtimeState.unknown.
- RoutingErrorCode
- Why routing failed. Open: unrecognized values map to RoutingErrorCode.unknown.
- SpiderErrorCode
-
The stable failure taxonomy shared with the other Spider SDKs. Branch on
code. - TransitMode
- A transit or street mode. Open: unrecognized values map to TransitMode.unknown.
- WheelchairBoarding
- Whether a stop is wheelchair accessible. Closed: unknown wire values map to null.
Extensions
- SpiderRealtimePolling on SpiderRealtime
- Change-detecting realtime polling. Each stream calls the underlying surface on an interval and yields a value only when the result changes from the previous one. Cancel the subscription to stop polling.
Exceptions / Errors
- SpiderContractMismatchError
- Thrown (never returned) when the gateway declares a different MAJOR contract version than this SDK speaks.
- SpiderError
-
A recoverable failure carried in
Failure.