Skip to content

Commit

Permalink
1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketapi-io committed Oct 24, 2024
1 parent 3655bde commit a139016
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
36 changes: 34 additions & 2 deletions rocketapi/instagramapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def search(self, query):
- `search_hashtags`
- `search_locations`
- `search_audios`
- `search_clips`
Args:
query (str): The search query
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -375,14 +376,15 @@ 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.
Args:
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.
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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})
6 changes: 5 additions & 1 deletion rocketapi/rocketapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ 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

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()
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

0 comments on commit a139016

Please sign in to comment.