https://github.com/ryanrudes/traffic
NYS DOT Python API
https://github.com/ryanrudes/traffic
camera department-of-transportation feed live ny road stream street traffic transportation video
Last synced: 28 days ago
JSON representation
NYS DOT Python API
- Host: GitHub
- URL: https://github.com/ryanrudes/traffic
- Owner: ryanrudes
- License: mit
- Created: 2023-08-15T19:44:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-18T01:56:00.000Z (about 2 years ago)
- Last Synced: 2025-09-02T03:55:26.453Z (about 1 month ago)
- Topics: camera, department-of-transportation, feed, live, ny, road, stream, street, traffic, transportation, video
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# New York State Department of Transportation API
[](https://pypi.python.org/pypi/nysdotapi/)
[](https://pypi.python.org/pypi/nysdotapi/)
[](https://pypi.python.org/pypi/nysdotapi/)
## Installation
```bash
pip install nysdotapi
```## Authentication
1. Visit the 511 NY [website](https://511ny.org/my511/register) and create a new account
2. Login to your account and request an API key [here](https://511ny.org/developers/help)## Example
The following code cycles through live feeds of various traffic cameras at random.```python
from traffic import APIimport random
import cv2api = API("")
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
```