sandeep
sandeep

Reputation: 21

How to use Instagram API in Python to upload images to my own account

I want to create a script where I can automatically upload images to my Instagram account. I've tried 3rd party packages (instapy-cli, InstagramAPI) but none of them work. I've signed up for Facebook developers but can't figure out how to use it in Python.

Upvotes: 1

Views: 706

Answers (1)

Sandeep Ram
Sandeep Ram

Reputation: 11

Use the instabot python library. The below function takes the username password image_path and description of your image in order to post it to Instagram. However, you cannot post multi-side/carousel posts with this code.

from instabot import Bot
import shutil
import os

def post(username, password , img , description):
    
    if os.path.exists('config'):
        shutil.rmtree('config')

    bot = Bot()
    bot.login(username = username, password = password)
    bot.upload_photo(img, caption = discription)
    os.rename(img+'.REMOVE_ME', img)

Upvotes: 1

Related Questions