UNPKG

gbfs-system

Version:

A Node.js package that enables real-time data retrieval from GBFS (General Bikeshare Feed Specification) using the auto-discovery URLs provided by MobilityData. It allows developers to easily access and utilize live bikeshare system information, station i

114 lines 5.1 kB
import { StationInfo, StationStatus, SystemInfo, StationUnified } from "./types.js"; /** * Get realtime feed data for a given GBFS (General Bikeshare Feed Specification) compliant system. * The feed must be already provided by the operator. exp : station_information, station_status, system_info, etc. * Visit MobiltyData website or github repo for more informations : https://github.com/MobilityData/gbfs */ export declare class Gbfs { private autoDiscoveryURL; private preferredFeedLanguage; private gbfsData; private gbfsSupportedLanguages; /** * Instanciate the Gbfs class. * @param autoDiscoveryURL - The URL of the GBFS auto-discovery endpoint. * @param preferredFeedLanguage - [Optional] The preferred language code for fetching GBFS data. * @returns A new instance of the Gbfs class. */ private constructor(); /** * Create an instance of Gbfs and retrieve all found feeds URLs * @param {string} autoDiscoveryURL - The URL of the GBFS system. * That URL can be found in the operator API documentation, or by checking the MobilityData maintained system.csv. * The {Systems} module of this library also provide a way to get the autoDiscoveryURL for a registered operator. * @param {string} preferredFeedLanguage - [Optional] - The language code you want to get the feeds data from. * Some operators provide their gbfs system in multiple languages depending on their public's needs. * @ */ static initialize(autoDiscoveryURL: string, preferredFeedLanguage?: string): Promise<Gbfs>; /** * Get the current defined preferred feed language. * @param language - The language code to set as the preferred feed language. */ set setPreferredFeedLanguage(language: string); /** * Getter for the preferred feed language. * * @returns The currently set preferred language code. */ get getPreferredFeedLanguage(): string | undefined; /** * Get all supported feed languages. * @returns An array of all feeds languages found for the current gbfs system. // ['en', 'fr'] */ getSupportedLanguages(): string[] | undefined; /** * Checks if a given language is supported by the GBFS system. * @param language - The language code to check for support. exp: 'en' * @returns True if the language is supported. */ isLanguageSupported(language: string): boolean; /** * Ensures the GBFS data is properly initialized and all required data stored. * @returns {void} */ private ensureInitialized; /** * Finds the URL of a specific feed. * @param {string} feedName - The name of the feed to find the URL for. * @returns The URL of the specified feed or undefined if not found. * If there's no defined preferred feed language, it uses the first found feed object to process. */ private findFeedUrl; /** * Fetches data from a specified URL. * @param {string} url - The URL to fetch data from. * @returns {Promise<unknown>} The data fetched from the specified URL. */ private fetchData; /** * Gets data for a specified feed. * @param {string} feedName - The name of the feed to get data for. * @returns {Promise<unknown>} The data for the specified feed. */ private getFeedData; /** * Fetches station_informations feed realtime data. * @returns An object of station_informations data for all stations. */ stationInfo(): Promise<StationInfo[]>; /** * Fetches station_informations feed realtime data. * @param stationId - The ID of the station to fetch station_informations data for. * @returns The station_informations data of the found station. */ stationInfo(stationId: string): Promise<StationInfo>; /** * Fetches station_status feed realtime data. * @returns An array of station_status data for all stations. */ stationStatus(): Promise<StationStatus[]>; /** * Fetches station_status feed realtime data. * @param stationId - The ID of the station to fetch station_status data for. * @returns The station_status data of the found station. */ stationStatus(stationId: string): Promise<StationStatus>; /** * Fetches system_information feed data. * @returns The system_information feed data as an object. */ systemInfo(): Promise<SystemInfo>; /** * Combines station information and status, prioritizing station information in case of property overlap. * @returns A combination of station_information and station_status for each station. */ stationUnified(): Promise<StationUnified[]>; /** * Combines station information and status, prioritizing station information in case of property overlap. * @param stationId - The ID of a specific station. * @returns A combination of station_information and station_status for the found station. */ stationUnified(stationId?: string): Promise<StationUnified>; } //# sourceMappingURL=Gbfs.d.ts.map