{"id":10309,"library":"traveltimepy","title":"Travel Time API Python Client","description":"Traveltimepy is the official Python client for the Travel Time API, providing functionality to calculate travel times and distances between locations, search reachable areas, and find routes. It supports various transportation modes (driving, cycling, public transport, walking). The current stable version is 4.6.1, with regular updates to keep pace with API features and Python ecosystem changes.","status":"active","version":"4.6.1","language":"en","source_language":"en","source_url":"https://github.com/TravelTime-dev/traveltime-python-sdk","tags":["API client","geospatial","travel time","mapping","location intelligence"],"install":[{"cmd":"pip install traveltimepy","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Data validation and settings management","package":"pydantic","optional":false},{"reason":"HTTP client for making API requests","package":"requests","optional":false},{"reason":"Utilities for parsing and manipulating dates/times","package":"python-dateutil","optional":false}],"imports":[{"note":"TravelTimeSDK was the main client class in v3; TravelTimeClient is used since v4.","wrong":"from traveltimepy import TravelTimeSDK","symbol":"TravelTimeClient","correct":"from traveltimepy import TravelTimeClient"},{"note":"Required for defining start/end points in API requests.","symbol":"Location","correct":"from traveltimepy import Location"},{"note":"Required for specifying latitude and longitude within Location objects.","symbol":"Coords","correct":"from traveltimepy import Coords"}],"quickstart":{"code":"import os\nfrom traveltimepy import TravelTimeClient\n\n# Initialize the Travel Time API client.\n# Ensure TRAVELTIME_APP_ID and TRAVELTIME_API_KEY environment variables are set\n# with your credentials obtained from the Travel Time Platform.\nclient = TravelTimeClient(\n    application_id=os.environ.get('TRAVELTIME_APP_ID', 'your_app_id_here'),\n    api_key=os.environ.get('TRAVELTIME_API_KEY', 'your_api_key_here')\n)\n\n# The 'client' object is now ready to make API calls, \n# e.g., client.time_filter(...), client.time_map(...).\n# For detailed examples, refer to the official documentation or GitHub README.","lang":"python","description":"This quickstart demonstrates how to initialize the `TravelTimeClient`. It relies on environment variables for API authentication. Replace placeholder values or ensure `TRAVELTIME_APP_ID` and `TRAVELTIME_API_KEY` are configured in your environment."},"warnings":[{"fix":"Users upgrading from v3.x to v4.x must rewrite their code. Review the official migration guide or v4.0.0 release notes. Key changes include `TravelTimeSDK` becoming `TravelTimeClient` and updated parameter objects.","message":"Version 4.0.0 of `traveltimepy` introduced a complete rewrite of the SDK. The client initialization, data structures (e.g., Location, Transportation), and method signatures changed significantly.","severity":"breaking","affected_versions":"3.x -> 4.x"},{"fix":"Set environment variables `TRAVELTIME_APP_ID` and `TRAVELTIME_API_KEY` with your actual credentials. Alternatively, pass them directly as keyword arguments to `TravelTimeClient()`.","message":"The API requires both an `application_id` and an `api_key`. Ensure these are correctly provided during client initialization, ideally via environment variables to avoid hardcoding credentials.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always cast latitude and longitude values to `float` before creating `Coords` objects, e.g., `Coords(lat=float(my_lat), lng=float(my_lng))`.","message":"When using `Coords` objects, ensure `lat` and `lng` are provided as floats. Incorrect data types can lead to `pydantic.ValidationError` or API errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify that your `TRAVELTIME_APP_ID` and `TRAVELTIME_API_KEY` environment variables (or direct parameters) match the credentials from your Travel Time Platform account. Check for typos or leading/trailing spaces.","cause":"Invalid `application_id` or `api_key` provided to the client, or the credentials do not have access to the requested API endpoint.","error":"traveltimepy.errors.TravelTimeError: Authentication failed (403 Forbidden)"},{"fix":"Update your code to use `TravelTimeClient` instead of `TravelTimeSDK`. The import should be `from traveltimepy import TravelTimeClient`.","cause":"Attempting to use the old `TravelTimeSDK` class from version 3.x with a version 4.x installation.","error":"AttributeError: module 'traveltimepy' has no attribute 'TravelTimeSDK'"},{"fix":"Ensure that both `lat` and `lng` values passed to `Coords` are valid `float` numbers. Convert strings to floats if necessary (e.g., `Coords(lat=float('51.5'), lng=float('-0.1'))`).","cause":"A `lat` (latitude) value provided to a `Coords` object was not a valid float (e.g., it was a string that couldn't be parsed).","error":"pydantic.error_wrappers.ValidationError: 1 validation error for Coords\\nlat\\n  value is not a valid float"}]}