[openstreetmap/openstreetmap-website] Add notes multi fetch API call (PR #3707)

Anton Khorev notifications at github.com
Wed Sep 21 12:08:05 UTC 2022


An API call to fetch several notes at once by their ids, similar to [the elements multi fetch call](https://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_/api/0.6/[nodes|ways|relations]?#parameters):

`/api/0.6/notes/fetch?notes=1,2,3`

I named it `fetch` here. If I was to follow a naming convention similar to the elements' call, it should have been named  `/api/0.6/notes?notes`. However `notes` path is already in use, even twice: for bbox queries with GET and for new notes with POST.

## What is it useful for?

If you receive notes from some source other than OSM API they may contain incomplete information or be out of date. That source may be some search engine or some feed for an area. For example, [resultmaps.neis-one.org/osm-notes](https://resultmaps.neis-one.org/osm-notes) has feeds for countries. Unfortunately they don't have coordinates, so if you want to see the notes on the map, you have to get them from the API. The only way to do that is download the notes one by one by their ids. That's a lot of requests because the feeds may contain hundreds of notes. But there are API calls already that can send hundreds of notes in one response: bbox and search queries. And bbox calls are routinely made when notes layer is turned on. So there's nothing in principle that prevents fetching multiple notes in one request. If you are already committed to downloading a bunch of notes by their ids, it will be faster and less taxing for the API to get all of the notes in one call. Of course there's a limit to the url length, in this case you'd have to make several calls to get really many notes, but that's still better than making really many calls.

Another possible use is if you have a set of notes selected in some app to work on. Maybe other people also work on these notes. In this case you may want to know if any of these notes was updated. Again, the only way to do this is to download them one by one.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/3707

-- Commit Summary --

  * Add basic note multi fetch
  * Limit notes fetch to visible notes

-- File Changes --

    M app/abilities/api_ability.rb (2)
    M app/controllers/api/notes_controller.rb (20)
    M config/routes.rb (1)
    M test/controllers/api/notes_controller_test.rb (62)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/3707.patch
https://github.com/openstreetmap/openstreetmap-website/pull/3707.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3707
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/3707 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20220921/52afc6e6/attachment.htm>


More information about the rails-dev mailing list