Simplified data retrieval from Entur in Python
Project description
Pythentur
This package provides functions for simple fetching of real-time public transport data - as provided by Entur. As an added bonus, the nsrGet
-function makes it easy to obtain the NSR ID of a stop place by a search string.
Installation
pip install pythentur
Dependencies:
Due to an issue, I'm not able to generate package dependencies, so they will have to be installed manually for the time being.
- Requests
Usage
StopPlace
object
Create a StopPlace
object by handing in the NSR ID to the constructor.
from pythentur import StopPlace
oslo_s = StopPlace("NSR:StopPlace:59872")
This stores the ID, the name of the stop place (if available) and a pre-made query template in the GraphQL format.
The number of calls to retrieve can be changed by changing the argument noDepartures
in the get
method. The default is 20.
StopPlace.get
method
This method makes a request to the Entur GraphQL API, by populating the query template with the NSR ID and the number of calls to get. This retrieves a list of calls, each represented by a dictionary.
from pythentur import StopPlace
oslo_s = StopPlace("NSR:StopPlace:59872")
data = oslo_s.get()
Here, data
is a list of dictionaries, each containing:
'platform'
: String containing the platform this call is arriving on. May be a blank string if the stop place does not have different specified platforms.'line'
: String containing the line number and name of the arriving transport.'aimedArrivalTime'
: Datetime object containing the planned arrival time of the call.'expectedArrivalTime'
: Datetime object containing the expected arrival time of the call.'delay'
: Timedelta object containing the calculated delay of the call.'readableTime'
: Returns a human readable string with relative time from now to the expected departure.
nsrGet
function
Utilizing nsrGet
, finding NSR IDs becomes a breeze. Hand in a search string to the function, and it spits out a list of IDs from stop places matching that string.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pythentur-0.0.9.tar.gz
.
File metadata
- Download URL: pythentur-0.0.9.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eaa37bc5e6f2a85ec6100661876d4d586522d4379c83a6b28b06c39a816c700 |
|
MD5 | 17eaf3c207171ed8e6036a6ebcb5eeb8 |
|
BLAKE2b-256 | a4b105e2c971d43c287020449df4fb91bb0ded5d2ab67168d350022f4b7af5c6 |
File details
Details for the file pythentur-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: pythentur-0.0.9-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab6ba3b83e951c38474ae2620cd05a8d0e6aae1ade49859bb250aaddb91d0330 |
|
MD5 | f7ffcdca3ae4d1e6ab94cc9a7e90fb49 |
|
BLAKE2b-256 | 1f78ce0f4767b5d33527ec0de8044d95fcc666b804f88d9fa4ee49664fc903c9 |