I would like to retrieve reviews for a clinic in New York via the Yelp API. However, the API only seems to only return the first three reviews.
My code
# Finding reviews for a particular clinic
import http.client
import json
import urllib.parse
api_key= 'MY API KEY'
API_HOST = 'https://api.yelp.com/reviews'
SEARCH_PATH = '/v3/businesses/search'
BUSINESS_PATH = '/v3/businesses/'
# Business ID will come after slash.
headers = {
'Authorization': 'Bearer %s' % api_key,
}
#need the following parameters (type dict)
params = {'name':'MinuteClinic', 'address1':'241 West 57th St', 'city':'New York', 'state':'NY', 'country':'US'}
param_string = urllib.parse.urlencode(params)
conn = http.client.HTTPSConnection("api.yelp.com")
conn.request("GET", "/v3/businesses/matches/best?"+param_string, headers=headers)
res = conn.getresponse()
data = res.read()
data = json.loads(data.decode("utf-8"))
print(data)
b_id = data['businesses'][0]['id']
r_url = "/v3/businesses/" + b_id + "/reviews" #review request URL creation based on business ID
conn.request("GET",r_url,headers=headers)
rev_res = conn.getresponse() #response and read functions needed else error(?)
rev_data = rev_res.read()
yelp_reviews = json.loads(rev_data.decode("utf-8"))
print(yelp_reviews)
print(len(yelp_reviews))
Is there a way to get all the reviews? Thank you so much.