Skip to content

Commit 1121172

Browse files
Update api_client.py to include apple store reviews functionality (#14)
* Update api_client.py to include apple store reviews functionality Based on same code for google map reviews, add wrapper to use apple store reviews API functionality. * Update api_client.py * Update api_client.py --------- Co-authored-by: vlad-stack <[email protected]>
1 parent 9c2919f commit 1121172

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

outscraper/api_client.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def yelp_reviews(self, query: Union[list, str], limit: int = 100, sort: str = 'r
697697

698698
return self._handle_response(response, wait_async, async_request)
699699

700-
def tripadvisor_reviews(self, query: Union[list, str], limit: int = 100,
700+
def tripadvisor_reviews(self, query: Union[list, str], limit: int = 100, cutoff: int = None,
701701
fields: Union[list, str] = None, async_request: bool = False, ui: bool = None, webhook: bool = None
702702
) -> Union[list, dict]:
703703
'''
@@ -723,6 +723,44 @@ def tripadvisor_reviews(self, query: Union[list, str], limit: int = 100,
723723
response = requests.get(f'{self._api_url}/tripadvisor/reviews', params={
724724
'query': queries,
725725
'limit': limit,
726+
'cutoff': cutoff,
727+
'async': wait_async,
728+
'fields': parse_fields(fields),
729+
'ui': ui,
730+
'webhook': webhook,
731+
}, headers=self._api_headers)
732+
733+
return self._handle_response(response, wait_async, async_request)
734+
735+
def apple_store_reviews(self, query: Union[list, str], limit: int = 100, sort: str = 'mosthelpful', cutoff: int = None,
736+
fields: Union[list, str] = None, async_request: bool = False, ui: bool = None, webhook: bool = None
737+
) -> list:
738+
'''
739+
Returns reviews from AppStore apps.
740+
741+
Parameters:
742+
query (list | str): you can use direct links, and IDs of any AppStore app (e.g., https://apps.apple.com/us/app/telegram-messenger/id686449807, id686449807). Using a lists allows multiple queries (up to 250) to be sent in one request and save on network latency time.
743+
limit (int): parameter specifies the limit of reviews to extract from one query.
744+
sort (str): parameter specifies one of the sorting types. Available values: "mosthelpful", "mostrecent".
745+
cutoff (int): parameter specifies the maximum timestamp value for reviews. Using the cutoff parameter overwrites sort parameter to "newest".
746+
fields (list | str): parameter defines which fields you want to include with each item returned in the response. By default, it returns all fields.
747+
async_request (bool): parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
748+
ui (bool): parameter defines whether a task will be executed as a UI task. This is commonly used when you want to create a regular platform task with API. Using this parameter overwrites the async_request parameter to `True`.
749+
750+
Returns:
751+
list: json result
752+
753+
See: https://app.outscraper.com/api-docs#tag/Reviews-and-Comments/paths/~1appstore~1reviews/get
754+
'''
755+
756+
queries = as_list(query)
757+
wait_async = async_request or limit > 499 or len(queries) > 10
758+
759+
response = requests.get(f'{self._api_url}/appstore/reviews', params={
760+
'query': queries,
761+
'limit': limit,
762+
'sort': sort,
763+
'cutoff': cutoff,
726764
'async': wait_async,
727765
'fields': parse_fields(fields),
728766
'ui': ui,

0 commit comments

Comments
 (0)