Instagram API for Python.
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
Checking
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
import requests
import urllib.parse
API_KEY = "YOUR API"
VIDEO_URL = "URL INSTAGRAM"
ENDPOINT = "https://senpai-bot.store/instagramdl"
def main():
encoded_url = urllib.parse.quote(VIDEO_URL, safe='')
full_url = f"{ENDPOINT}?apikey={API_KEY}&url={encoded_url}"
try:
response = requests.get(full_url)
response.raise_for_status()
except requests.RequestException as e:
print(f"Error making request: {e}")
return
try:
data = response.json()
except ValueError as e:
print(f"Error parsing JSON: {e}")
return
if data.get("code") != 200:
print(f"API returned error code: {data.get('code')}")
return
r = data["result"]
print("Username :", r.get("username"))
print("Full Name :", r.get("full_name"))
print("Caption :", r.get("caption"))
print("Post URL :", r.get("post_url"))
print("Post Type :", r.get("post_type"))
print("Media Type :", r.get("type"))
print("Duration :", r.get("duration"))
print("Likes :", r.get("likes"))
print("Comments :", r.get("comments"))
print("Created :", r.get("created"))
print("Poster URL :", r.get("poster"))
print("Picture :", r.get("picture") or "(null)")
print("Private :", r.get("private"))
print("Slide Post :", r.get("slide_post"))
print("Verified :", r.get("verified"))
if __name__ == "__main__":
main()