8

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
    }
  }
}
brooksrelyt
  • 3,482
  • 4
  • 22
  • 42
Jack Fairfield
  • 1,510
  • 16
  • 23

2 Answers2

3

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.

Zach Bloomquist
  • 3,805
  • 21
  • 36
0

I had the same problem, and I've discovered that if you don't set the "limit" parameter, it will default to 20. However, I have also discovered that the maximum you can set "limit" to is 50, and when I did that I had 50 results instead of the 20 I had when I did not set the "limit" parameter.

In my case, I plan to now narrow my search radius and run a script that will call many different areas with individual URLs in order to get around this. Let me know if this is also what you experience.