Skip to main content

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.

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, --file FILE: store a domain list in a csv-file. Existing files are overwritten

List counter sites

Retrieves detailed information for all public counter sites within a specified domain, or for the provided counter sites.

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, --domain DOMAIN_ID: id of the domain whose counter sites should be listed
  • -s, --sites SITE_IDS [SITE_IDS ...]: ids of the counter sites to list
  • -f, --file FILE: store counter sites in a csv-file. Existing files are overwritten

Fetch counter data

Retrieves traffic data from all counter sites within a specified domain or from the provided 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, --domain DOMAIN_ID: id of the domain whose counter sites should be fetched
  • -s, --sites SITE_IDS [SITE_IDS ...]: ids of the counter sites to fetch
  • -f, --file FILE: 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 to hour
  • -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
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traffic_data_fetcher-1.0.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traffic_data_fetcher-1.0.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file traffic_data_fetcher-1.0.0.tar.gz.

File metadata

  • Download URL: traffic_data_fetcher-1.0.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for traffic_data_fetcher-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2d592f6bfec42eca5822500d785e5a0de40b4663b9f1fb0c1f437c1f5157c7ce
MD5 6c4b19ce1657be51141ab247dc6c4c03
BLAKE2b-256 2ecd883c14d5cf3bf50ef5266d2f9159656a3e6113418ff0dc567d6711b470b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for traffic_data_fetcher-1.0.0.tar.gz:

Publisher: release.yml on cboehme/traffic-data-fetcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file traffic_data_fetcher-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for traffic_data_fetcher-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f26243867096518a0cac9e7e4e7b03ef9fdd712ce689a3c2d417b7de7958ebbc
MD5 9d3f6deda41ca6d44e3f4c34f1b21f1a
BLAKE2b-256 f5ec86405ae39a4fcacfba962af18c6e5e43601806fe15f900ad68d023fe4fda

See more details on using hashes here.

Provenance

The following attestation bundles were made for traffic_data_fetcher-1.0.0-py3-none-any.whl:

Publisher: release.yml on cboehme/traffic-data-fetcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page