Skip to main content

tollcalc

Python client and CLI for the TollCalc European truck toll API. Calculate road tolls for heavy goods vehicles across 37 European countries — by address or GPS coordinates.

Installation

pip install tollcalc

Authentication

Up to 10 requests per month are free without a token.

Log in via browser (recommended)

tollcalc auth login

This opens your browser, lets you log in to your TollCalc account, and saves a long-lived API token to ~/.config/tollcalc/token. All subsequent CLI calls use this token automatically.

tollcalc auth status    # show current login state
tollcalc auth logout    # remove the stored token

Set the token manually

export TOLLCALC_TOKEN=your_token_here

Or write it to ~/.config/tollcalc/token.


CLI usage

Route by address

Calculate the toll for a truck driving from Hamburg to Vienna:

tollcalc --from "Hamburg, Germany" --to "Vienna, Austria"

With a via stop in Munich and segment detail:

tollcalc \
  --from "Hamburg, Germany" \
  --to   "Vienna, Austria" \
  --via  "Munich, Germany" \
  --axles 5 \
  --weight 40 \
  --emission-class euro6 \
  --co2-class class_1 \
  --all-segs

Output:

Route: Hamburg → Munich → Vienna
Total: 983.4 km  |  Toll: 142.78 €
Vehicle: 5 axles, 40 t, euro6, class_1

 Country      Total km   Toll km   Distance   Traversal      Total    €/km   Segs
 Germany       512.3 km   498.1 km    82.40 €          -    82.40 €  0.1655    43
 Austria       211.8 km   211.8 km    50.38 €     10.00 €   60.38 €  0.2843    18

Route by GPS coordinates

If you have a GPS track from a driven route (e.g. from a telematics system), pass the coordinates directly — geocoding is skipped and the toll is calculated on the exact driven path.

Use "lat;lon" format for each point. Pass the first point as --from, the last as --to, and all intermediate points via --via:

tollcalc \
  --from "53.5503;10.0006" \
  --via  "52.5200;13.4050" \
  --via  "50.0755;14.4378" \
  --via  "48.8068;14.0059" \
  --to   "48.2093;16.3728"

Waypoint limit: 50 total (origin + via + destination) The routing engine accepts at most 50 waypoints per request, which means --via may contain at most 48 entries. Raw GPS tracks from telematics systems typically have hundreds or thousands of points — these must be downsampled before use. A good rule of thumb: keep one point per kilometre. A 500 km route should have around 50 via points or fewer. Many telematics platforms offer a built-in downsampling or track simplification feature (e.g. Ramer-Douglas-Peucker algorithm).

You can also mix addresses and coordinates freely:

tollcalc --from "Hamburg, Germany" --to "48.2093;16.3728"

All options

  --from PLACE          Origin: address or "lat;lon" coordinate
  --to   PLACE          Destination: address or "lat;lon" coordinate
  --via  PLACE          Via waypoint, repeatable

  --axles N             Number of axles (default: 5)
  --weight T            Gross weight in tonnes (default: 40)
  --emission-class K    Euro emission class, e.g. euro6 (default: euro6)
  --co2-class K         CO2 class class_1..class_5 (default: class_1)

  --planned-trip-start  DATETIME   Trip date/datetime (ISO-8601) — uses the toll
                        rules valid at that point in time (default: now)

  --token TOKEN         API bearer token (or set TOLLCALC_TOKEN)
  --api-url URL         Custom API base URL

  --segs                Show tolled segments per country
  --all-segs            Show all segments, including toll-free ones
  --road-types          Show road-type breakdown per country
  --json                Print raw API response as JSON
  --debug               Request ORS routing debug data
  --ors FILE            Save raw ORS response to FILE (implies --debug)
  --ors-steps           Print ORS step-by-step road analysis (implies --debug)

Python API

Use calculate_toll() when you want to integrate toll calculation into your own Python application without using the CLI.

Route by address

from tollcalc import calculate_toll

result = calculate_toll(
    origin="Hamburg, Germany",
    destination="Vienna, Austria",
    via=["Munich, Germany"],
    axles=5,
    weight=40.0,
    emission_class="euro6",
    co2_class="class_1",
)

print(f"Total toll: {result['total_toll_eur']:.2f} €")
print(f"Total distance: {result['total_distance_km']:.1f} km")

for country in result["countries"]:
    print(f"  {country['country_name']}: {country['toll_eur']:.2f} €")

Route by GPS coordinates

If your TMS or telematics system provides a GPS track, pass the coordinates as "lat;lon" strings. This is useful when you want to calculate the toll for a route that has already been driven:

from tollcalc import calculate_toll

# GPS track recorded by the vehicle (lat;lon format)
gps_track = [
    "53.5503;10.0006",   # Hamburg
    "52.5200;13.4050",   # Berlin
    "50.0755;14.4378",   # Prague
    "48.8068;14.0059",   # Linz area
]

result = calculate_toll(
    origin=gps_track[0],
    destination=gps_track[-1],
    via=gps_track[1:-1],   # all intermediate points
    axles=5,
    weight=40.0,
    emission_class="euro6",
    co2_class="class_1",
    token="your_api_token",   # or set TOLLCALC_TOKEN env var
)

print(f"Total toll for driven route: {result['total_toll_eur']:.2f} €")

for country in result["countries"]:
    km_toll   = country["km_toll_eur"]
    traversal = country["traversal_toll_eur"]
    print(
        f"  {country['country_name']:15s}  "
        f"{country['total_km']:6.1f} km  "
        f"{country['toll_eur']:7.2f} €"
        + (f"  (incl. {traversal:.2f} € vignette)" if traversal else "")
    )

Function reference

calculate_toll(
    origin: str,
    destination: str,
    *,
    via: list[str] | None = None,
    axles: int = 5,
    weight: float = 40.0,
    emission_class: str = "euro6",
    co2_class: str = "class_1",
    token: str | None = None,
    api_url: str = "https://app.tollcalc.eu",
    debug: bool = False,
    planned_trip_start: str | None = None,
    timeout: int = 60,
) -> dict
Parameter Description
origin Departure — free-text address or "lat;lon" string
destination Arrival — free-text address or "lat;lon" string
via List of intermediate waypoints (addresses or coordinates). Max 48 entries — the routing engine allows at most 50 waypoints in total (origin + via + destination). For GPS tracks, downsample to ~1 point/km.
axles Number of axles: 2, 3, 4, 5 (5 = 5+)
weight Gross vehicle weight in tonnes
emission_class euro0euro6
co2_class class_1 (highest emissions) … class_5 (zero emission)
token API bearer token. Falls back to TOLLCALC_TOKEN env var or ~/.config/tollcalc/token
api_url Custom API base URL (default: https://app.tollcalc.eu)
debug Include raw ORS routing data in the response
planned_trip_start ISO-8601 date or datetime (e.g. "2026-09-01" or "2026-09-01T06:00:00Z"). Uses the toll rules that are valid at this point in time (e.g. the Dutch 22.3 % discount from 1 Sep 2026). Default: current time
timeout HTTP timeout in seconds

Returns the raw API response dict. Raises requests.HTTPError on API errors.


Supported countries

37 European countries including Germany, Austria, France, Poland, Czech Republic, Hungary, Romania, Croatia, Benelux, Scandinavia, and more. See tollcalc.eu for the full list.

Links

Download files

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

Source Distribution

tollcalc-0.5.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

tollcalc-0.5.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file tollcalc-0.5.0.tar.gz.

File metadata

  • Download URL: tollcalc-0.5.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.5

File hashes

Hashes for tollcalc-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7ec84441feafc56f06762addbd033a2f18b6e9f7625c33b8772d29debcb56a67
MD5 1d822bc523015d808cabee57efe31064
BLAKE2b-256 202c986325e7fd18ac74330c90bc07e5dad84c785f56d06c520e9175800c5a5b

See more details on using hashes here.

File details

Details for the file tollcalc-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: tollcalc-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.5

File hashes

Hashes for tollcalc-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad71df92933a9a00d9440ce4551a3d60e0bd178b8b7c44f3db255b4de1504b48
MD5 610cf66500e889a1417fc2e422a0983b
BLAKE2b-256 5937bcc7d1b3dd127de108d47bb4ab0fa534de9d746875ab8582654cc885d848

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 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