Getting Your 511 Traffic Incidents in the San Francisco Bay Area as a Real Time Streaming API

Continuing our work to make city data more real time, 511 traffic incidentswe have worked to make 511 data streaming using Server-Sent Events (SSE) in any browser or mobile device. 511 data includes a number interesting data sets that can be made real-time, such as transit schedules, but we wanted to focus on traffic data for our next project, so we took the 511 traffic incidents API for the San Francisco Bay Area and proxied it using Streamdata.io, and then published as a simple prototype to show what is possible.

After signing up for an API key, we took the API path for San Francisco/Bay Area 511 traffic events.

Then we plugged the API path into a simple prototype we deployed as a simple streaming web page using the Streamdata.io JavaScript SDK. To create your own, all you have to do is take HTML page below, plug in your own Streamdata.io API key, and you will have a real-time streaming version of the San Francisco/Bay Area traffic incidents API.

In addition to having a Streamdata.io account, with an accompanying API key, you will need to sign up for your own SF 511 API key, which you can then add as a parameter in your Streamdata.io settings. We recommend putting it in your Streamdata.io application settings and keeping out of your JavaScript to minimize the secrets you are publishing on your web page. You can head over to the 511 SF Bay developer page to sign up for your key, and get more information about their API, including documentation, FAQs and other resources.

Not all 511 providers have a JSON API like the San Francisco/Bay Area does, so we’ll be targeting any existing 511 APIs we can find. Next on our target list is New York City, who have a nice set of APIs, but after that, we must hunt for other usable 511 APIs. Most 511 providers will require converting RSS feeds in APIs, and even scraping 511 HTML listings and turn into JSON feeds, before we can proxy and make real-time using Streamdata.io–so we will probably need some local help.

If you’d like to see the 511 traffic data for your city or region be available in a streaming format, feel free to reach out. We’ll see what we can do to help you identify any feeds and see what we can do to make things more real-time when it comes to your local commute.

You can find the demo for this project over at Github, or get at the scripts behind it on the Github repository. It is a pretty basic example of a listing page, but it gets the point across what you can do when streaming 511 traffic data.

**Original source: streamdata.io blog

LEAVE A REPLY

Please enter your comment!
Please enter your name here