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
}
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With