Skip to content

Latest commit

History

38 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

itabus-api

versionnpm

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. **

Installation

npm install itabus-api

Features

  • Search tickets
  • Station retrieval

How To Use - Search tickets

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}`));

How To Use - Station retrieval

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())}

About

Access to Itabus's unofficial API

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages