0

I am trying to get data from Yelp's API but as the title suggests I am not getting a JSON and I'm not sure what to do. Below is my code

import requests

api_key = 'MY API KEY'

# USING THE YELP BUSINESS SEARCH API: https://www.yelp.com/developers/documentation/v3/business_search
# HEADERS CONTAIN THE API KEY
headers = {'Authorization': 'Bearer {}'.format(api_key), 'content-type': 'application/json'}
search_api_url = 'https://www.yelp.com/developers/documentation/v3/business_search'
params = {
    'term': 'restaurants',
    'location': 'Cincinnati, Ohio',
    'limit': 50
}

# MAKE THE GET CALL WITH A TIME OUT OF 5 SECONDS
response = requests.get(search_api_url, headers=headers, params=params, timeout=5)
print(response.url)
print(response.status_code)
print(response.headers)
  • Do you get any response, and is the `status_code` 200? Try `response.json()` – chrisbyte Aug 01 '21 at 14:46
  • Yes ```status_code``` returned 200. When I tried ```response.json()``` I received this error: ```json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)``` – Brian Mochtyak Aug 01 '21 at 14:50

0 Answers0