1.1.1 • Published 4 years ago

rts-api v1.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

rts-api

An unofficial JavaScript bindings for the RTS bus network API.

Note: since there is no public documentation for the API, the usage of some of the data points provided by the API is unknown, but the data is provided anyway, unmodified from the original data, only organized. If there is a mistake, let me know.

Most of the data provided by the API will be unnecessary for the average use case of this project, so the data fields are sorted by utility in the docs below.

Installation

npm install rts-api

Usage

Each of the functions below require an agency ID, which represents an area where RTS buses run. For example, the agency ID for the Gainesville area is 116. Use getAgencies() and check the response for the agency that covers your area.

import { getCurrentBuses } from "rts-api";

const agencyID = "116";

getCurrentBuses(agencyID).then((buses) => console.log(buses));

Functions

The following functions make a GET requesat to the RTS API:

Each function below returns a promise that resolves to the data.

getCurrentBuses(agencyID: string, routeID?: string)

Returns an array of bus objects that are currently in service. If the routeID parameter is provided, then only the buses on that route will be returned.

getAgency(agencyID: string)

Returns an agency

getAgencies()

Returns an array of agency

getStops(agencyID: string, routeID?: string)

Returns an array of bus stop for the specified agency. If the routeID parameter is provided, then only the stops that make up that route will be returned.

getStopById(agencyID: string, stopID: string)

Returns the bus stop that matches the provided stopID.

getRoutes(agencyID: string)

Returns an array of route that are in the specified agency.

getRouteById(agencyID: string, routeID: string)

Returns a route that matches the provided route ID.

getSegments(agencyID: string, routeID?: string)

Returns an array of segments. If a route ID is provided, then only the segments on that route are returned

Segments are used to draw the routes on a map.

getAnnouncements(agencyID: string)

Returns an array of announcement for the specified agency.

Data Types

Vehicle

Field NameTypeDescription
idstringUnique ID for this vehicle
positionnumber[]The vehicle's current location ([latitude, longitude])
headingnumberThe vehicle's bearing where 0 is North, 90 is East, etc. Range: 0-360
speednumberThe vehicle's current velocity. Unsure if it's in mph or kph
routeIDstringThe route that this vehicle is currently operating
currentStopIDstringThe ID of the stop that the vehicle is on
nextStopIDstringThe ID of the next stop that this vehicle will stop on
agencyIDstringThe agency that this vehicle belongs to
serviceStatusstringIs "in_service" if the vehicle is currently on its route
tripIDstringThe trip that this vehicle belongs to (unsure)
tripStartDateThe start time of this vehicle's service (unsure)
tripEndDateThe time that this vehicle will stop servicing its route (unsure)
gtfsTripIdstringThe General Transit Feed Specification ID for this vehicle
directionbooleanUnsure
stopPatternIDstringUnsure
callNamestringUnsure
arrivalStatusOne of "Early" | "Late" | "N/A" | "On-Time"The status of the vehicle in relation to its schedule
segmentIDstringThe current segment that this vehicle is on
offRoutebooleantrue if the vehicle is not currently on its route (due to detours)
timestampnumberThe time that this vehicle's location was queried in seconds after Unix epoch
loadnumberThe current passenger load, where 0 is empty and 1 is at full capacity
apcStatusstringup if the vehicle's Automatic Passenger Counting is operational (lets you know if load is reliable)

Agency

Field NameTypeDescription
idstringThe unique ID for this agency
longNamestringThe name for this agency
shortNamestringA condensed version of longName
positionnumber[]The location for this agency. Note: not always the center of its bounding box. [latitude, longitude]
locationstringThe location for this agency. Typically follows [city], [state abbr.] format
boundsnumber[]The coordinates of the top left and bottom right corner of a bounding box for this agency's area. [latTopLeft, longTopLeft, latBottomRight, longBottomRight]
colorstringThe hex code for this agency's color
affiliatedAgenciesstring[]The affiliated agency IDs
arrivalPredictionsbooleantrue if this agency provides predictions for bus arrivals
hasNotificationsbooleantrue if this agency allows for notifications (mobile/desktop app)
hasSchedulesbooleantrue if the vehicles in this agency are meant to follow a schedule
hasTripPlanningbooleantrue if this agency supports planning bus routes between two locations
textColorstringThe hex code for text that will be visible on this agency's color
timezonestringThe timezone of this agency
timezoneOffsetnumberThe offset in seconds from GMT
urlstringThe URL for this agency's transit page

Stop

Field NameTypeDescription
idstringThe unique ID for this bus stop
namestringThe name for this bus stop
descriptionstringA description of this bus stop, typically the stop's address
positionnumber[]The coordinates of this bus stop, [latitude, longitude]
locationTypestringThe type for this stop, typically "stop"
parentStationIDstringThe ID of this stop's parent station (largely unused)
codestringUnsure
urlstringThe URL for this bus stop (largely unused)

Route

Field NameTypeDescription
idstringThe unique ID for this route
isActivebooleantrue if this route is currently servicing passengers
longNamestringThe name for this route
shortNamestringThe condensed route name, typically just the route number
stopsstring[]The ID of stops that are in this route
segmentsstring[]The ID of the segments that make up this route
boundsnumber[]The coordinates of the box that contain this route [latTopLeft, longTopLeft, latBottomRight, longBottomRight]
colorstringThe hex code of the color of this route
descriptionstringA description for this route (largely unused)
agencyIDstringThe ID of the agency that this route belongs to
textColorstringThe hex code for the text color that would be legible on this route's color
typestringThe type of vehicle that operates this route, typically "bus"
urlstringThe web page for the route's schedule

Segment

Field NameTypeDescription
pointsstringAn encoded polyline for this segment
levelsstringSpecifies at which levels this segment is visible. Currently obsolete.
idstringThe unique ID for this segment

Announcement

Field NameTypeDescription
idstringThe unique ID for this announcement
titlestringThe title for this announcement| |urgent|boolean|trueif the announcement is urgent | |content|string| HTML content accompanying this announcement. | |date|string| The date of the announcement. Typically inYYYY/MM/DDformat | |startAt|Date| The date on which the announcement's changes become effective | |agencyID|string| The ID of the agency that this announcement applies to | |hasContent|boolean|trueif thecontent`field has a value
1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago