This SDK isn't in sync wtith the current API docs on the website
salcedo opened this issue · 5 comments
salcedo commented
The API docs on https://app.outscraper.com/api-docs mention maps/search-v3
There is no google_maps_search_v3() nor use of maps/search-v3 in the SDK.
google_maps_search() method calls maps/search-v2
ETA on fix?
vlad-stack commented
maps/search-v3 and maps/search-v2 are the same.
What is the actual problem that you have apart from spotting this inconsistency?
salcedo commented
If google_maps_search() method is using maps/search-v2 (aka v3) it should take the parameters listed in the API docs (e.g. coordinates), but it does not.
vlad-stack commented
I see, what specific parameter do you need?
salcedo commented
Needed the coordinates parameter. We got it now. Thanks.
class OutscraperClient:
_api_url = "https://api.app.outscraper.com"
_api_headers = {}
def __init__(self, api_key: str) -> None:
self._api_headers = {"X-API-KEY": api_key, "client": "Python SDK"}
def google_maps_search_v3(
self,
query: Union[list, str],
limit: int = 20,
drop_duplicates: bool = False,
coordinates: str = None,
skip_places: int = 0,
language: str = "en",
region: str = None,
enrichment: list = None,
fields: Union[list, str] = None,
# async_request: bool = False,
ui: bool = False,
# webhook: str = None,
) -> Union[list, dict]:
# queries = as_list(query)
# wait_async = async_request or (len(queries) > 10 and limit > 1)
params = {
"query": as_list(query),
"limit": limit,
"dropDuplicates": "true" if drop_duplicates else "false",
"skipPlaces": skip_places,
"language": language,
# "async": "true" if async_request else "false",
"async": "false",
"ui": "true" if ui else "false",
}
if coordinates:
params["coordinates"] = coordinates
if region:
params["region"] = region
if enrichment:
params["enrichment"] = as_list(enrichment)
if fields:
params["field"] = as_list(fields)
# if webhook:
# params["webhook"] = webhook
response = requests.get(
f"{self._api_url}/maps/search-v3", headers=self._api_headers, params=params
)
if 199 < response.status_code < 300:
return response.json().get("data", [])
else:
raise Exception(f"Outscraper response status code: {response.status_code}")
vlad-stack commented
Ok, updating to v5.0.0 version.
Thank you!