Opened 9 years ago

Closed 7 years ago

#3911 closed enhancement (fixed)


Reported by: Christophe Benz Owned by: rails-dev@…
Priority: minor Milestone: Wishlist
Component: api Version:
Keywords: Cc:


I would like to access the OSM API with JSON / JSONP instead of XML to use data from a full-JavaScript? client.

For modern browsers, it would be useful to implement CORS (cross-origin resource sharing) :

I did not find any discussion about it on the mailing list or in another ticket.

API v0.7 mentions geoJSON [1]. I think that outputting the same schema in JSON than XML is possible, but geoJSON is not the same problem. I would like simple JSON (and JSONP) that mimics the XML schema.


Change History (8)

comment:1 Changed 9 years ago by Tom Hughes

Milestone: Wishlist

And I'd like a Pony - are you offering to provide one?

If your proposing to offer patches to implement this then fine, if you're not then this is basically just you begging somebody else to do a whole lot of work to make your life easier and isn't really helpful.

I'm also a bit confused by the CORS thing - that site implies that all major browsers already support it but my understanding was that the attempt to standardise cross domain access for XHR had faltered and Firefox at least has never supported it in any release version. It was supported in some betas or something I think but was never released.

comment:2 Changed 9 years ago by Tom Hughes

Oh I should also add that the API 0.7 page you reference is basically a giant joke and should in no circumstances be read as a serious discussion of what might be in API 0.7 although support for alternative output formats is actually a reasonable candidate. Indeed that doesn't even need to wait for a new API version.

comment:3 Changed 9 years ago by Christophe Benz

Great ! So you seem to accept a patch doing JSON / JSONP. I was afraid this idea was rejected so I wanted to ask first.

Someone made some work in 2009 : . The patches, as far as I can see, was never merged. I don't know whether he submitted his patches.

By the way I don't ask anyone to do the job, I just use the bugtracker to register a wish. I surely could implement it, even if my rails skills are nearly null :-)

About CORS, according to wikipedia (, it is implemented in Gecko 1.9.1 (Firefox 3.5). But I agree that for the moment it is quite experimental.

Thanks for the information about the API 0.7 wiki page. Is there any more relevant information source ?

comment:4 Changed 9 years ago by Christophe Benz

Oops, here is the link :

It outputs a result like that :

What do you think about these patches ?

If it fits, I'll create a git branch directly mergeable.

comment:5 Changed 9 years ago by Tom Hughes

Well that page appears to document adding it to (a) the map call, which is no longer handled in ruby and (b) a "geohash" call which does not exist, and never has existed, in our code base.

For the map call any work needs to be done in cgimap, though for compatibility we may want to make the ruby code do it as well. Note that Matt Amos has already been working on multi-format output for cgimap though so you should talk to him about that.

For other calls the work would (for now) need to be in the rails code, although many of the read calls are likely to move to cgimap in due course.

comment:6 Changed 9 years ago by amm

In case it helps, Matt's work on the multi-format cgimap can be found at in the content-types branch.

That branch also already contains a number of further read calls (although not all), but non of that is deployed yet.

comment:7 Changed 9 years ago by Tom Hughes

Owner: changed from Tom Hughes to rails-dev@…

comment:8 Changed 7 years ago by iandees

Resolution: fixed
Status: newclosed

CORS headers have been added in the appropriate places. JSON is coming in the near future.

Note: See TracTickets for help on using tickets.