npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rts-api

v1.1.1

Published

An unofficial API for the RTS bus network

Downloads

4

Readme

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 Name | Type | Description | | --------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | | id | string | Unique ID for this vehicle | | position | number[] | The vehicle's current location ([latitude, longitude]) | | heading | number | The vehicle's bearing where 0 is North, 90 is East, etc. Range: 0-360 | | speed | number | The vehicle's current velocity. Unsure if it's in mph or kph | | routeID | string | The route that this vehicle is currently operating | | currentStopID | string | The ID of the stop that the vehicle is on | | nextStopID | string | The ID of the next stop that this vehicle will stop on | | agencyID | string | The agency that this vehicle belongs to | | serviceStatus | string | Is "in_service" if the vehicle is currently on its route | | tripID | string | The trip that this vehicle belongs to (unsure) | | tripStart | Date | The start time of this vehicle's service (unsure) | | tripEnd | Date | The time that this vehicle will stop servicing its route (unsure) | | gtfsTripId | string | The General Transit Feed Specification ID for this vehicle | | direction | boolean | Unsure | | stopPatternID | string | Unsure | | callName | string | Unsure | | arrivalStatus | One of "Early" | "Late" | "N/A" | "On-Time" | The status of the vehicle in relation to its schedule | | segmentID | string | The current segment that this vehicle is on | | offRoute | boolean | true if the vehicle is not currently on its route (due to detours) | | timestamp | number | The time that this vehicle's location was queried in seconds after Unix epoch | | load | number | The current passenger load, where 0 is empty and 1 is at full capacity | | apcStatus | string | up if the vehicle's Automatic Passenger Counting is operational (lets you know if load is reliable) |

Agency

| Field Name | Type | Description | | -------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | id | string | The unique ID for this agency | | longName | string | The name for this agency | | shortName | string | A condensed version of longName | | position | number[] | The location for this agency. Note: not always the center of its bounding box. [latitude, longitude] | | location | string | The location for this agency. Typically follows [city], [state abbr.] format | | bounds | number[] | The coordinates of the top left and bottom right corner of a bounding box for this agency's area. [latTopLeft, longTopLeft, latBottomRight, longBottomRight] | | color | string | The hex code for this agency's color | | affiliatedAgencies | string[] | The affiliated agency IDs | | arrivalPredictions | boolean | true if this agency provides predictions for bus arrivals | | hasNotifications | boolean | true if this agency allows for notifications (mobile/desktop app) | | hasSchedules | boolean | true if the vehicles in this agency are meant to follow a schedule | | hasTripPlanning | boolean | true if this agency supports planning bus routes between two locations | | textColor | string | The hex code for text that will be visible on this agency's color | | timezone | string | The timezone of this agency | | timezoneOffset | number | The offset in seconds from GMT | | url | string | The URL for this agency's transit page |

Stop

| Field Name | Type | Description | | ----------------- | ---------- | ------------------------------------------------------------ | | id | string | The unique ID for this bus stop | | name | string | The name for this bus stop | | description | string | A description of this bus stop, typically the stop's address | | position | number[] | The coordinates of this bus stop, [latitude, longitude] | | locationType | string | The type for this stop, typically "stop" | | parentStationID | string | The ID of this stop's parent station (largely unused) | | code | string | Unsure | | url | string | The URL for this bus stop (largely unused) |

Route

| Field Name | Type | Description | | ------------- | ---------- | --------------------------------------------------------------------------------------------------------------- | | id | string | The unique ID for this route | | isActive | boolean | true if this route is currently servicing passengers | | longName | string | The name for this route | | shortName | string | The condensed route name, typically just the route number | | stops | string[] | The ID of stops that are in this route | | segments | string[] | The ID of the segments that make up this route | | bounds | number[] | The coordinates of the box that contain this route [latTopLeft, longTopLeft, latBottomRight, longBottomRight] | | color | string | The hex code of the color of this route | | description | string | A description for this route (largely unused) | | agencyID | string | The ID of the agency that this route belongs to | | textColor | string | The hex code for the text color that would be legible on this route's color | | type | string | The type of vehicle that operates this route, typically "bus" | | url | string | The web page for the route's schedule |

Segment

| Field Name | Type | Description | | ---------- | -------- | -------------------------------------------------------------------------------------------------------------------- | | points | string | An encoded polyline for this segment | | levels | string | Specifies at which levels this segment is visible. Currently obsolete. | | id | string | The unique ID for this segment |

Announcement

| Field Name | Type | Description | | ---------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | id | string | The unique ID for this announcement | | title | string | The 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 |