Home > sncf.js > SearchManager > searchTrain
SearchManager.searchTrain() method
Search a train by headsign ID
Signature:
typescript
searchTrain(headsign: string, date?: Date): Promise<Vehicle>;
Parameters
Parameter | Type | Description |
---|---|---|
headsign | string | The headsign of the line |
date | Date | (Optional) Not required, but highly recommended for effective results |
Promise<Vehicle>
Example
This example shows how to search a line by name
javascript
const vehicle = await sncf.searchManager.searchTrain('123456', date)
console.log(vehicle)