From 3655bde9a73673c4a6b0ef103f45c04a31a085b8 Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Fri, 20 Sep 2024 15:00:15 +0500 Subject: [PATCH 1/6] 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"], ) From a139016919d7bf424a9742e607268de5795490c1 Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Thu, 24 Oct 2024 12:12:36 +0500 Subject: [PATCH 2/6] 1.0.8 --- rocketapi/instagramapi.py | 36 ++++++++++++++++++++++++++++++++++-- rocketapi/rocketapi.py | 6 +++++- setup.py | 4 ++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/rocketapi/instagramapi.py b/rocketapi/instagramapi.py index faa500e..a327b35 100644 --- a/rocketapi/instagramapi.py +++ b/rocketapi/instagramapi.py @@ -48,6 +48,7 @@ def search(self, query): - `search_hashtags` - `search_locations` - `search_audios` + - `search_clips` Args: query (str): The search query @@ -102,7 +103,7 @@ def get_user_clips(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 `max_id` (!) field of the response). @@ -375,7 +376,7 @@ def get_location_info(self, location_id): """ return self.request("instagram/location/get_info", {"id": location_id}) - def get_location_media(self, location_id, page=None, max_id=None): + def get_location_media(self, location_id, page=None, max_id=None, tab=None): """ Retrieve location media by location id. @@ -383,6 +384,7 @@ def get_location_media(self, location_id, page=None, max_id=None): location_id (int): Location id page (int): Page number max_id (str): Use for pagination + tab (str): Tab name: recent, ranked (default: recent) In order to use pagination, you need to use both the `max_id` and `page` parameters. You can obtain these values from the response's `next_page` and `next_max_id` fields. @@ -393,6 +395,8 @@ def get_location_media(self, location_id, page=None, max_id=None): payload["page"] = page if max_id is not None: payload["max_id"] = max_id + if tab is not None: + payload["tab"] = tab return self.request("instagram/location/get_media", payload) def get_hashtag_info(self, name): @@ -500,6 +504,23 @@ def get_audio_media(self, audio_id, max_id=None): payload["max_id"] = max_id return self.request("instagram/audio/get_media", payload) + def get_audio_media_by_canonical_id(self, audio_canonical_id, max_id=None): + """ + Retrieve audio media by audio canonical id. + + Args: + audio_canonical_id (int): Audio canonical id + max_id (str): Use for pagination + + You can use the `max_id` parameter to paginate through media (take from the `next_max_id` field of the response). + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/audio/get_media_by_canonical_id + """ + payload = {"id": audio_canonical_id} + if max_id is not None: + payload["max_id"] = max_id + return self.request("instagram/audio/get_media_by_canonical_id", payload) + def get_user_about(self, user_id): """ Obtain user details from «About this Account» section. @@ -557,3 +578,14 @@ def search_audios(self, query): For more information, see documentation: https://docs.rocketapi.io/api/instagram/audio/search """ return self.request("instagram/audio/search", {"query": query}) + + def search_clips(self, query): + """ + Search for a specific clip with a caption that includes the query (max 12 results) + + Args: + query (str): The search query + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/search_clips + """ + return self.request("instagram/media/search_clips", {"query": query}) diff --git a/rocketapi/rocketapi.py b/rocketapi/rocketapi.py index 8edd35a..106678e 100644 --- a/rocketapi/rocketapi.py +++ b/rocketapi/rocketapi.py @@ -11,6 +11,7 @@ def __init__(self, token, max_timeout=30): For more information, see documentation: https://docs.rocketapi.io/api/ """ self.base_url = "https://v1.rocketapi.io/" + self.version = "1.0.8" self.token = token self.max_timeout = max_timeout @@ -18,6 +19,9 @@ def request(self, method, data): return requests.post( url=self.base_url + method, json=data, - headers={"Authorization": f"Token {self.token}"}, + headers={ + "Authorization": f"Token {self.token}", + "User-Agent": f"RocketAPI Python SDK/{self.version}", + }, timeout=self.max_timeout, ).json() diff --git a/setup.py b/setup.py index d8ab8c7..2ed5407 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setuptools.setup( name="rocketapi", - version="1.0.7", + version="1.0.8", 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.7.tar.gz", + download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.8.tar.gz", install_requires=["requests"], ) From ef72b4f495f757bd39078bb3ccedcd90cb081ed3 Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Tue, 26 Nov 2024 21:31:27 +0300 Subject: [PATCH 3/6] 1.0.9 --- rocketapi/instagramapi.py | 27 ++++++++++++++++++++++++--- rocketapi/rocketapi.py | 2 +- setup.py | 4 ++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/rocketapi/instagramapi.py b/rocketapi/instagramapi.py index a327b35..ef2689d 100644 --- a/rocketapi/instagramapi.py +++ b/rocketapi/instagramapi.py @@ -312,6 +312,19 @@ def get_media_likes(self, shortcode, count=12, max_id=None): payload["max_id"] = max_id return self.request("instagram/media/get_likes", payload) + def get_media_likes_by_id(self, media_id): + """ + Retrieve up to 1000 media likes by media id. + + Args: + media_id (int): Media id + + Pagination is not supported for this endpoint. + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes_by_id + """ + return self.request("instagram/media/get_likes_by_id", {"id": media_id}) + def get_media_comments(self, media_id, can_support_threading=True, min_id=None): """ Retrieve media comments by media id. @@ -521,13 +534,21 @@ def get_audio_media_by_canonical_id(self, audio_canonical_id, max_id=None): payload["max_id"] = max_id return self.request("instagram/audio/get_media_by_canonical_id", payload) + def get_live_info(self, broadcast_id): + """ + Retrieve live information by broadcast id. + + Args: + broadcast_id (int): Broadcast id + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/live/get_info + """ + return self.request("instagram/live/get_info", {"id": broadcast_id}) + def get_user_about(self, user_id): """ Obtain user details from «About this Account» section. - ⭐️ This method is exclusively available to our Enterprise+ clients. - If you wish to enable it for your account, please get in touch with our support team: https://t.me/rocketapi - Args: user_id (int): User id diff --git a/rocketapi/rocketapi.py b/rocketapi/rocketapi.py index 106678e..6fcafd9 100644 --- a/rocketapi/rocketapi.py +++ b/rocketapi/rocketapi.py @@ -11,7 +11,7 @@ def __init__(self, token, max_timeout=30): For more information, see documentation: https://docs.rocketapi.io/api/ """ self.base_url = "https://v1.rocketapi.io/" - self.version = "1.0.8" + self.version = "1.0.9" self.token = token self.max_timeout = max_timeout diff --git a/setup.py b/setup.py index 2ed5407..04b9e9b 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setuptools.setup( name="rocketapi", - version="1.0.8", + version="1.0.9", 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.8.tar.gz", + download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.9.tar.gz", install_requires=["requests"], ) From 61d7d342dd74f00022f59ec66b2a3f8579d20181 Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Wed, 11 Dec 2024 19:57:42 +0300 Subject: [PATCH 4/6] 1.0.10 --- rocketapi/instagramapi.py | 11 +++++++++++ rocketapi/rocketapi.py | 2 +- setup.py | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rocketapi/instagramapi.py b/rocketapi/instagramapi.py index ef2689d..d482b99 100644 --- a/rocketapi/instagramapi.py +++ b/rocketapi/instagramapi.py @@ -367,6 +367,17 @@ def get_media_id_by_shortcode(self, shortcode): "instagram/media/get_id_by_shortcode", {"shortcode": shortcode} ) + def get_media_id_by_share(self, share): + """ + Get media id by share code (for links like https://www.instagram.com/share/XXXxx356, where XXXxx356 is the share code). + + Args: + share (str): Share code + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_id_by_share + """ + return self.request("instagram/media/get_id_by_share", {"share": share}) + def get_guide_info(self, guide_id): """ Retrieve guide information by guide id. diff --git a/rocketapi/rocketapi.py b/rocketapi/rocketapi.py index 6fcafd9..68ac816 100644 --- a/rocketapi/rocketapi.py +++ b/rocketapi/rocketapi.py @@ -11,7 +11,7 @@ def __init__(self, token, max_timeout=30): For more information, see documentation: https://docs.rocketapi.io/api/ """ self.base_url = "https://v1.rocketapi.io/" - self.version = "1.0.9" + self.version = "1.0.10" self.token = token self.max_timeout = max_timeout diff --git a/setup.py b/setup.py index 04b9e9b..fc632d1 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setuptools.setup( name="rocketapi", - version="1.0.9", + version="1.0.10", 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.9.tar.gz", + download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.10.tar.gz", install_requires=["requests"], ) From 23ada9f4af7df388b52343509cf7e4df45023446 Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Tue, 22 Apr 2025 12:10:20 +0400 Subject: [PATCH 5/6] 1.0.11 --- rocketapi/instagramapi.py | 76 +++++++++++++++++++++++++++++++++------ rocketapi/rocketapi.py | 2 +- setup.py | 4 +-- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/rocketapi/instagramapi.py b/rocketapi/instagramapi.py index d482b99..6aafc78 100644 --- a/rocketapi/instagramapi.py +++ b/rocketapi/instagramapi.py @@ -57,16 +57,30 @@ def search(self, query): """ return self.request("instagram/search", {"query": query}) + def get_web_profile_info(self, username): + """ + Retrieve user web profile information by username. + + Args: + username (str): Username + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_web_profile_info + """ + return self.request( + "instagram/user/get_web_profile_info", {"username": username} + ) + def get_user_info(self, username): """ Retrieve user information by username. + This is an alias for get_web_profile_info. Args: username (str): Username For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_info """ - return self.request("instagram/user/get_info", {"username": username}) + return self.get_web_profile_info(username) def get_user_info_by_id(self, user_id): """ @@ -97,6 +111,24 @@ def get_user_media(self, user_id, count=12, max_id=None): payload["max_id"] = max_id return self.request("instagram/user/get_media", payload) + def get_user_media_by_username(self, username, count=12, max_id=None): + """ + Retrieve user media by username. + + Args: + username (str): Username + 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). + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_media_by_username + """ + payload = {"username": username, "count": count} + if max_id is not None: + payload["max_id"] = max_id + return self.request("instagram/user/get_media_by_username", payload) + def get_user_clips(self, user_id, count=12, max_id=None): """ Retrieve user clips (videos from "Reels" section) by id. @@ -294,24 +326,39 @@ def get_media_info_by_shortcode(self, shortcode): "instagram/media/get_info_by_shortcode", {"shortcode": shortcode} ) - def get_media_likes(self, shortcode, count=12, max_id=None): + def get_media_likes_by_shortcode(self, shortcode): """ Retrieve up to 1000 media likes by media shortcode. Args: shortcode (str): Media shortcode - count (int): Not supported right now - max_id (str): Not supported right now Pagination is not supported for this endpoint. For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes """ - payload = {"shortcode": shortcode, "count": count} - if max_id is not None: - payload["max_id"] = max_id + payload = {"shortcode": shortcode} return self.request("instagram/media/get_likes", payload) + def get_media_likes(self, shortcode, count=12, max_id=None): + """ + Retrieve up to 1000 media likes by media shortcode. + This is an alias for get_media_likes_by_shortcode. + + Note: The parameters count and max_id are kept for backward compatibility but are no longer supported. + + Args: + shortcode (str): Media shortcode + count (int): DEPRECATED - No longer supported + max_id (str): DEPRECATED - No longer supported + + Pagination is not supported for this endpoint. + + For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes + """ + # Ignoring count and max_id parameters as they're no longer supported + return self.get_media_likes_by_shortcode(shortcode) + def get_media_likes_by_id(self, media_id): """ Retrieve up to 1000 media likes by media id. @@ -434,7 +481,7 @@ def get_hashtag_info(self, name): """ return self.request("instagram/hashtag/get_info", {"name": name}) - def get_hashtag_media(self, name, page=None, max_id=None): + def get_hashtag_media(self, name, page=None, max_id=None, tab=None): """ Retrieve hashtag media by hashtag name. @@ -442,6 +489,7 @@ def get_hashtag_media(self, name, page=None, max_id=None): name (str): Hashtag name page (int): Page number max_id (str): Use for pagination + tab (str): Tab name: recent, top, or clips (default: recent) In order to use pagination, you need to use both the `max_id` and `page` parameters. You can obtain these values from the response's `next_page` and `next_max_id` fields. @@ -452,6 +500,8 @@ def get_hashtag_media(self, name, page=None, max_id=None): payload["page"] = page if max_id is not None: payload["max_id"] = max_id + if tab is not None: + payload["tab"] = tab return self.request("instagram/hashtag/get_media", payload) def get_highlight_stories_bulk(self, highlight_ids): @@ -611,13 +661,19 @@ def search_audios(self, query): """ return self.request("instagram/audio/search", {"query": query}) - def search_clips(self, query): + def search_clips(self, query, max_id=None): """ Search for a specific clip with a caption that includes the query (max 12 results) Args: query (str): The search query + max_id (str): Use for pagination + + You can use the max_id parameter to paginate through following (take from the reels_max_id field of the response). For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/search_clips """ - return self.request("instagram/media/search_clips", {"query": query}) + payload = {"query": query} + if max_id is not None: + payload["max_id"] = max_id + return self.request("instagram/media/search_clips", payload) diff --git a/rocketapi/rocketapi.py b/rocketapi/rocketapi.py index 68ac816..fc39713 100644 --- a/rocketapi/rocketapi.py +++ b/rocketapi/rocketapi.py @@ -11,7 +11,7 @@ def __init__(self, token, max_timeout=30): For more information, see documentation: https://docs.rocketapi.io/api/ """ self.base_url = "https://v1.rocketapi.io/" - self.version = "1.0.10" + self.version = "1.0.11" self.token = token self.max_timeout = max_timeout diff --git a/setup.py b/setup.py index fc632d1..278e000 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setuptools.setup( name="rocketapi", - version="1.0.10", + version="1.0.11", 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.10.tar.gz", + download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.11.tar.gz", install_requires=["requests"], ) From 2188d7660350e9bea52c62d0c6d2252e8773bb9b Mon Sep 17 00:00:00 2001 From: RocketAPI Date: Tue, 22 Apr 2025 19:56:06 +0400 Subject: [PATCH 6/6] 1.0.12 --- rocketapi/instagramapi.py | 3 +++ rocketapi/rocketapi.py | 2 +- setup.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rocketapi/instagramapi.py b/rocketapi/instagramapi.py index 6aafc78..3809a21 100644 --- a/rocketapi/instagramapi.py +++ b/rocketapi/instagramapi.py @@ -26,6 +26,9 @@ def request(self, method, data): self.last_response = response self.counter += 1 if response["status"] == "done": + if method in ["instagram/media/get_shortcode_by_id", "instagram/media/get_id_by_shortcode"]: + return response + if ( response["response"]["status_code"] == 200 and response["response"]["content_type"] == "application/json" diff --git a/rocketapi/rocketapi.py b/rocketapi/rocketapi.py index fc39713..02c776e 100644 --- a/rocketapi/rocketapi.py +++ b/rocketapi/rocketapi.py @@ -11,7 +11,7 @@ def __init__(self, token, max_timeout=30): For more information, see documentation: https://docs.rocketapi.io/api/ """ self.base_url = "https://v1.rocketapi.io/" - self.version = "1.0.11" + self.version = "1.0.12" self.token = token self.max_timeout = max_timeout diff --git a/setup.py b/setup.py index 278e000..1dbcf2b 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ setuptools.setup( name="rocketapi", - version="1.0.11", + version="1.0.12", 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.11.tar.gz", + download_url="https://github.com/rocketapi-io/rocketapi-python/archive/refs/tags/v1.0.12.tar.gz", install_requires=["requests"], )