Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mpolden/atb
Sane API for bus data in Trondheim, Norway
https://github.com/mpolden/atb
api atb bus-data bus-schedule go
Last synced: 15 days ago
JSON representation
Sane API for bus data in Trondheim, Norway
- Host: GitHub
- URL: https://github.com/mpolden/atb
- Owner: mpolden
- License: bsd-3-clause
- Created: 2015-02-26T21:13:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-14T19:16:19.000Z (over 1 year ago)
- Last Synced: 2024-10-04T12:57:11.146Z (about 1 month ago)
- Topics: api, atb, bus-data, bus-schedule, go
- Language: Go
- Homepage: https://mpolden.no/atb/
- Size: 102 KB
- Stars: 26
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# atb
![Build Status](https://github.com/mpolden/atb/workflows/ci/badge.svg)
A minimal API for bus data in Trondheim, Norway. This API proxies requests to
Entur APIs and converts the responses into a sane JSON format.Responses from the proxied APIs are cached. By default bus stops will be cached
for 1 week and departures for 1 minute.As of mid-August 2021 the SOAP-based AtB API no longer returns any departure
data. According to [this blog post on open
data](https://beta.atb.no/blogg/apne-data-og-atb) it appears the preferred API
is now [Entur](https://developer.entur.org/). The `/api/v1/` paths have
therefore been removed.Version 2 has been implemented and proxies requests to Entur instead. These are
the changes in version 2:* There is no version 2 variant of `/api/v1/busstops`. Use
https://stoppested.entur.org/ to find valid stop IDs.
* Entur uses different stop IDs so old ones, such as `16011376`, cannot be used
in version 2. A stop includes departures in both directions by default so
there is no longer a unique stop for each direction.
* The `registeredDepartureTime` field may be omitted.
* The `isGoingTowardsCentrum` field has moved to the departure object.This API aims to be compatible with
[BusBuddy](https://github.com/norrs/busbuddy) (which appears to be defunct).## Usage
```
$ atb -h
Usage of atb:
-d string
Departure cache duration (default "1m")
-l string
Listen address (default ":8080")
-s string
Bus stop cache duration (default "168h")
-x Allow requests from other domains
```## API
### `/`
Lists all available API routes.
Example:
```
$ curl https://mpolden.no/atb/ | jq .
{
"urls": [
"https://mpolden.no/atb/v2/departures"
]
}
```### `/api/v2/departures`
List departures from the given bus stop, identified by a stop ID. Use
https://stoppested.entur.org to find stop IDs, for example `41613` (the number
part of `NSR:StopPlace:41613`) for Prinsens gate.Departures traveling in any direction are included by default. Add the parameter
`direction=inbound` or `direction=outbound` to filter departures towards, or
away from, the city centre.Note that the claimed direction is questionable in some cases so inspect the
responses to decide whether `inbound` or `outbound` makes sense for your use
case.```
$ curl 'https://mpolden.no/atb/v2/departures/41613?direction=inbound' | jq .{
"url": "https://mpolden.no/atb/v2/departures/41613",
"departures": [
{
"line": "71",
"scheduledDepartureTime": "2021-08-11T23:49:38.000",
"destination": "Dora",
"isRealtimeData": true,
"isGoingTowardsCentrum": true
},
...
]
}
```