Nearby search result per category limit?

hey, is there any way I can limit my nearby search results to one result per category? Right now I’m just hoping to get the nearest of certain points of interest from an origin, but if one point of interest appears frequently, it drowns out the others.

Hi,
Yes, it is possible. To do so, you need to use two parameters:

&limit=

The default value is 10, and you can set it to 1.

The second parameter is:

&categoryset=

You can set this parameter value to category ID.
To see our categories IDs list, you can simply use the POI category endpoint:

https://api.tomtom.com/search/2/poiCategories.json?key=*****

To learn more, you can check out our documentation here

1 Like

Hi Michal,

Thanks for your reply. When I set limit=1 I get one result total instead of one result for each category that I set with &categoryset=.

What I want is only one result for each category that I set, if that makes sense

eg. when I set &categoryset=7326,9374 I only want one result from 7326 and one result from 9374 instead of one result from both.

Thanks.

Oh, sorry, I misunderstood you before.
Unfortunately, this is not possible to show one result per category with more than one category selected.

You would have to make multiple API calls, one for each category.

1 Like

I see, thanks Michal!

Hi Michal , I had another quick question about the nearby search API , is the dist response value a straight line distance ? Or is it via available road

Hi again,
A radius parameter and its response is a straight line from the point you use as your position.