metro-route-sdk
v0.1.1
Published
Official JavaScript/TypeScript SDK for the Metro Route Premium API.
Maintainers
Readme
Metro Route SDK (JavaScript)
The official, strongly-typed JavaScript client library for the Metro Route Premium API. This SDK provides seamless, programmatic access to real-time data, station information, and journey planning for both the Delhi Metro (DMRC) and the Noida Metro (NMRC).
Built on top of the native fetch API, this SDK has zero external dependencies and works flawlessly across:
- Node.js (18+)
- Modern Web Browsers
- React Native / Expo
- Cloudflare Workers & Edge environments
🚀 Installation
npm install metro-route-sdk💻 Quick Start
import { MetroRouteClient } from 'metro-route-sdk';
const client = new MetroRouteClient();
async function main() {
// Plan a Delhi Metro journey
const dmrcJourney = await client.planJourney("RG", "DW21");
console.log(`DMRC Fare: ₹${dmrcJourney.fare}`);
// Plan a Noida Metro journey
const nmrcJourney = await client.planNmrcJourney("1", "16");
console.log(`NMRC Fare: ₹${nmrcJourney.fare}`);
}
main();📚 Full API Reference
The MetroRouteClient fully utilizes Promises and maps directly to the API routes.
🚆 Delhi Metro (DMRC) Endpoints
1. getLines()
Fetches a list of all currently operating Delhi Metro lines, including their hex colors and terminal stations.
- Returns:
Promise<Array<Object>>
2. getStationsByLine(lineCode)
Retrieves every station on a specific line sequentially.
- Parameters:
lineCode(string): The identifier for the line (e.g.,"YELLOW","BLUE").
- Returns:
Promise<Array<Object>>
3. searchStations(name)
Fuzzy-searches for stations matching the given name query.
- Parameters:
name(string): Search term (e.g.,"Rajiv").
- Returns:
Promise<Array<Object>>
4. getStationDetails(stationCode)
Retrieves comprehensive details about a specific station, including gates, platforms, and interchange information.
- Parameters:
stationCode(string): The station's unique code (e.g.,"RG"for Rajiv Chowk).
- Returns:
Promise<Object>
5. planJourney(fromStationCode, toStationCode)
Calculates the optimal route between two DMRC stations, providing the exact fare, travel time, and a step-by-step path including interchanges.
- Parameters:
fromStationCode(string): Starting station code.toStationCode(string): Destination station code.
- Returns:
Promise<Object>
6. getNotifications()
Fetches the latest official alerts, delays, and notifications directly from DMRC.
- Returns:
Promise<Array<Object>>
🚊 Noida Metro (NMRC) Endpoints
7. getNmrcStations()
Fetches all operational stations on the Noida Metro Aqua Line.
- Returns:
Promise<Array<Object>>
8. planNmrcJourney(fromStationId, toStationId)
Calculates the fare and route for a journey entirely within the Aqua Line network.
- Parameters:
fromStationId(string): Numeric string ID of the starting station (e.g.,"1"for Sector 51).toStationId(string): Numeric string ID of the destination station.
- Returns:
Promise<Object>
⚙️ Configuration
By default, the client points to the live production server. You can override the baseUrl during initialization if you are hosting the API yourself:
const localClient = new MetroRouteClient("http://localhost:8000/api/v2");