UNPKG

@drfrost/bods-js

Version:

JavaScript client for the UK's Bus Open Data Service (BODS) API

79 lines 2.21 kB
import type { ApiConfig } from './types/index.js'; import { TimetablesClient, FaresClient, AVLClient, DisruptionsClient } from './client/index.js'; /** * Main BODS (Bus Open Data Service) API Client * * This client provides access to all BODS APIs: * - Timetables: Bus schedules and routes * - Fares: Bus fare information * - AVL: Real-time vehicle locations * - Disruptions: Service disruption information * * @example * ```typescript * import { BODSClient } from 'bods-js'; * * const client = new BODSClient({ * apiKey: 'your-api-key-here' * }); * * // Search for timetables * const timetables = await client.timetables.search({ * noc: ['SCMN'], * status: 'published' * }); * * // Get real-time vehicle locations * const vehicles = await client.avl.getSIRIVM({ * operatorRef: ['SCMN'] * }); * * // Get current service disruptions * const disruptions = await client.disruptions.getCurrent(); * ``` */ export declare class BODSClient { /** HTTP client for making API requests */ private readonly httpClient; /** Timetables API client */ readonly timetables: TimetablesClient; /** Fares API client */ readonly fares: FaresClient; /** Automatic Vehicle Location API client */ readonly avl: AVLClient; /** Disruptions API client */ readonly disruptions: DisruptionsClient; /** * Create a new BODS API client * * @param config - API configuration including API key * * @example * ```typescript * const client = new BODSClient({ * apiKey: 'your-api-key-here', * timeout: 30000 // optional: request timeout in milliseconds * }); * ``` */ constructor(config: ApiConfig); /** * Get API client configuration info */ getConfig(): Omit<ApiConfig, 'apiKey'>; /** * Test API connectivity * * @returns Promise resolving to true if API is accessible * * @example * ```typescript * const isConnected = await client.testConnection(); * if (isConnected) { * console.log('API is accessible'); * } * ``` */ testConnection(): Promise<boolean>; } //# sourceMappingURL=bods-client.d.ts.map