Request: Can I request and consume Streetmix views via REST API?


Hello! Awesome site!

I work for a DOT and we would love it if we could pass our centerline lane inventory to your site via a RESTful interface. Specifically, I would like to pass a request object that would contain all the attributes that Streetmix would need to generate a street cross-section.

I would pass something like this:

payload = {"streetWidth": 24,
       "streetName": "My Cool Street",
       "locations": [
              "index" : 0,  
              "type" : "Sidewalk", 
              "width" : 1.8,
              "facing" : 'inbound',  
              "elevation" : 'elevated', 
              "density" : 'normal',               
              "index" : 1,  
              "type" : "ParkingLane", 
              "width" : 2.4,
              "facing" : 'perpendicular',  
              "elevation" : 'normal',
              "index" : 2,  
              "type" : "ThroughLane",
              "width" : 3.8,
              "facing" : 'inbound',  
              "elevation" : 'normal', 
              "hasSharrow" : 'yes',
              "laneType" : 'car'

As a return, it would be nice to have either of the two returned:

  1. An iframe-friendly (and interactive) embeddable link to the resulting Streetmix.
  2. A static image of the resulting Streetmix.


This is not a full answer but at least a step in the right direction, I wrote a proof of concept app that does the opposite - takes an existing Streetmix street JSON and parses it to create a 3D visualization.

The relevant parsing code in this file:

I heavily referenced this Streetmix page which outlines all the possible segments:

I learned a few things:

In theory to accomplish what you’re suggesting you’d need to (a) authenticate with, (b) create a new street object and then populate it at the same time or as a separate step. As such it may make more sense to fork the Streetmix project to your own repo so you can spin up a local version and get direct access to the API without needing to figure out how to remotely authenticate. I’m not sure the service was intended for remote programatic API access.


@kfarr - you just blew my mind. That is almost exactly what I have in mind to do. Thank you so much for the suggestion - I will definitely give this a spin.


If you’re able to spin this up in your own environment then you could write another script that directly injects the JSON that represents your City records into the MongoDB database in the appropriate format that Streetmix will then simply render. Per the above instructions you can introspect the json output of some existing Streetmix designs you have to see how it works.

Otherwise you’ll need to dive into the Express backend app of Streetmix to understand how to make write requests. I’m not familiar with the codebase but I’m sure others on this forum are.