Skip to main content

traffic-cli

A small command-line tool that calculates the driving (or cycling/walking) travel time between two locations using a routing API of your choice.

$ traffic "las vegas" "los angeles"
From: las vegas (Las Vegas, Clark County, Nevada, United States)
To:   los angeles (Los Angeles, Los Angeles County, California, United States)
Travel time: 3 hours, 58 mins

Locations can be place names, addresses, or postcodes. Geocoding is done via OpenStreetMap's Nominatim; routing is delegated to a provider you configure (OpenRouteService, GraphHopper, Mapbox, Google Maps, or TomTom).

Installation

Requires Python 3.10+.

pipx install traffic-cli      # recommended (isolated install)
# or
pip install traffic-cli
# or, with uv
uv tool install traffic-cli

Setup

You need a free/paid API key from one of the supported routing providers, then run init once:

traffic init <provider> <api_key> [profile]
# e.g.
traffic init ors YOUR_API_KEY car

If you run traffic before initialising, it will prompt you interactively.

Configuration is stored at ~/.traffic/config.json.

Supported providers

Provider init name Get a key
OpenRouteService ors https://openrouteservice.org/
GraphHopper graphhopper https://www.graphhopper.com/
Mapbox mapbox https://www.mapbox.com/
Google Maps google_maps https://developers.google.com/maps

Travel profiles

Each provider supports three generic profiles: car (default), bike, and walk. Set your default with:

traffic set profile bike

Usage

traffic <origin> <destination>
traffic <origin> to <destination>

Examples:

traffic california nevada
traffic "las vegas" california
traffic las vegas to california
traffic home work                  # using saved variables (see below)
traffic --country gb b46 cv7       # bias geocoding to a country
traffic --home London --destination Paris

Saved variables

Save frequently used locations as named shortcuts:

traffic set home "10 Downing Street, London"
traffic set work "Buckingham Palace, London"
traffic home work

Country bias

If a place name is ambiguous, bias geocoding to a country with --country (alias --cc), or set a default. You can pass an ISO code (gb), a country name (france), or a common alias (uk, england, usa):

traffic --country gb birmingham coventry
traffic --country england b46 b9
traffic set country gb

Tip: short, bare UK outward codes like b9 are ambiguous even within a country (they also match B-roads). Use a full postcode (B9 4AA) or add a town ("B9, Birmingham") for a precise result.

Output formats

Flag Output
(default) Human-readable origin, destination, and travel time
--compact / -c Compact duration, e.g. 3h 58m
--raw / --seconds Raw duration in seconds
--json JSON object (Waybar-compatible)
--headless / -q Suppresses tips; prints a clean duration (good for scripts)

Routing options:

Flag Effect
--no-motorways Avoid motorways
--include-tolls Include toll roads

Waybar

The --json output is designed to drop straight into a Waybar custom module:

"custom/traffic": {
    "exec": "traffic --json home work",
    "return-type": "json",
    "interval": 300
}

Commands

Command Description
traffic <origin> <destination> Calculate travel time (the default command)
traffic init <provider> <key> [profile] Create the initial configuration
traffic set <key> <value> Set a setting (profile, country, api_key, provider_name) or a saved variable
traffic --version Print the installed version
traffic --help Show help

Notes

  • Geocoding uses OpenStreetMap's public Nominatim service. Requests are rate-limited to ~1/second and cached per invocation to respect its usage policy.
  • API usage (and any billing) is governed by whichever routing provider you configure.

Metadata

Release files for traffic-cli 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traffic-cli 0.1.2
File Size Uploaded
traffic_cli-0.1.2.tar.gz 26.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for traffic-cli 0.1.2
File Interpreter ABI Platform
traffic_cli-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 39.6 kB

Release files / traffic_cli-0.1.2.tar.gz

Download URL traffic_cli-0.1.2.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a232f473bed0d27cf3a4b1a81029759b0a715887dcd21b8df2c8396f2f3d278f
BLAKE2b-256 checksum
How to use checksums
0c0dac1ad7fe8ff2ec529bc421540cc6ea9ebb3565f9c6cb761b464020325888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / traffic_cli-0.1.2-py3-none-any.whl

Download URL traffic_cli-0.1.2-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc331ddba06b3a214f4c4a8f2a0a7ae0dae593e50e2bdcbac9251e345d1486fa
BLAKE2b-256 checksum
How to use checksums
c0815fc89fdf3757c33b380d75f76691c91d9863d60eaebc01b533d73fdf93bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page