mypy-boto3-geo-routes Type Annotations

1.42.81 · active · verified Sat Apr 11

This library provides comprehensive type annotations for the AWS Boto3 LocationServiceRoutesV2 service. It is part of the mypy-boto3 project, which offers extensive stub packages for all boto3 services, generated by `mypy-boto3-builder`. The project is actively maintained, with new versions (currently 1.42.81) released frequently to align with upstream boto3 updates and AWS API changes.

Warnings

Install

Imports

Quickstart

Demonstrates initializing a type-hinted AWS LocationServiceRoutesV2 client and performing a basic `calculate_route` operation. Note that `mypy-boto3-geo-routes` provides only type stubs; the actual `boto3` library must be installed and configured for runtime execution with valid AWS credentials.

import boto3
from mypy_boto3_location_service_routes_v2 import LocationServiceRoutesV2Client
from mypy_boto3_location_service_routes_v2.type_defs import CalculateRouteRequestRequestTypeDef

# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)

# Initialize the boto3 client with type annotations
client: LocationServiceRoutesV2Client = boto3.client("location-service-routes-v2")

# Example: Calculate a route. Replace with actual data and coordinates.
# For a full list of parameters, refer to AWS Boto3 documentation.
request_params: CalculateRouteRequestRequestTypeDef = {
    "CalculatorName": "ExampleRouteCalculator", # Must be an existing calculator name in your AWS account
    "DeparturePosition": [10.0, 20.0], # Example: [longitude, latitude]
    "DestinationPosition": [11.0, 21.0], # Example: [longitude, latitude]
    "TravelMode": "Car",
    "DepartureTime": "2024-01-01T00:00:00Z" # ISO 8601 format
}

try:
    response = client.calculate_route(**request_params)
    print(f"Calculated Route Summary: {response['Summary']}")
    # Example output: Calculated Route Summary: {'DataSource': 'Esri', 'Distance': 1.23, 'DurationSeconds': 60.0}
except client.exceptions.ResourceNotFoundException as e:
    print(f"Error: {e}. Ensure 'ExampleRouteCalculator' exists and is correctly configured in AWS Location Service.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →