Skip to main content

Python client for the Arizona 511 traveler information API

Project description

az511-client

PyPI version Python versions License: MIT

Python client for the Arizona 511 traveler information API.

Installation

pip install az511-client

Quick Start

from az511 import AZ511Client

client = AZ511Client(api_key="your_key_here")

cameras = client.get_cameras()
for cam in cameras:
    print(cam.roadway, cam.location, cam.latitude, cam.longitude)
    for view in cam.views:
        print("  ", view.url)

Authentication

Get a free API key at https://www.az511.com/my511/register.

Pass it explicitly or set the AZ511_API_KEY environment variable:

export AZ511_API_KEY=your_key_here
# reads AZ511_API_KEY automatically from the environment
client = AZ511Client()

A .env file in the working directory is also supported (via python-dotenv):

AZ511_API_KEY=your_key_here

Available Methods

Method Returns Description
get_cameras() list[Camera] All traffic cameras
get_weather_stations() list[WeatherStation] All roadside weather stations
get_alerts() list[Alert] Active traveler alerts
get_rest_areas() list[RestArea] Rest area status and amenities
get_events() list[Event] Active traffic events and roadwork
get_message_boards() list[MessageBoard] Variable message signs (VMS)
get_wzdx() WZDxFeatureCollection Work zone data (GeoJSON, WZDx 4.x)

All model classes are importable from az511.models:

from az511.models import (
    Camera, CameraView,
    WeatherStation,
    Alert,
    RestArea,
    Event, EventRestrictions,
    MessageBoard,
    WZDxFeatureCollection, WZDxFeature, WZDxProperties,
)

Error Handling

from az511 import AZ511Client
from az511.exceptions import AuthError, RateLimitError, APIError

client = AZ511Client()

try:
    events = client.get_events()
except AuthError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limit hit — wait 60 seconds and retry")
except APIError as e:
    print(f"API error {e.status_code}: {e}")

Rate Limits

The AZ511 API allows 10 requests per 60 seconds. Exceeding this raises RateLimitError (HTTP 429). The client does not throttle automatically — callers are responsible for pacing requests.

Development

git clone https://github.com/joelrberry/az511-client
cd az511-client
python -m venv .venv
.venv\Scripts\activate          # Windows
# source .venv/bin/activate     # macOS/Linux
pip install -e ".[dev]"
cp .env.example .env            # add your AZ511_API_KEY
pytest

License

MIT — see LICENSE.

Project details


Download files

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

Source Distribution

az511_client-0.1.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

az511_client-0.1.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file az511_client-0.1.1.tar.gz.

File metadata

  • Download URL: az511_client-0.1.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for az511_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ce7247208e666899749a8549fb26f379df0c64fececfdbe1fd62958dfced1397
MD5 cbd4e6b31bced0a5d74071fb899a7904
BLAKE2b-256 743da151679d4b173e7e5142acb665781f19dc70e597d9d35eeb8ad0015e1cf8

See more details on using hashes here.

File details

Details for the file az511_client-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: az511_client-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for az511_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 365d761468e874b559b0e5c50ea5525d1aa89096ce97cf76b627410589c8feed
MD5 6ade6da5352ccb343fa79450b86be6b3
BLAKE2b-256 d4d2963ccf49292f5659a896b316c3f39cf96d482d130f0bffe46ea612dafd27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page