A command line tool for retrieving data from Eco Counter's traffic counter API
Project description
Traffic Data Fetcher
A command line tool for retrieving information about counter sites and retrieving traffic data from Eco Counter's traffic monitoring stations.
Installation
Traffic Data Fetcher requires Python 3.8 or higher. The recommended way to install Traffic Data Fetcher is via pipx:
python3 -m pipx install traffic-data-fetcher
Alternatively, pipx allows directly running Traffic Data Fetcher without installing it first:
python3 -m pipx run traffic-data-fetcher YOUR-ARGS-HERE
Organisation of the traffic monitoring stations
Eco Counter calls their traffic monitoring stations counter sites. A counter site groups counters positioned at the same location. A counter collects data for a specific means of transport and a specific direction of travel. Each counter site belongs to a domain. A domain groups a number of counter sites which are typically operated by a city or district administration.
A counter site may be either public or non-public. Detailed traffic data separated by direction is only available for public sites. Traffic Data Fetcher currently does not support fetching data from non-public sites.
Usage
Traffic Data Fetcher supports the commands list-domains, list-sites, and fetch-counts.
By default, the commands write their results to standard output in csv format. By passing a file name
with the -f or --file option the results can be saved into a csv file.
Standard options:
-h,--help: show a help message and exit--version: show the version of traffic-data-fetcher and exit
List all domains
Retrieves a list of all known domains. As there is no official queryable list of domains, the
list-domains command relies on a list which is regularly updated by a cloud service that checks
all domain ids between 1 and 10.000 for existing domains.
Usage: traffic-data-fetcher list-domains [-h] [-f FILE]
Options:
-h,--help: show a help message and exit-f,--fileFILE: store a domain list in a csv-file. Existing files are overwritten
List counter sites
Retrieves detailed information for all (public and non-public) counter sites within a specified domain, or for the provided counter sites. If individual counter sites are queried, only public sites can be retrieved.
Usage: traffic-data-fetcher list-sites [-h] (-d DOMAIN_ID | -s SITE_IDS [SITE_IDS ...]) [-f FILE]
Options:
-h,--help: show a help message and exit-d,--domainDOMAIN_ID: id of the domain whose counter sites should be listed-s,--sitesSITE_IDS [SITE_IDS ...]: ids of the counter sites to list-f,--fileFILE: store counter sites in a csv-file. Existing files are overwritten
Fetch counter data
Retrieves traffic data from all public counter sites within a specified domain or from the provided public counter sites. The returned data can be filtered by means of transport and direction, and constrained by time range and temporal resolution.
Usage:
traffic-data-fetcher fetch-counts [-h] (-d DOMAIN_ID | -s SITE_IDS [SITE_IDS ...])
[-f FILE]
[-S {quarter_of_an_hour,hour,day,week,month}]
[-B BEGIN] [-E END]
[-D {in,out,none} [{in,out,none} ...]]
[-M {foot,bike,horse,car,bus,minibus,undefined,motorcycle,kayak,e_scooter,truck}
[{foot,bike,horse,car,bus,minibus,undefined,motorcycle,kayak,e_scooter,truck}
...]]`
Options:
-h,--help: show a help message and exit-d,--domainDOMAIN_ID: id of the domain whose counter sites should be fetched-s,--sitesSITE_IDS [SITE_IDS ...]: ids of the counter sites to fetch-f,--fileFILE: store data in a csv-file. Existing files are overwritten-S,--step-size {quarter_of_an_hour,hour,day,week,month}: step size of the data to fetch. Defaults tohour-B,--begin BEGIN: fetch data starting at date. Date must be ISO 8610 formatted (YYYY-MM-DD)-E,--end END: fetch data until date (exclusively). Date must be ISO 8610 formatted (YYYY-MM-DD)-D,--direction {in,out,none} [{in,out,none} ...]: select directions to fetch. By default, data for all directions is fetched-M,--means-of-transport {foot,bike,horse,car,bus,minibus,undefined,motorcycle,kayak,e_scooter,truck} [{foot,bike,horse,car,bus,minibus,undefined,motorcycle,kayak,e_scooter,truck} ...]: select means of transport to fetch. By default, data for all means of transport is fetched
Examples
- Show the list of known domains:
traffic-data-fetcher list-domains - Show details for all counter sites in the domain Stadt Bonn:
traffic-data-fetcher list-sites --domain 4701
- Retrieve the monthly count data for all counters at the two counter sites *Kennedybrücke (Nordseite)* and *Kennedybrücke (Südseite)* in Bonn:
traffic-data-fetcher fetch-counts --sites 100019809,100019810 --step-size month
- Retrieve the monthly count data for cars entering Ludwigsburg via Bismarckstraße (the counter
site records counts for both bicycles and cars):
# Get the details of the counter site to find out # which direction corresponds to going into town: traffic-data-fetcher list-sites --sites 300015617 # Going into town is represented by direction in (unsurprisingly). # Using this information the data can be fetched like this: traffic-data-fetcher fetch-counts --sites 300015617 --step-size month --direction IN --means-of-transport car
- Retrieve hourly count data per recorded at the counter site Rhenusallee in Bonn for the dates Saturday, April 5, 2025,
and Sunday, April 6, 2025:
traffic-data-fetcher fetch-counts --sites 100019729 --begin 2025-04-05 --end 2025-04-07
Acknowledgements
Special thanks to Pascua Theus for providing the groundwork for accessing Eco Counter's API in his blog post on counting bicycles and to the Bundesstelle for Open Data for their documentation of the Eco-Visio-API. Their contributions were essential to making this project possible.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traffic_data_fetcher-1.1.0.tar.gz.
File metadata
- Download URL: traffic_data_fetcher-1.1.0.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
045879aaa6cf6f308270abd1b87bdcb65d7c34450386e27beca5af53b53fd802
|
|
| MD5 |
54f8da56fad08bb3ee8156b430d043a1
|
|
| BLAKE2b-256 |
882cb3ce3ac49d9816393f99a6f378f7e5330244edd6a31e58c4a1da3dd16672
|
Provenance
The following attestation bundles were made for traffic_data_fetcher-1.1.0.tar.gz:
Publisher:
release.yml on cboehme/traffic-data-fetcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
traffic_data_fetcher-1.1.0.tar.gz -
Subject digest:
045879aaa6cf6f308270abd1b87bdcb65d7c34450386e27beca5af53b53fd802 - Sigstore transparency entry: 203125218
- Sigstore integration time:
-
Permalink:
cboehme/traffic-data-fetcher@82941fa87f43139aca07aa39ff450e4b11b4aec2 -
Branch / Tag:
refs/tags/release/1.1.0 - Owner: https://github.com/cboehme
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@82941fa87f43139aca07aa39ff450e4b11b4aec2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file traffic_data_fetcher-1.1.0-py3-none-any.whl.
File metadata
- Download URL: traffic_data_fetcher-1.1.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e18a42db91e9b28c1a729edc6548c72378acbba625e11e485a56eaa8f93fb168
|
|
| MD5 |
f28eb331ece66d1ca04dd3b3f9e2af9b
|
|
| BLAKE2b-256 |
d7a14fd471ff116ecb9a9d4604a06a803823cae177eb01c06512b7a580cc4c4f
|
Provenance
The following attestation bundles were made for traffic_data_fetcher-1.1.0-py3-none-any.whl:
Publisher:
release.yml on cboehme/traffic-data-fetcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
traffic_data_fetcher-1.1.0-py3-none-any.whl -
Subject digest:
e18a42db91e9b28c1a729edc6548c72378acbba625e11e485a56eaa8f93fb168 - Sigstore transparency entry: 203125219
- Sigstore integration time:
-
Permalink:
cboehme/traffic-data-fetcher@82941fa87f43139aca07aa39ff450e4b11b4aec2 -
Branch / Tag:
refs/tags/release/1.1.0 - Owner: https://github.com/cboehme
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@82941fa87f43139aca07aa39ff450e4b11b4aec2 -
Trigger Event:
push
-
Statement type: