Hey,
I built a transit api that covers 200+ cities across Europe, serving realtime departure times for all common transportation types (bus, subway, metro etc.). So far it works as a HA REST sensor and I am considering to build a proper HACS integration, if it is well received.
It started first as an app for my Pebble smartwatch, but then I started to wonder if others might find this service useful for other devices and solutions, until a colleague asked my if he could use the service for his HA setup at home.
Being a frontend dev in my professional life, I was wanting to make the call as simple as possible, with an easy to read response format. You give lon and lat GPS values, and get back the departures from your surrounding. There are plently of parameters you can give on top, e.g. for specifying the radius, transportation types, etc.
Quick setup
**1. Get a free API key by sending me a DM (750 requests/day. Should be enough for 1-min polling)
2. Add to configuration.yaml:
sensor:
- platform: rest
name: Transit Departures
unique_id: abfahrt_departures
resource: "https://api.abfahrt.now/departures?lat=YOUR_LAT&lon=YOUR_LON&radius=500&key=YOUR_API_KEY"
scan_interval: 60
json_attributes:
- departures
- stations
- city
- region
value_template: "{{ value_json.departures | length }}"
3. Add a Lovelace card or Markdown card:
type: markdown
title: Departures
content: >
{% set deps = state_attr('sensor.transit_departures', 'departures') %}
{% set icons = {'subway':'🚇','suburban':'🚈','tram':'🚊','bus':'🚌','ferry':'⛴️','regional':'🚆','express':'🚄'} %}
{% for d in deps[:12] %}
{{ icons.get(d.mode, '🚏') }} **{{ d.line }}** → {{ d.direction | truncate(25, True) }} · *{{ d.time }}*{% if d.delay and d.delay > 0 %} +{{ d.delay }}min{% endif %}
{% endfor %}
This gives you something like:
🚇 U5 → Hönow · 2 min
🚈 S5 → Westkreuz · 4 min
🚌 100 → Zoologischer Garten · 6 min +3min
🚊 M4 → Sulzfelder Str. · 8 min
Useful API parameters
| Parameter | Example | Description |
|---|---|---|
radius |
500 |
Search area in meters (default 500, max 5000) |
mode |
bus or -bus |
Include or exclude transport modes |
from |
10 |
Skip departures in the next N minutes |
to |
45 |
Only show departures within N minutes |
limit |
20 |
Max number of departures (default 15, max 60) |
Full API Docs are here: API Documentation — Abfahrt! API
So if you only want buses departing in 10–30 minutes:
https://api.abfahrt.now/departures?lat=...&lon=...&radius=500&mode=bus&from=10&to=30&key=...
What’s in the response
Each departure includes:
- line: line name (e.g. “U2”, “75”, “S5”)
- direction: destination / headsign
- time: human-readable (“3 min”, “14:32”, “Now”)
- timestamp: Unix timestamp for automations
- delay: eal-time delay in minutes
- mode: subway, suburban, tramm, bus, ferry, regional, express
- stop: which nearby stop this departs from
- cancelled: boolean
The response also includes a city field (e.g. “Berlin”, “London”, “Barcelona”) and a stations list with all nearby stops and their distances.
Looking for testers
I’d love to hear feedback from you! Again, it all started as a side project, but I am excited what you do out of it, when tinkerers and devs don’t have to worry anymore about different data formats for different cities and transit operators. Especially interested in:
- How would your HA setup benefit from this information or what automations are you running with it?
- Are all your local stops showing up?
- What would make this more useful for your dashboard?
Bear with me when I am not responding quick enough. Will do my best to answer asap. ![]()