nysdotapi 1.0.1

Creator: bradpython12

Last updated:

Add to Cart

Description:

nysdotapi 1.0.1

New York State Department of Transportation API




Installation
pip install nysdotapi

Authentication

Visit the 511 NY website and create a new account
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

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.