A comprehensive, production-ready Python SDK for accessing HERE Technologies Traffic and Incident APIs. Provides 100% coverage of all documented endpoints with full type hints, comprehensive error handling, and extensive test coverage.
- β 100% API Coverage - All documented endpoints (v7, v6.3, and v3)
- β Dual Authentication - API Key and OAuth 2.0 support with automatic token management
- β Type Hints - Full type annotations throughout for better IDE support
- β Response Models - Structured data models with helper methods
- β 100% Test Coverage - Comprehensive unit, integration, and e2e tests
- β Well Documented - Extensive documentation and examples
- β Production Ready - Error handling, retries, and best practices
pip install -e here_traffic_sdkOr install from requirements:
cd here_traffic_sdk
pip install -r requirements.txtfrom here_traffic_sdk import HereTrafficClient, LocationReference
# Initialize client with API key
client = HereTrafficClient(api_key="YOUR_API_KEY")
# Get traffic flow data for a circular area (London, 1km radius)
flow_response = client.v7.get_flow_circle(
latitude=51.50643,
longitude=-0.12719,
radius_meters=1000,
location_referencing=LocationReference.SHAPE
)
# Access flow data
flows = flow_response.flows
free_flow_speeds = flow_response.free_flow_speeds
expected_speeds = flow_response.expected_speeds
print(f"Found {len(flows)} flow segments")
print(f"Average free flow speed: {sum(free_flow_speeds) / len(free_flow_speeds):.1f} km/h")
# Get traffic incidents
incidents_response = client.v7.get_incidents_circle(
latitude=51.50643,
longitude=-0.12719,
radius_meters=1000
)
# Access incident data
incidents = incidents_response.incidents
critical_incidents = incidents_response.get_critical_incidents()
print(f"Found {incidents_response.incident_count} incidents")
print(f"Critical incidents: {len(critical_incidents)}")from here_traffic_sdk import HereTrafficClient, AuthMethod
# Initialize client with OAuth credentials
client = HereTrafficClient(
access_key_id="YOUR_ACCESS_KEY_ID",
access_key_secret="YOUR_ACCESS_KEY_SECRET",
auth_method=AuthMethod.OAUTH
)
# Use the client the same way
response = client.v7.get_flow_circle(51.50643, -0.12719, 1000)- β
GET /flow- Traffic flow data - β
GET /incidents- Traffic incident data - β
GET /availability- API availability information
- β
GET /flow.json- Traffic flow data - β
GET /incidents.json- Traffic incident data
- β
GET /flow- Traffic flow data
- SDK Documentation - Complete SDK documentation
- API Endpoints - Complete API endpoint documentation
- Examples - Usage examples
- Test Coverage - Test coverage report
from here_traffic_sdk import HereTrafficClient, LocationReference, GeospatialFilter
client = HereTrafficClient(api_key="YOUR_API_KEY")
# Using circle filter
response = client.v7.get_flow_circle(
latitude=51.50643,
longitude=-0.12719,
radius_meters=1000
)
# Using bounding box filter
response = client.v7.get_flow_bbox(
lat1=51.5,
lon1=-0.13,
lat2=51.51,
lon2=-0.12
)
# Using custom geospatial filter
filter_str = GeospatialFilter.circle(51.50643, -0.12719, 2000)
response = client.v7.get_flow(
location_referencing=LocationReference.SHAPE,
geospatial_filter=filter_str
)# Get incidents in a circular area
response = client.v7.get_incidents_circle(
latitude=51.50643,
longitude=-0.12719,
radius_meters=1000
)
# Get all incidents
all_incidents = response.incidents
# Get only critical incidents
critical = response.get_critical_incidents()
# Filter by type
accidents = response.get_incidents_by_type("accident")# Check API availability
availability = client.v7.get_availability()
if availability.available:
print("API is available")
print(f"Coverage areas: {len(availability.coverage_areas)}")# Use v6.3 API (legacy)
response = client.v6.get_flow_bbox(
lat1=51.5,
lon1=-0.13,
lat2=51.51,
lon2=-0.12
)The SDK has 100% test coverage across unit, integration, and e2e tests.
cd here_traffic_sdk
# Install test dependencies
pip install -r requirements-dev.txt
# Run all tests
pytest
# Run with coverage report
pytest --cov=here_traffic_sdk --cov-report=html
# Run specific test categories
pytest tests/unit -v # Unit tests
pytest tests/integration -v # Integration tests
pytest tests/e2e -v -m e2e # E2E testsSee TEST_COVERAGE.md for detailed coverage information.
- Python 3.8+
- requests >= 2.28.0
- Sign up at HERE Platform
- Create an application
- Generate an API Key or OAuth 2.0 credentials
The simplest method. Just provide your API key:
client = HereTrafficClient(api_key="YOUR_API_KEY")For enhanced security, use OAuth 2.0:
from here_traffic_sdk import HereTrafficClient, AuthMethod
client = HereTrafficClient(
access_key_id="YOUR_ACCESS_KEY_ID",
access_key_secret="YOUR_ACCESS_KEY_SECRET",
auth_method=AuthMethod.OAUTH
)The OAuth token is automatically managed and refreshed as needed.
See Authentication Guide for detailed information.
here-sdk/
βββ here_traffic_sdk/ # Python SDK package
β βββ here_traffic_sdk/ # Main SDK module
β β βββ __init__.py # Package exports
β β βββ client.py # Main client
β β βββ auth.py # Authentication
β β βββ v7.py # API v7 client
β β βββ v6.py # API v6.3 client
β β βββ v3.py # API v3 client
β β βββ models.py # Response models
β βββ tests/ # Test suite
β β βββ unit/ # Unit tests
β β βββ integration/ # Integration tests
β β βββ e2e/ # E2E tests
β βββ examples/ # Usage examples
β βββ setup.py # Package setup
β βββ requirements.txt # Dependencies
β βββ README.md # SDK documentation
βββ docs/ # API documentation
β βββ all_endpoints.md # Endpoint reference
β βββ authentication.md # Auth guide
β βββ README.md # Docs index
βββ README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
# Clone the repository
git clone https://github.com/yourusername/here-traffic-sdk.git
cd here-traffic-sdk
# Install in development mode
cd here_traffic_sdk
pip install -e .
# Install test dependencies
pip install -r requirements-dev.txt
# Run tests
pytestCode License: GNU Affero General Public License v3.0 (AGPL-3.0)
Documentation License: Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
- Source code is licensed under AGPL-3.0
- Documentation, README files, and all non-code content is licensed under CC BY-SA 4.0
- HERE Developer Portal: https://developer.here.com
- Traffic API Documentation: https://developer.here.com/documentation/traffic
- Traffic Incidents Guide: https://developer.here.com/documentation/traffic/dev_guide/topics/traffic-incidents.html
- Authentication Guide: https://developer.here.com/documentation/authentication
- HERE Platform: https://platform.here.com
For issues and questions:
- Check the official HERE documentation
- Review the SDK documentation
- Check examples
- Open an issue on GitHub
- Traffic flow data updated every minute
- Traffic incident data updated every two minutes
- Coverage across 70+ countries
- 13+ million kilometers of roads
- Shape Points - Coordinate-based location referencing
- TMC - Traffic Message Channel standard
- OLR - OpenLR Location Referencing
- Circle filters (latitude, longitude, radius)
- Bounding box filters
- Corridor/polyline filters
TrafficFlowResponse- Flow data with helper methodsTrafficIncidentResponse- Incident data with filteringAvailabilityResponse- Availability information
- β 100% API Coverage - All documented endpoints implemented
- β 100% Test Coverage - Unit, integration, and e2e tests
- β Production Ready - Error handling, type hints, documentation
- β Well Maintained - Comprehensive documentation and examples
Made with β€οΈ for the HERE Technologies community