API Reference
January 31, 2026 ยท View on GitHub
railil exports a fully typed API for use in Node.js applications.
searchTrains(from, to, date?, time?)
Fetches the train schedule between two stations.
Signature
function searchTrains(
fromStation: string,
toStation: string,
date?: string,
time?: string
): Promise<SearchResult>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
fromStation | string | Yes | The Station ID (e.g., "3700"). Use the stations export to find IDs. |
toStation | string | Yes | The Station ID. |
date | string | No | Date in YYYY-MM-DD format. Defaults to today. |
time | string | No | Time in HH:MM format. Defaults to current time. |
Returns
Returns a Promise that resolves to a SearchResult object containing the matched stations and travel options. Only trains departing at or after the requested time (or "now") are returned.
SearchResult
The result object returned by searchTrains.
interface SearchResult {
travels: Travel[]; // Array of journey options
from: Station; // Resolved origin station
to: Station; // Resolved destination station
}
stations
An array of all available stations, including their IDs and names in multiple languages.
Structure
interface Station {
id: string;
name: {
he: string; // Hebrew
en: string; // English
ru: string; // Russian
ar: string; // Arabic
};
}
Example Usage
import { stations } from 'railil';
const myStation = stations.find(s => s.name.en === 'Tel Aviv - Savidor Center');
console.log(myStation.id); // "3700"
Types
Travel
Represents a specific journey option found by the search.
interface Travel {
departureTime: string; // ISO 8601
arrivalTime: string; // ISO 8601
freeSeats?: number;
travelMessages: string[];
trains: Train[]; // Array of trains involved (handling transfers)
}
Train
Represents a specific train leg within a journey.
interface Train {
trainNumber: number;
orignStation: number;
destinationStation: number;
originPlatform: number;
destPlatform: number;
arrivalTime: string;
departureTime: string;
stopStations: StationInfo[];
// ... other properties
}