API will not return correctly named places with /places/autocomplete

Platform (Android, iOS, Website): API v1

URLs (aka web addresses) of any relevant observations or pages:
https://api.inaturalist.org/v1/places/autocomplete?q=blue%20mountains

Description of problem:
The API operation /places/autocomplete/ does not return all places that should match the search query.

For example, searching q=blue%mountains returns these names:

      "name": "Blue Mountains",
      "name": "Phawngpui (Blue Mountain",
      "name": "Scenic Reserve - Lietze (Blue Mountains) Bushside Road",
      "name": "Blue Ridge Mountains",
      "name": "East Blue Mountain Spring",
      "name": "Blue Mountain at Carlisle Gap",
      "name": "Blue Mountain at West Licking Creek",
      "name": "Blue Mountain at Whitsel Trail",
      "name": "Blue Mountain at Slip Rock #2",
      "name": "Blue Mountain at Hissing Rocks",

But it does not return a place named “Blue Mountains National Park, NSW, AU”. To return THAT name, I need to specifically look for q=Blue%20Mountains%20National%20Park:

      "name": "Blue Mountains National Park, NSW, AU",

The autocomplete endpoint will return Blue Mountains National Park, NSW, AU, but it doesn’t guarantee results in a particular order, and it’s not in the first 10 results. In fact, it’s not even in the first 20 results, which is the maximum you can ask for. The only way to get it from the autocomplete endpoint is to order the results by area, and ask for at least 12 results: https://api.inaturalist.org/v1/places/autocomplete?q=blue%20mountains&order_by=area&per_page=12

I don’t think the developers intended for this endpoint to be used in this way, so I doubt they will consider this a bug. I think they would probably recommend that you instead use the universal search endpoint with a place filter, where it’s the third result: https://api.inaturalist.org/v1/search?q=blue%20mountains&sources=places

1 Like

You may have better luck with the main /search endpoint:
https://api.inaturalist.org/v1/search?q=blue%20mountains&sources=places

“Blue Mountains National Park, NSW, AU” is the 3rd result.

Edit: @jwidness beat me to it!

2 Likes

Thank you, this is very helpful! The /places/autocomplete operation didn’t list per-page as an argument, so I didn’t realise I could use it. But even better, the search operation returns a lot more results to me. It seems like the API docs need some expansion!

1 Like