Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Retreive values from public API at the Swedish Transport Administration (Trafikverket).
Readme
python module for communicating with the swedish trafikverket api
Development and testing done with 3.11
from pytrafikverket import TrafikverketTrain, StationInfo
import aiohttp
import asyncio
from datetime import datetime
async def main(loop):
async with aiohttp.ClientSession(loop=loop) as session:
train_api = TrafikverketTrain(session, "api_key_here")
stations = await train_api.async_search_train_stations("kristianstad")
for station in stations:
print(station.name + " " + station.signature)
from_station = await train_api.async_get_train_station("Sölvesborg")
to_station = await train_api.async_get_train_station("Kristianstad C")
product_description = "SJ Regional" # Optional search field
print("from_station_signature: " + from_station.signature)
print("to_station_signature: " + to_station.signature)
train_stop = await train_api.async_get_train_stop(from_station, to_station, datetime(2022, 4, 11, 12, 57), product_description);
print(train_stop.get_state())
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
$ py pytrafikverket.py -key <api_key> -method search-for-station -station "Kristianstad"
$ py pytrafikverket.py -key <api_key> -method get-next-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg"
$ py pytrafikverket.py -key <api_key> -method get-next-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -train-product "SJ Regional"
$ py pytrafikverket.py -key <api_key> -method get-train-stop -from-station "Kristianstad C" -to-station "Sölvesborg" -date-time "2017-05-19T16:38:00"
$ py pytrafikverket.py -key <api_key> -method get-weather -station "Nöbbele"
$ py pytrafikverket.py -key <api_key> -method search-for-ferry-route -route "sund"
$ py pytrafikverket.py -key <api_key> -method get-ferry-route -route "Adelsöleden"
$ py pytrafikverket.py -key <api_key> -method get-next-ferry-stop -from-harbor "Ekerö"
$ py pytrafikverket.py -key <api_key> -method get-next-ferry-stop -from-harbor "Furusund" -date-time "2019-12-24T00:00:00"
FAQs
Retreive values from public API at the Swedish Transport Administration (Trafikverket).
We found that pytrafikverket demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.