@swittuth/mbta-tracker-sdk
v1.1.3
Published
TypeScript SDK for MBTA Tracker API - provides easy access to MBTA routes, stops, predictions, alerts, and location services
Maintainers
Readme
MBTA Tracker SDK
TypeScript/JavaScript SDK for the MBTA Tracker API. Provides easy access to MBTA routes, stops, predictions, alerts, and location services.
Features
- 🚇 MBTA Data: Routes, stops, predictions, alerts, vehicles, and facilities
- 🗺️ Location Services: Geocoding via Nominatim API
- 🔒 Type Safe: Full TypeScript support with auto-generated types
- 🌐 Universal: Works in Node.js, browsers, and React Native
- 📦 Zero Dependencies: Uses native Fetch API
Installation
npm install mbta-tracker-sdkQuick Start
import { MbtaApi, NominatimApi, Configuration } from 'mbta-tracker-sdk';
// Configure the API client
const config = new Configuration({
basePath: 'https://your-api-domain.com' // Replace with your API URL
});
const mbtaApi = new MbtaApi(config);
const nominatimApi = new NominatimApi(config);
// Get all MBTA routes
const routes = await mbtaApi.getRoutes();
// Get stops for a specific route
const stops = await mbtaApi.getStops({ route: 'Red' });
// Get predictions for a stop
const predictions = await mbtaApi.getPredictions({
route: 'Red',
stop: 'place-sstat',
directionId: 0,
trip: 'trip-id',
include: 'trip',
sort: 'arrival_time'
});
// Search for location data
const location = await nominatimApi.getLocationData({
street: '1 State St',
city: 'Boston',
state: 'MA',
country: 'US',
zipcode: '02109'
});API Reference
MBTA API Methods
getRoutes()- Get all MBTA routesgetStops(params)- Get stops for a routegetPredictions(params)- Get predictions for stopsgetAlerts(params?)- Get service alertsgetVehicleInformation(id, params)- Get vehicle detailsgetStopFacilities(params)- Get stop facility informationgetRouteServiceInformation(params)- Get route service details
Nominatim API Methods
getLocationData(params)- Geocode addresses
Development
# Install dependencies
npm install
# Build the package
npm run build
# Clean build artifacts
npm run clean
# Prepare for publishing
npm run prepublishOnlyPublishing
npm run prepublishOnly
npm publishEnvironment Support
- Node.js: ≥16.0.0
- Browsers: Modern browsers with Fetch API support
- TypeScript: ≥4.0
- Module Systems: CommonJS, ES6 modules
License
MIT License - see LICENSE file for details.
