1

When i run the program it gave me upto 50 records/results so i create an 'offset' which will give me more than 50 then i run the code again and the result appear are same, only get 50 records not more than that.

import requests
import json
import pandas as pd

api_key = 'jdfhdf......'
headers = {'Authorization': 'Bearer %s' % api_key}
search_api_url = 'https://api.yelp.com/v3/businesses/search'
parameters = {
        'term': 'Food',
        'location': 'Atlanta',
        'limit': '50',
        'offset': 1000
    }
req = requests.get(search_api_url, headers=headers, params=parameters)
parsed = json.loads(req.text)
businesses = parsed["businesses"]
cols= list(businesses[0].keys())
data = pd.DataFrame(columns=cols)
for biz in businesses:
    data = data.append(biz, ignore_index=True)
    print(data)
    data.to_csv('sample.csv')
lonewolf_7
  • 39
  • 4
  • pls check if the intention to write to CSV is okay? should not it be outside of for loop ? – simpleApp May 02 '21 at 15:41
  • not having problem with csv whether it's outside the loop or not, it's the 'data' records that is not responding more than 50 records – lonewolf_7 May 02 '21 at 15:56
  • try this [solution](https://stackoverflow.com/questions/35525994/how-to-request-more-than-20-results-from-yelp-api) , it uses offset parameter. – simpleApp May 02 '21 at 16:43
  • i checked it and i can get only 1000 records not more than that and btw thanks. – lonewolf_7 May 02 '21 at 18:12

0 Answers0