Skip to main content

NYS DOT Traffic Camera Python API

Project description

New York State Department of Transportation API

PyPI download month PyPI - Status PyPI GitHub

Installation

pip install nysdotapi

Authentication

  1. Visit the 511 NY website and create a new account
  2. Login to your account and request an API key here

Example

The following code cycles through live feeds of various traffic cameras at random.

from traffic import API

import random
import cv2

api = API("<insert-api-key>")

cameras = api.get_cameras()
print("Cameras:", len(cameras))

while True:
    camera = random.choice(cameras)
    
    try:
        with camera.get_stream() as stream:
            title = "LIVE: " + camera.roadway if camera.roadway else "LIVE"
                
            for i in range(100):
                frame = next(stream)
                
                cv2.imshow(title, frame)
                cv2.waitKey(1)
                
            cv2.destroyAllWindows()
    except KeyboardInterrupt:
        raise
    except StopIteration:
        pass

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

nysdotapi-1.0.1.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

nysdotapi-1.0.1-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

Supported by

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