Access to Itabus's unofficial API with object-oriented promises.
Itabus is an Italian road transport company operating exclusively within Italy.
The name of the stations is accepted only in Italian! Example: * 'MILANO' is valid station * 'MILAN' is not valid station The project is developed for information purposes. **Do not use this code for evil purposes and respect the service offered. **
npm install itabus-api
- Search tickets
- Station retrieval
constItabusAPI=require("itabus-api")constItabus=newItabusAPI()// DATE FORMAT --> "YYYY-MM-DD"Itabus.search_tickets("Milano","Bologna","2023-10-10").then(request=>{if(request.success===false){console.log(request.error)}else{constResults=request.data// Get all travel ticket solutionsconsole.log(Results.getTickets())// Get the ticket with the shortest tripconsole.log(Results.getShortestTrip())// Get the ticket with the cheapest tripconsole.log(Results.getCheapestTrip())// For each ticket, you can extract individual informationconstexampleTicket=Results.getTickets()[0]console.log(exampleTicket.getTravelDuration())console.log(exampleTicket.getId())console.log(exampleTicket.getOrigin())console.log(exampleTicket.getDestination())console.log(exampleTicket.getDepartureTimestamp())console.log(exampleTicket.getArrivalTimestamp())console.log(exampleTicket.getRates())console.log(exampleTicket.getBasicPrice())}}).catch(err=>console.log(`Error searching: ${err.message}`));constItabusAPI=require("itabus-api")constItabus=newItabusAPI()constresult=Itabus.get_station("Milano")if(result.success===false){console.log(result.error)}else{console.log(result.data)//Id of Stationconsole.log(result.data.getCode())//City of Stationconsole.log(result.data.getCity())//Address of Stationconsole.log(result.data.getAddress())//List of available destinations from this stationconsole.log(result.data.getDestinations())}