Simplified data retrieval from Entur in Python
Project description
Pythentur
Entur data-fetch in Python
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:
- 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 and a pre-made query template in the GraphQL format.
Pythentur supports custom query templates, if you wish to retrieve more data. This is given to the constructor with the query
argument.
query_template = "<graphQL query>"
oslo_s = StopPlace("NSR:StopPlace:59872", query = query_template)
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.
The number of calls to retrieve can be changed by changing the argument noDepartures
in the get()
method. The default is 20.
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.3.tar.gz
.
File metadata
- Download URL: pythentur-0.0.3.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5c139ae4ee53fc02d6cb7c0359558e5db545700239bf64811b1d8b11393f69f |
|
MD5 | 3feba72d5f770100aa0fc227ee3be15c |
|
BLAKE2b-256 | f6227c0d3143b0ea91e347566c43e1c53b209d53648832b646ba6f84951bfd75 |
File details
Details for the file pythentur-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pythentur-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.8 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/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67705e1808b37e05f844305a1c067942d4119c6b4ed85acec5f7ca156d422ef5 |
|
MD5 | f66b341b390f79a88c08fcfca92679b1 |
|
BLAKE2b-256 | a13cb94b71652f92bef8db848045e1267401754a06c4d364da798877b3709246 |