Skip to content

Instantly share code, notes, and snippets.

@Suleman-Elahi
Last active August 25, 2024 18:09
Show Gist options
  • Save Suleman-Elahi/3b6c1e02ead4c849ceb7e70955b55180 to your computer and use it in GitHub Desktop.
Save Suleman-Elahi/3b6c1e02ead4c849ceb7e70955b55180 to your computer and use it in GitHub Desktop.
Sript to unsave all saved Instagram posts. Uses Instagram private API by ping and its extensions to do the heavy lifting.
from instagram_private_api import Client, ClientCompatPatch
from instagram_private_api_extensions import pagination
import json, time
user_name = 'UserName'
password = 'PassWord'
api = Client(user_name, password)
items=[]
for results in pagination.page(api.saved_feed, args={}):
if results.get('items'):
items.extend(results['items'])
print("Starting unsaving posts.....")
for i,x in enumerate(items):
z = items[i]['media']['pk']
api.unsave_photo(media_id=z)
time.sleep(3)
print("Unsaved: ", z)
@Suleman-Elahi
Copy link
Author

403 forbidden likely cased for abusing the API. Try after using a VPN and make sure that account doesn't have 2FA enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment