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

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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file nysdotapi-1.0.1.tar.gz.

File metadata

  • Download URL: nysdotapi-1.0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for nysdotapi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bd5ab572700cbb97436d8f12270ab4d5bd8313f077ef05521f12baaca0fccb30
MD5 c123aa5a13e1eea0d810784fa8734141
BLAKE2b-256 b3dfaa68edec274a6209ab65641cfa5815fce1503c2c22dcdd92d41b065ce6e0

See more details on using hashes here.

File details

Details for the file nysdotapi-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: nysdotapi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for nysdotapi-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5fd242a4d269d60490b6754644b427ec5858e439b1382121a6d35674d2c02d67
MD5 c714f48719419533e83cdb86959352f8
BLAKE2b-256 59b8c28928fc718482973346e011ea8ba7aa1d2694695dd5a0d0461264c231b3

See more details on using hashes here.

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