--- id: pytrafikverket version: "1.1.1" license: MIT license_treatment: permissive maintenance: active --- # pytrafikverket — Retrieve values from public API at the Swedish Transport Administration (Trafikverket). License: permissive · Maintenance: active · Downloads: 73.5K/mo ## What it is and what it does Pytrafikverket is an async Python wrapper around the Swedish Transport Administration's (Trafikverket) public API. It provides high-level methods to search and retrieve train station information, query train schedules between stations, look up ferry routes and schedules, and fetch weather data at transport locations. The library uses aiohttp for non-blocking HTTP requests, making it suitable for integration into async applications or services that need to poll transport data without blocking. The package includes both a programmatic API (via TrafikverketTrain and related classes) and a CLI tool for direct queries. It requires an API key from Trafikverket and Python 3.11 or later. Dependencies are lightweight: aiohttp for HTTP, lxml for XML parsing, yarl for URL handling, and aiozoneinfo for timezone support. Use it for: - Build a travel planner or commute app that queries real-time Swedish train schedules and station information. - Monitor ferry route availability and schedules for Swedish waterway transport. - Fetch weather conditions at Swedish transport hubs for operational decision-making. - Create a CLI tool or dashboard that displays next available train or ferry departures. - Integrate transport data into a broader Swedish logistics or mobility platform. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Async Python client for querying Sweden's Trafikverket public API to retrieve train stations, schedules, ferry routes, and weather data. Yes, if you need to query Swedish Trafikverket data. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. The async design and modern Python support (3.11+) make it well-suited for contemporary applications. Verify that your use case aligns with Trafikverket's API terms and that you can obtain an API key. ## Install pip install pytrafikverket uv add pytrafikverket poetry add pytrafikverket ## Installing pytrafikverket Before you install: Low friction install with a pure-Python wheel. Actively maintained as of 2026-08-12 with recent releases. Supports Python 3.11, 3.12, and 3.13. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal attribution requirements. Quickstart: import asyncio import aiohttp from pytrafikverket import TrafikverketTrain async def main(): async with aiohttp.ClientSession() as session: train_api = TrafikverketTrain(session, "your_api_key") stations = await train_api.async_search_train_stations("kristianstad") for station in stations: print(station.name) asyncio.run(main()) Requires a valid Trafikverket API key; obtain one from the Swedish Transport Administration before use. Verify before relying: - Whether the Trafikverket API key is free or requires registration/payment - Rate limits or quotas enforced by the Trafikverket API - Geographic scope: whether the API covers all Swedish transport or only specific regions ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 73.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags swedish trafikverket api client, train station lookup python, async swedish transport api, ferry route query, trafikverket python wrapper, swedish railway data, transport administration api, async-http-client, swedish-transport, public-api-wrapper [View on SkillFed](https://skillfed.io/packages/pytrafikverket) · [View on PyPI](https://pypi.org/project/pytrafikverket/)