NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I want to get image from "" or "" with Python.

I tried this command.

import requests

url = "" <br />
r =,{'mapnik_format': 'png', 'minlon': 135.74, 'minlat': 35.011, 'maxlon': 135.75, 'maxlat': 35.014, 'format': 'mapnik', 'mapnik_scale': 30000})

but r is Response [400] and r.content is this

<p>Missing or invalid token</p>

Why I can't get image? How should I do?

asked 04 Jan '17, 05:35

taki_'s gravatar image

accept rate: 0%

edited 04 Jan '17, 07:59

scai's gravatar image

scai ♦

The export facility on the web site is not meant to be used programmatically. (See which says "Calls to /cgi-bin/export may only be triggered by direct end-user action." - even though you're not calling /cgi-bin/export this is the same thing.)

So even if the problem you are seeing could be fixed, you'd be using the interface in disregard of the policy.

Generally the best and most reliable way to generate static map images is to run your own rendering server - that way you can make as many requests as you like and you're not killing anyone else's server with it. If you absolutely must use a hosted service, have a look at but be aware that the services listed there are not suitable for massive use either.

permanent link

answered 04 Jan '17, 09:53

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Oh, I see. Thank you.

(10 Jan '17, 13:19) taki_

Well, the same error occurs from the web gui when trying to export a page, to any format.

(29 Mar '17, 22:38) quazgar

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 04 Jan '17, 05:35

question was seen: 4,188 times

last updated: 29 Mar '17, 22:38

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum