Skip to main content

Python API for EFA(Elektronische Fahrplanauskunft) async requests

Project description

apyefa

Python package License

Intro

apyefa is a python package used to asynchronously fetch public transit routing data via EFA interfaces like efa.vgn. It can request itineraries for Bus/Trams/Subways etc. connections and return data in a human and machine readable format.

Installation

You only need to install the apyefa package, for example using pip:

pip install apyefa

Restrictions

Currently the package supports only endpoints using RapidJSON format. To check whether the endpoint supports this format, please call:

curl <EFA API URL>/XML_SYSTEMINFO_REQUEST?outputFormat=rapidJSON
e.g. curl https://bahnland-bayern.de/efa/XML_SYSTEMINFO_REQUEST?outputFormat=rapidJSON

If API's answer looks like this, endpoint supports rapidJSON:

{"version":"10.6.21.17","ptKernel":{"appVersion":"10.6.22.28 build 16.12.2024 11:14:57","dataFormat":"EFA10_06_01","dataBuild":"2024-12-31T00:54:55Z"},"validity":{"from":"2024-12-15","to":"2025-06-14"}}

Development setup

Create and activate virtual environment. Then install dependencies required by apefa package.

python3 -m venv .venv
source .venv/bin/activate
pip install .

apyefa functions

Function Name Description
info() Provides EFA endpoint system information
locations_by_name() Search for locations by name with optional filters and limits
location_by_coord() Search for location by it's coordinates
list_lines() Retrieves a list of lines
list_stops() Retrieves a list of stops
trip() Calculates a trip between an origin and a destination locations
departures_by_location() Fetches departures for a given location
lines_by_name() Fetches lines by name
lines_by_location() Fetches lines for a specific location
line_stops() Retrieves the stops for a given line
coord_bounding_box() Requests locations within a bounding box
coord_radial() Requests locations within a radius
geo_object() Generates a sequence of coordinates and all passed stops of a provided line

Example

import asyncio
from apyefa import EfaClient
from apyefa.data_classes import (
    Location,
    LocationFilter,
)

async def async_info(client: EfaClient):
    info = await client.info()
    print(info)

async def async_location_by_name(client: EfaClient):
    stops: list[Location] = await client.locations_by_name(
        "Plärrer", filters=[LocationFilter.STOPS], limit=20
    )
    for s in stops:
        print(s)    

async def main():
    async with EfaClient("https://bahnland-bayern.de/efa/") as client:
        await asyncio.gather(
            async_info(client),
            async_location_by_name(client),
        )

if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apyefa-1.0.1.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apyefa-1.0.1-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file apyefa-1.0.1.tar.gz.

File metadata

  • Download URL: apyefa-1.0.1.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for apyefa-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4ecc5c712dbc18b0a94340c7be43f173071087eba5ed8fdd89877a342d028b19
MD5 1651c69406c9387fc72fefbbad6dd825
BLAKE2b-256 ad12e54d9f6e9467b418d3c01cfece23c7ce292ca5de8c1f1e966be0ef8ebd8f

See more details on using hashes here.

File details

Details for the file apyefa-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: apyefa-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for apyefa-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e77c987b7dc1e956ffe0c27cbfbecaeb4423ae3bff5c470fc83db0d97a40e712
MD5 f8bcf87ce816b42d89eaeed19c3e631b
BLAKE2b-256 e352805d1f5f0c5f77e33065416747120411e1afc60ff27f4041fc5a60c3983e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page