From 3655bde9a73673c4a6b0ef103f45c04a31a085b8 Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Fri, 20 Sep 2024 15:00:15 +0500 Subject: [PATCH] 1.0.7 --- rocketapi/instagramapi.py | 68 ++++++++++++++++++++++++++++++++++----- setup.py | 4 +-- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/rocketapi/instagramapi.py b/rocketapi/instagramapi.py index 272c9e4..faa500e 100644 --- a/rocketapi/instagramapi.py +++ b/rocketapi/instagramapi.py @@ -34,13 +34,21 @@ def request(self, method, data): elif response["response"]["status_code"] == 404: raise NotFoundException("Instagram resource not found") else: - raise BadResponseException("Bad response from Instagram") - raise BadResponseException("Bad response from RocketAPI") + raise BadResponseException( + f"Bad response from Instagram ({method}: {response['response']['status_code']})" + ) + raise BadResponseException(f"Bad response from RocketAPI ({method})") def search(self, query): """ Search for a specific user, hashtag or place. + As of September 2024, we no longer recommend using this method, as it now only returns a maximum of 5 users and leaves the places and hashtags arrays empty. Instead, please use the separate methods: + - `search_users` + - `search_hashtags` + - `search_locations` + - `search_audios` + Args: query (str): The search query @@ -76,7 +84,7 @@ def get_user_media(self, user_id, count=12, max_id=None): Args: user_id (int): User id - count (int): Number of media to retrieve (max: 50) + count (int): Number of media to retrieve (max: 12) max_id (str): Use for pagination You can use the `max_id` parameter to paginate through the media (take from the `next_max_id` field of the response). @@ -179,7 +187,7 @@ def get_user_followers(self, user_id, count=12, max_id=None): Args: user_id (int): User id - count (int): Number of users to return (max: 100) + count (int): Number of users to return (max: 50) max_id (str): Use for pagination You can use the `max_id` parameter to paginate through followers (take from the `next_max_id` field of the response). @@ -287,14 +295,14 @@ def get_media_info_by_shortcode(self, shortcode): def get_media_likes(self, shortcode, count=12, max_id=None): """ - Retrieve media likes by media shortcode. + Retrieve up to 1000 media likes by media shortcode. Args: shortcode (str): Media shortcode - count (int): Number of likers to return (max: 50) - max_id (str): Use for pagination + count (int): Not supported right now + max_id (str): Not supported right now - You can use the `max_id` parameter to paginate through likers (take from the `next_max_id` field of the response). + Pagination is not supported for this endpoint. For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes """ @@ -505,3 +513,47 @@ def get_user_about(self, user_id): For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_about """ return self.request("instagram/user/get_about", {"id": user_id}) + + def search_users(self, query): + """ + Search for a specific user (max 50 results) + + Args: + query (str): The search query + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/search + """ + return self.request("instagram/user/search", {"query": query}) + + def search_hashtags(self, query): + """ + Search for a specific hashtag (max 20 results) + + Args: + query (str): The search query + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/hashtag/search + """ + return self.request("instagram/hashtag/search", {"query": query}) + + def search_locations(self, query): + """ + Search for a specific location (max 20 results) + + Args: + query (str): The search query + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/location/search + """ + return self.request("instagram/location/search", {"query": query}) + + def search_audios(self, query): + """ + Search for a specific audio (max 10 results) + + Args: + query (str): The search query + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/audio/search + """ + return self.request("instagram/audio/search", {"query": query}) diff --git a/setup.py b/setup.py index e66fc63..d8ab8c7 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setuptools.setup( name="rocketapi", - version="1.0.6", + version="1.0.7", author="RocketAPI", author_email="developer@rocketapi.io", description="RocketAPI Python SDK", packages=["rocketapi"], url="https://github.com/rocketapi-io/rocketapi-python", - download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.6.tar.gz", + download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.7.tar.gz", install_requires=["requests"], )