InstaBot is a Python-based automation tool that publishes images to Instagram using the official Facebook / Instagram Graph API.
Images are temporarily hosted using imgbb so Instagram can access them via a public URL.
After posting, images can optionally be moved to an archive directory.
All configuration is done via a single JSON file.
{
"authentication": {
"APP_ID": "",
"APP_SECRET": "",
"IG_USER_ID": "",
"SHORT_LIVED_TOKEN": "",
"LONG_LIVED_TOKEN": "",
"URL": "https://graph.facebook.com/v24.0/oauth/access_token",
"IMGBB_API_KEY": ""
},
"data": {
"image_dir": "./images/post",
"used_image_dir": "./images/posted",
"corrupted_image_dir": "./images/corrupted"
},
"settings": {
"deleteUsedPictures": false,
"moveUsedPictures": true,
"maxAttempts": 5
}
}The following fields are required to authenticate with the Facebook / Instagram Graph API.
Facebook App ID
Location: Facebook Developer Portal → Your App → Settings → Basic
Facebook App Secret
Location: Facebook Developer Portal → Your App → Settings → Basic
Instagram Business or Creator account ID.
The Instagram account must be connected to a Facebook Page.
Short-lived User Access Token generated via the Graph API Explorer.
This token must be provided once to generate the long-lived token.
Leave this field empty.
The application automatically exchanges the short-lived token for a long-lived token and stores it internally.
You do not need to manually refresh or update this token.
OAuth endpoint used to exchange access tokens.
Default value is correct and should not be changed.
API key from https://api.imgbb.com
Used to temporarily host images so Instagram can access them.
These paths control where images are read from, where used images are stored, and where corrupted files are moved.
Directory containing images that are eligible for posting.
Default:
./images/post
Directory where images are moved after they have been posted (if enabled).
Default:
./images/posted
Directory where invalid/corrupted images are moved when the bot detects a problem (e.g. unreadable file, unsupported format, repeated upload failures).
Default:
./images/corrupted
All paths can be absolute or relative to the project root.
General behavior settings for the application.
This is not yet implemented! All images are moved to corrupted or posted
Controls whether successfully posted images are deleted after posting.
-
true
Images are deleted after they have been posted. -
false
Images are not deleted after posting.
Controls whether successfully posted images are moved after posting.
-
true
Images are moved toused_image_dirafter they have been posted. -
false
Images remain inimage_dirafter posting.
Recommended: set to true if you want a clean post folder.
Controls how many times InstaBot will retry processing/posting an image before treating it as failed.
- Example:
5
The bot retries up to 5 times before giving up. After that, the image may be moved tocorrupted_image_dir.
Recommended: 5 is a good default.