Skip to main content

septa-api

Async Python client for SEPTA real-time data: service alerts, Regional Rail departure boards and trip planning, bus and trolley positions, and stop departures for every bus, trolley, and subway route. Built for a Home Assistant integration, usable anywhere.

No API key needed. Not affiliated with SEPTA.

Installation

pip install septa-api

Usage

import asyncio

import aiohttp

from septa_api import SeptaClient, load_catalog


async def main():
    catalog = load_catalog()
    route = catalog.routes["B1"]
    northbound = next(d for d in route.directions if d.name == "Northbound")
    stop_id = northbound.stop_ids[0]

    async with aiohttp.ClientSession() as session:
        client = SeptaClient(session)

        for departure in await client.async_get_stop_departures(stop_id, route.id, results=3):
            label = "live" if departure.realtime else "scheduled"
            print(f"{catalog.stops[stop_id]}: {departure.expected:%H:%M} ({label})")

        for alert in await client.async_get_alerts():
            if route.id in alert.route_ids:
                print(f"{alert.severity}: {alert.header}")


asyncio.run(main())

Data sources

SEPTA's real-time data is spread over three systems, each with gaps. This library uses each one for what it does best.

Data Source Notes
Routes, directions, stops Static GTFS, bundled Refreshed daily by a workflow when SEPTA publishes a new release
Service alerts GTFS-RT alert feeds Every mode; uses the same route IDs as the catalog
Stop departures JSON API timetable, plus live bus/trolley delay Broad Street and Market-Frankford Lines are timetable only
Bus and trolley positions JSON API (TransitView)
Regional Rail departures and trips JSON API (Arrivals, NextToArrive) Live delays, tracks, and transfers

SEPTA publishes no live predictions for the Broad Street Line or Market-Frankford Line. Their GTFS-RT trip updates are generated from the timetable, so this library doesn't pretend otherwise: their StopDeparture.realtime is always False.

API

All times are timezone-aware in America/New_York (septa_api.TIMEZONE).

load_catalog()

Returns the bundled Catalog: routes by route ID, stops (stop ID to name), and the gtfs_version it was built from. It reads a file, so call it in an executor from async code. The result is cached.

A route's directions carry each direction's GTFS id, name (Northbound, Inbound, ...), destination, and ordered stop_ids. Direction IDs mean different things on different routes, so match on name.

SeptaClient(session)

Takes an aiohttp.ClientSession, which the caller owns.

await client.async_get_alerts()

Every active and upcoming Alert across all modes. Route-level alerts list route_ids and apply to both directions. Trip cancellations list only trip_ids, which match StopDeparture.trip_id. Use alert.is_active(now) to filter by the alert's active periods.

await client.async_get_stop_departures(stop_id, route_id, results=20)

Upcoming StopDepartures of one route from a bus, trolley, or subway stop, from the timetable. When a live vehicle is running the trip, delay_minutes and vehicle_id are filled in and realtime is True; expected is the scheduled time plus the delay. SEPTA caps results at 20.

await client.async_get_vehicles(route_id)

Live Vehicle positions on a bus or trolley route. direction matches the catalog's direction names case-insensitively. Empty for subway lines.

await client.async_get_station_departures(station, results=5)

A Regional Rail station's live departure board, as TrainDepartures, results per direction. direction is N or S (SEPTA's through-Center-City convention), not inbound/outbound.

await client.async_get_next_to_arrive(origin, destination, results=5)

The next Regional Rail Trips between two stations, each with one or two TripLegs and the connection_station if there's a transfer.

Station arguments are catalog stop names; the client translates them to the legacy names SEPTA's JSON API expects. Station names in the results (origin, connection_station, ...) are SEPTA's legacy names.

Exceptions

  • SeptaRequestError: SEPTA rejected the request, e.g. an unknown station or stop.
  • SeptaConnectionError: SEPTA couldn't be reached or returned a server error.
  • SeptaError: base class; also raised for malformed responses.

License

MIT

Metadata

Release files for septa-api 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for septa-api 0.1.0
File Size Uploaded Provenance Actions
septa_api-0.1.0.tar.gz 181.8 kB With provenance Details for septa_api-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for septa-api 0.1.0
File Interpreter ABI Platform Actions
septa_api-0.1.0-py3-none-any.whl Python 3 none any Details for septa_api-0.1.0-py3-none-any.whl

Total release size: 361.3 kB

Release files / septa_api-0.1.0.tar.gz

Download URL septa_api-0.1.0.tar.gz
Size 181.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d563255bd86e7090e318122b3cb2e4fb6e68bcf8fbf7bfb656ee008f13a5d7b2
BLAKE2b-256 checksum
How to use checksums
f4ff2c64deeadd78e8733948ce8e28fd593d835c2af5fb3324e78c73c839e6fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / septa_api-0.1.0-py3-none-any.whl

Download URL septa_api-0.1.0-py3-none-any.whl
Size 179.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2170593eb3579fcc6abf3fcd68653db1171877ff9f5f7fbefa2c4b5e59bc731
BLAKE2b-256 checksum
How to use checksums
ca9c1775c4228ef18fcb5f8145ff8e23acd4be21bd0bae36f16145acb3cdafd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for septa-api 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for septa_api-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page