Google Streetview Static API
It is possible to extract both thumbnails and higher resolution images (tiles) from the Google Streetview service through an unpublished, undocumented API which I will document below. Google have not publicly released this API, but nor have they sought to secure or even obfuscate it in any way. To me, this is about as open an invitation as it gets.
Thumbnails (The Easy Bit)
You might have noticed that more often than not, when viewing a location on Google Maps nowadays you get a little Streetview thumbnail linking to the appropriate location on Google Streetview. If you’ve ever wondered if you could get static streetview imaging out Google for your own use then read on.
Inspection of the image source reveals something quite surprising:
http://cbk0.google.com/cbk?output=thumbnail&w=90&h=68&ll=51.494966,-0.146674
http://cbk0.google.com/cbk?output=thumbnail&w=[WIDTH]&h=[HEIGHT]&ll=[LAT,LNG]
Not exactly cryptic is it. We have a width, a height and a lat/lng pair. Playing with the values of width and height you will find the maximum dimensions available are 416×208 pixels, giving you a full, albeit small, 360 degree panorama of your desired location. You can play with the coordinates too but specifying a location without a streetview panorama will result in a 404 error.
I think I’m panoid…
Each Streetview panorama is uniquely identified by an panoid. I’m pretty sure this is a timecode hash but I haven’t looked into it any further. For the purposes of fetching Streetview images the only important thing to consider is that these are unique ids.
If you’re like me, you’ve been looking at the example above and wondering what other output types there are besides ‘thumbnail’. One of the other options is ‘xml’, which returns some handy metadata for a given location. You can use this data to determine if there is a streetview panorama available at your chosen location.
http://cbk0.google.com/cbk?output=xml&ll=[LAT,LNG]
Example:
http://cbk0.google.com/cbk?output=xml&ll=51.494966,-0.146674
<panorama> <data_properties image_width="13312" image_height="6656" tile_width="512" tile_height="512" pano_id="sLaiF6Jex7mJmNol7tdOoA" num_zoom_levels="3" lat="51.495090" lng="-0.146971" original_lat="51.495098" original_lng="-0.147000"> <copyright>© 2010 Google</copyright> <text>Eccleston Pl</text> <region>London, England</region> <country>United Kingdom</country> <data_flag>1</data_flag> </data_properties> <projection_properties projection_type="spherical" pano_yaw_deg="201.78" tilt_yaw_deg="92.06" tilt_pitch_deg="1.75"/> <annotation_properties> <link yaw_deg="204.7" pano_id="CeutxcyB2V74lfN_fJwRww" road_argb="0x80ffffff"> <link_text>Eccleston Pl</link_text> </link> <link yaw_deg="24.7" pano_id="t_mnKSugTLrQTEnJplXQ3A" road_argb="0x80ffffff"> <link_text>Eccleston Pl</link_text> </link> </annotation_properties> </panorama>
This returns a lot of data, but for now we’ll simply concentrate on the panoid values. Generally there will be three panoids. One as an attribute of the data_properties element and two as the attributes of the two link elements of the annotation_properties element. As far as I can tell the supplemental two panoids relate to the previous and next panorama on the route.
So in this example we end up with a main panoid of “sLaiF6Jex7mJmNol7tdOoA”
Finally we can plug this value into the thumbnail url as follows:
http://cbk0.google.com/cbk?output=thumbnail&w=[WIDTH]&h=[HEIGHT]&panoid=[PID]
http://cbk0.google.com/cbk?output=thumbnail&w=416&h=208&panoid=sLaiF6Jex7mJmNol7tdOoA
Notice how we end up with exactly the same panorama, but at a different offset.
With a little extra work, tying this into the Open Postcode Geocoding API, I came up with a nice little wrapper around this accepting a UK postcode and directly returning the corresponding panorama thumbnail. I’ve added this to my geo webservice and it is callable as follows:
http://geo.jamiethompson.co.uk/streetview/[POSTCODE]_[WIDTH]x[HEIGHT].jpg
Example
http://geo.jamiethompson.co.uk/streetview/SW1W9TQ_416×208.jpg
The high detail tiles
So, you probably noticed some info relating to tiles in the xml data in the previous example. It’s possible to fetch a set of 512 pixel square tiles at various zoom levels for a given panorama using the following request.
http://cbk0.google.com/cbk?output=tile&panoid=[PID]&zoom=[ZOOM]&x=[X]&y=[Y]
[X] and [Y] relate to the horizontal and vertical tile positions, while [ZOOM] relates to the zoom level. If the XML data is to be believed there are 3 zoom levels, but I have found there to be 5. The number of X and Y positions increases with each zoom level. These are zero based.
Zoom Level 0:

Single Tile – X=0, Y=0
Zoom Level 1:

Tile 1 – X=0, Y=0 Tile 2 – X=1, Y=0
Zoom Level 2

4 X positions (0-3), 2 Y positions (0-1)
Zoom Level 3

6 X positions (0-5), 3 Y positions (0-2)
Zoom Level 4

13 X positions (0-12), 7 Y positions (0-6)
Zoom Level 5

26 X positions (0-25), 13 Y positions (0-12)
Demo
I’ve put together a very quick and dirty demo page that displays the tiles re-assembled for any given UK postcode. Be warned, at zoom level 5 this will download 338 512×512 pixel tiles, roughly 7-8MB.
Posted in Web | Tagged with: api, geocoding, Google, postcode, Streetview



May 15th, 2010 at 11:20 pm
Some really nice work here dude, now I just need to find a project to use it on.
May 24th, 2010 at 11:16 pm
Really nice job digging through all of those url requests, and then making good sense of it. Really appreciate the post!
June 7th, 2010 at 2:09 am
Hola, buen post.
¿has usado este método en sitios web de gran carga?
Quiero decir que si google te ha bloqueado el uso de este método
June 7th, 2010 at 2:09 am
Ups, English now
Hi, nice post.
Have you used this method in high-load websites?
I mean if google has blocked the use of this method
June 15th, 2010 at 1:28 pm
For now at least, I don’t think it would be a great idea to rely on this method for anything with a moderate to high load. There’s no official word from Google as such but I’m guessing that if there were it would be along the lines of “Please don’t do this”. Having said that, I keep thinking I might try it out in some non-mission-critical way in a production environment and see what happens.
June 19th, 2010 at 7:33 pm
[...] jamiethompson.co.uk 本站文章除注明转载外,均为本站原创编译 [...]
June 19th, 2010 at 9:19 pm
[...] Via jamiethompson.co.uk [...]
June 20th, 2010 at 11:20 am
but I think you might be violating the google maps/google earth terms of service when you do this – sections 2 and 4 in particular.
http://www.google.com/intl/en_ALL/help/terms_maps.html
June 20th, 2010 at 1:10 pm
[...] reading here: Google Streetview Static API – Jamie Thompson 17 May 2010 | Uncategorized | Trackback | del.icio.us | Stumble it! | View Count : 0 Next Post [...]
June 20th, 2010 at 11:00 pm
@miguel, google won’t block this because it doesn’t do anything they didn’t already allow in the streetviewer. the fuckwit jamie thompson has no idea what he is doing and is just using what is already available claiming it is some discovery
June 21st, 2010 at 5:06 am
[...] Google Streetview Static API – Jamie Thompson I’ve put together a very quick and dirty demo page that displays the tiles re-assembled for any given UK postcode. Be warned, at zoom level 5 this will download 338 512×512 pixel tiles, roughly 7-8MB. (tags: google maps photo) [...]
June 21st, 2010 at 8:01 am
@matt Whoa, hold your horses – and your language. Why so angry? I’m not sure how/where I claimed some kind of discovery. I certainly wasn’t the first person to notice and use the Street View HTTP API, and as I’ve quite clearly demonstrated above it’s really not very complicated.
I think you need to calm down a little. This isn’t meant to be anything more than a very basic tutorial. Please re-read it if you like. I’m clearly not claiming to have ‘discovered’ anything (other than the fact that the XML denotes 3 zoom levels when there are actually 5.. which is no real secret as you can zoom in this far with the flash viewer)
I noticed something I found interesting and shared it with others. If that makes me a ‘fuckwit’ then a fuckwit I most certainly am.
So, um, yeah. WTF?
June 21st, 2010 at 10:30 pm
I may have no use for this whatsoever, but I appreciate the work you put in this.
Ignore that haters.
June 22nd, 2010 at 8:11 pm
[...] are doing great things with free APIs. These Streetview panoramas by Jamie Thompson are highly reminiscent of Hockney’s polaroid collages / History Rambler, photographs of [...]
June 24th, 2010 at 11:17 pm
They are just haters, Jamie Thompson. Let them hate, good job!
June 27th, 2010 at 12:12 pm
This is awesome work Jamie.
You’ve really shown how to leverage the web and all that goes with it.
I will certainly be continuing to follow your work.
Cheers
Stephen
June 30th, 2010 at 8:56 am
nice work, you know there is another param which changes the angle the camera is facing. useful if you want the other side of the road but you only have the co-ords.
yaw=90
east is 90, west is 270, north is 0, south is 180. you can do any number from 0 to 360
July 16th, 2010 at 6:49 am
The post is really helpful Jamie…good work!
July 24th, 2010 at 9:01 am
I attemp to run between panoid.
In the XML you have the nearest panoid. You can get the information of this panoid with.
http://cbk0.google.com/cbk?output=xml&panoid=PID
It’s simple.
August 25th, 2010 at 4:45 pm
as well as yaw, the pitch parameter is also available …
it goes from
pitch=-90 (looking up)
to
pitch=90 (looking down)