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


OSM has an API to query data. Like this:,51.450317,7.016477,51.452105

However, you can't do this query from javascript, because this would violate the "cross-domain policy". If I understood it right, OSM could remove this policy by adding these HTTP headers to the API answer:

response['Access-Control-Allow-Origin'] = "*" response['Access-Control-Allow-Methods'] = "POST, GET, OPTIONS" response['Access-Control-Allow-Headers'] = "X-Requested-With"

(Taken from Stackoverflow-question "Cross domain POST query using Cross-Origin Resource Sharing getting no data back")

My questions: 1. Is this limitation (as it currently is) intentional? 2. Would be possible for you to add these headers to support js queries? (Please?)

asked 12 Sep '12, 09:41

tt40's gravatar image

accept rate: 0%

edited 13 Sep '12, 07:50

NicolasDumoulin's gravatar image


You can use Overpass API instead. Just replace


So you get e.g.,51.450317,7.016477,51.452105

Overpass API sets a cross-origin header.

The rationale behind this is that the OSM main API is for editing, not for data reading. By contrast, the mirrors (one of which is Overpass API) serve beside a small time lag the same data, are intended for read only operations, and usually answer much faster.

permanent link

answered 12 Sep '12, 14:07

Roland%20Olbricht's gravatar image

Roland Olbricht
accept rate: 36%


(12 Sep '12, 14:10) tt40

In 2021, the OSM API is setting CORS header! For example:

const r = await fetch("");
const note = await r.json();
permanent link

answered 02 Apr '21, 08:03

darthwalsh's gravatar image

accept rate: 0%

I don't know anything about this headers features and if they can be fixed in the HTTP response. But, there is a classical workaround: you can put a proxy script (php or python for example( on your webserver that will download the data and serve it locally. You can find some examples on the web, like mine.

permanent link

answered 12 Sep '12, 09:56

NicolasDumoulin's gravatar image

accept rate: 13%

Good point, I should have thought of that myself. Do I need a registration or API key? I don't want to be blocked suddenly if I do too many queries...


If anybody knows the answers to the original questions, I'd still be interested to solve this without a proxy. Might be useful for other JS developers, too.

(12 Sep '12, 10:01) tt40

There is an API usage policy - it's the usual issue of shared resources. Depending on what you actually want to do, there may well be better alternatives to hitting the API directly.

(12 Sep '12, 11:02) SomeoneElse ♦

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: 12 Sep '12, 09:41

question was seen: 7,297 times

last updated: 02 Apr '21, 08:03

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