0

I am learning about YELP APIs currently, and want to execute Business Search, but i am stuck with error 400 (HTTP 400 - Bad request). Following online course, my code (runned in virtual environment) should return error 401 (HTTP 401) (and then we provide created yelp app id and key etc.), but i am getting error 400 and can't find a way to solve this, so i get the error 401 and can continue...

Here is my code, it is super-simple and i checked for grammer mistakes and can't find one. I am looking for answer for few hours and really starting lose myself.... Could someone please help me?

import requests

response = requests.get("https://api.yelp.com/v3/businesses/search") # to send GET (to read) request to an endpoint.
print(response)

Outcome when running code:

<Response [400]>

Please let me know what more information you need to help me out. I am a complete beginner here and begging for help.

1 Answers1

0

According to the Yelp documentation, you are required to include query parameters of either (1) location, or (2) latitude and longitude. It looks like your request is missing those parameters.

https://www.yelp.com/developers/documentation/v3/business_search

See below for example:

import requests

response = requests.get("https://api.yelp.com/v3/businesses/search?latitude=37.786882&longitude=-122.399972") # to send GET (to read) request to an endpoint.
print(response)
benjuhn
  • 96
  • 3