This Node.js package is a simple wrapper for the Atac API, the public API for the realtime tracking of the Rome Public Transport service.
The API is documented here.
You can install the package with npm:
npm install LBreda/NodeAtacAPI
You can use it by requiring it:
const AtacApi = require('NodeAtacAPI');
const atac = new AtacApi("API_KEY");
In order to use the Atac API, you need an API Key. You can get a key on the Atac Website.
Tip: you can omit the parameter in AtacApi constructor and use the environment variable ATAC_API_KEY
Each available function is a wrapper for the official API.
Each method will return a Promise.
atac.getBusStop
is a wrapper for paline.Previsioni.
It will return all the data about a bus stop, including the list of the incoming buses.
It needs the bus stop number.
The response object is a dictionary:
string nome
: the bus stop namebool abilitata
: enabled / disabledint id_news
: news ID for the disabled status, or -1string collocazione
: Description of the locationVehiclesList arrivi
: Array of incoming vehicles, ordered by time of arrivalStopList primi_per_palina
: Array of Bus stop poles
Each StopList
array element is a dictionary:
string id_palina
: Bus stop pole IDstring nome_palina
: Bus stop pole nameVehiclesList arrivi
: Array of incoming vehicles, ordered by time of arrival
Each VehiclesList
array element is a dictionary:
string linea
: Line numberstring id_palina
: Bus stop pole IDstring nome_palina
: Bus stop pole namebool non_monitorata
: if true, realtime data is not available (and the following keys are not set)bool nessun_autobus
: if true, there are no buses for the line (and the following keys are not set)bool disabilitata
: if true, the realtime data is not available at the moment (and the keys following the next are not set)int news_id
: ID of the notice which explains why the data is not available, or -1string id_percorso
: Route IDstring destinazione
: Final destination name (may be undefined)string carteggi
: Route papersstring carteggi dec
: Decoded route papersstring capolinea
: Final destination (the difference withdestinazione
is a mystery only Atac can solve)string partenza
: Departure time from the first stop (defined if the bus is reaching the first stop)string annuncio
: Announcement string for the InfoTP informative systembool meb
: True if the bus has a on-board ticket vending machinebool pedana
: True if the bus has a on-board wheelchair rampbool moby
: True if the bus has a on-board monitorbool aria
: True if the bus has a (probably out of order) air conditionerbool a_capolinea
: True if the bus is reaching the first stopbool in_arrivo
: True if the bus is coming at the current stopdate prossima_partenza
: Next departure from the first stopint tempo_attesa
: Waiting time for the bus on the current stop (in minutes)int tempo_attesa_secondi
: Waiting time for the bus on the current stop (in seconds)int distanza_fermate
: Distance of the bus from the current stop (in stops)int id_veicolo
: Vehicle ID numberint banda
: Undocumented
atac.getRoutes
is a wrapper for paline.Percorsi.
It will return a list of routes for a given line. A line may have one or more routes (usually two, one for each way).
It needs the line number.
The response object is a dictionary:
bool monitorata
: True if the line has real-time databool abilitata
: True if the line is currently enabledint id_news
: ID of the notice explaining why the line is disabled, or -1RoutesList percorsi
: List of the line routes
Each RouteList
element is a dictionary:
string id_percorso
: Route IDstring descrizione
: Route descriptionstring capolinea
: Route last stop
atac.getRoute
is a wrapper for paline.Percorso.
It will return all the data for a given route.
It needs the route ID.
The response object is a dictionary.
I'm working on a English translation of the output. You can find the Italian version on the linked API function page.
atac.getNextDeparture
is a wrapper for paline.ProssimaPartenza.
It will return the next departure from the first stop for a given route.
It needs the route ID.
The response object is a string
in
the format Y-m-d H:i:s
.
atac.getNewsCategories
is a wrapper for the undocumented news.Categorie endpoint.
It will return an list of the available news categories, and the number of the news contained in each category.
It needs no parameters.
The response object is an array of dictionaries in this format:
int id_categoria
: Category IDstring nome
: Category nameint conteggio
: Number of news in the category
atac.getNewsFirstPage
is a wrapper for the undocumented news.PrimaPagina endpoint.
It will return a list of the main news.
It needs no parameters.
The response object is an array of dictionaries in this format:
int id_news
: News item idint id_categoria
: Category IDstring titolo
: News titlestring contenuto
: News contentdate data_pubblicazione
: Publishing date
atac.getNewsCategoriesForSingleNews
is a wrapper for the undocumented news.CategorieNews endpoint.
It will return an list of the categories in which a single news is published.
It needs the News Item id.
The response object is an array of dictionaries in this format:
int id_categoria
: Category IDstring nome_categoria
: Category name
atac.getNewsByCategory
is a wrapper for the undocumented news.PerCategoria endpoint.
It will return a list of news for a single category.
It needs the Category id.
The response object is an array of dictionaries in this format:
int id_news
: News item idint id_categoria
: Category IDstring titolo
: News titlestring contenuto
: News contentdate data_pubblicazione
: Publishing date
atac.getNewsSingle
is a wrapper for the undocumented news.Singola endpoint.
It will return a single detailed news.
It needs the Category id.
The response object is a dictionary in this format:
int id_news
: News item idint id_categoria
: Category IDstring titolo
: News titlestring contenuto
: News contentdate data_pubblicazione
: Publishing dateint prec
: Previous News IDint succ
: Next News ID
atac.getNewsByCategory
is a wrapper for the undocumented news.Tutte endpoint.
It will return a list of all the news.
It needs no parameters.
The response object is an array of dictionaries in this format:
int id_news
: News item idint id_categoria
: Category IDstring titolo
: News titlestring contenuto
: News contentdate data_pubblicazione
: Publishing date
- Support for the
paline.PalinaLinee
,paline.Veicolo
API functions - Documentation for
paline.SmartSearch
- Better support for the
paline.Percorso
API function - Testing framework
- Better documentation for the return values
- (much) better error handling (in part solved with Promise rejection)