Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't Yelp returning all of the results?

I am using the Business Search function in the Yelp Fusion Api.

Why can't I seem to get all of the businesses?

Here is an example:

When I make this request, it returns a the first 20 results and a total property of 485.

https://api.yelp.com/v3/businesses/search?limit=20&term=childcare&location=NY

However, if I add an offset, it doesn't return any results. Even though it should return results 450-470.

https://api.yelp.com/v3/businesses/search?limit=20&term=childcare&location=NY&offset=450

Here is the output after adding the offset:

{
  "businesses": [],
  "total": 485,
  "region": {
    "center": {
        "longitude": -73.99429321289062,
        "latitude": 40.70544486444615
    }
  }
}
like image 691
Jack Fairfield Avatar asked Aug 07 '18 15:08

Jack Fairfield


1 Answers

The API doesn't return the correct "total" number of results available. Try loading https://api.yelp.com/v3/businesses/search?limit=20&offset=330&term=childcare&location=NY - this is the last page of results I was able to find, at offset 330. If you change the offset to 350, no businesses will be returned.

Seems like you'll have to scan through the list from the front until you stop getting businesses back in your results since the total is unreliable.

like image 128
Zach Bloomquist Avatar answered Nov 20 '22 03:11

Zach Bloomquist