0
# Instabot
1
2
A comprehensive Python library for Instagram automation that provides both low-level API access and high-level bot functionality. Instabot enables developers to create sophisticated Instagram bots with built-in safety features, rate limiting, and extensive filtering capabilities to maintain account security while automating interactions.
3
4
## Package Information
5
6
- **Package Name**: instabot
7
- **Language**: Python
8
- **Installation**: `pip install instabot`
9
- **Python Support**: 2.7, 3.5, 3.6, 3.7
10
11
## Core Imports
12
13
```python
14
from instabot import Bot, API, utils
15
```
16
17
Individual component imports:
18
19
```python
20
from instabot.bot import Bot
21
from instabot.api import API
22
from instabot.utils import file
23
```
24
25
## Basic Usage
26
27
### Using the Bot (Recommended)
28
29
```python
30
from instabot import Bot
31
32
# Initialize bot with default settings
33
bot = Bot()
34
35
# Login with credentials
36
bot.login(username="your_username", password="your_password")
37
38
# Upload a photo with caption
39
bot.upload_photo("path/to/photo.jpg", caption="Hello Instagram! #instabot")
40
41
# Like photos from a hashtag
42
bot.like_hashtag("python", amount=10)
43
44
# Follow users from a hashtag
45
bot.follow_followers("target_username", nfollows=20)
46
47
# Print statistics and logout
48
bot.logout()
49
```
50
51
### Using the API (Lower-level)
52
53
```python
54
from instabot import API
55
56
# Initialize API
57
api = API()
58
59
# Login
60
api.login(username="your_username", password="your_password")
61
62
# Upload photo
63
api.upload_photo("path/to/photo.jpg", caption="Hello Instagram!")
64
65
# Get user information
66
user_info = api.get_username_info("target_username")
67
68
# Like a media post
69
api.like("media_id_here")
70
71
# Logout
72
api.logout()
73
```
74
75
## Architecture
76
77
Instabot is built on a two-tier architecture:
78
79
- **API Layer**: Low-level Instagram API wrapper providing direct access to Instagram endpoints with minimal abstraction
80
- **Bot Layer**: High-level automation framework built on top of the API layer, adding safety features, rate limiting, filtering, and batch operations
81
- **Utilities**: File management and helper functions for maintaining bot state and user lists
82
83
This design allows developers to choose between direct API control and automated bot functionality while ensuring consistent behavior across both approaches.
84
85
## Capabilities
86
87
### Bot Automation
88
89
High-level Instagram bot with comprehensive automation features, safety filters, rate limiting, and batch operations. Includes smart targeting, content filtering, and user management capabilities.
90
91
```python { .api }
92
class Bot:
93
def __init__(self, base_path=current_path + "/config/", proxy=None,
94
max_likes_per_day=random.randint(50, 100),
95
filter_users=False, **config): ...
96
def login(self, username=None, password=None, **args): ...
97
def logout(self): ...
98
def upload_photo(self, photo, caption=None, **options): ...
99
def like_hashtag(self, hashtag, amount=None): ...
100
def follow_followers(self, user_id, nfollows=None): ...
101
def unfollow_non_followers(self, n_to_unfollows=None): ...
102
```
103
104
[Bot Automation](./bot-automation.md)
105
106
### API Access
107
108
Low-level Instagram API wrapper providing direct access to Instagram endpoints with authentication, media management, user interactions, and feed operations.
109
110
```python { .api }
111
class API:
112
def __init__(self, device=None, base_path=current_path + "/config/",
113
save_logfile=True, **config): ...
114
def login(self, username=None, password=None, force=False, **options): ...
115
def logout(self): ...
116
def upload_photo(self, photo, caption=None, **options): ...
117
def like(self, media_id, **options): ...
118
def follow(self, user_id): ...
119
def get_user_feed(self, user_id, max_id=""): ...
120
```
121
122
[API Access](./api-access.md)
123
124
### File Management
125
126
Utility classes for managing user lists, blacklists, whitelists, and bot state persistence with support for file-based storage and duplicate management.
127
128
```python { .api }
129
class file:
130
def __init__(self, fname, verbose=True): ...
131
def append(self, item, allow_duplicates=False): ...
132
def remove(self, x): ...
133
def random(self): ...
134
def __iter__(self): ...
135
def __len__(self): ...
136
@property
137
def list(self): ...
138
@property
139
def set(self): ...
140
```
141
142
[File Management](./file-management.md)
143
144
## Types
145
146
### Configuration Types
147
148
```python { .api }
149
# Bot configuration parameters
150
BotConfig = {
151
'max_likes_per_day': int,
152
'max_follows_per_day': int,
153
'max_unfollows_per_day': int,
154
'max_comments_per_day': int,
155
'whitelist_file': str,
156
'blacklist_file': str,
157
'followed_file': str,
158
'proxy': str,
159
# ... extensive additional configuration options
160
}
161
162
# API configuration parameters
163
APIConfig = {
164
'device': str,
165
'base_path': str,
166
'save_logfile': bool,
167
'log_filename': str,
168
'proxy': str
169
}
170
```
171
172
### Response Types
173
174
```python { .api }
175
# User information response
176
UserInfo = {
177
'user': {
178
'pk': int,
179
'username': str,
180
'full_name': str,
181
'profile_pic_url': str,
182
'follower_count': int,
183
'following_count': int,
184
'media_count': int,
185
'is_private': bool,
186
'is_verified': bool
187
}
188
}
189
190
# Media information response
191
MediaInfo = {
192
'items': [{
193
'id': str,
194
'code': str,
195
'media_type': int,
196
'image_versions2': dict,
197
'video_versions': list,
198
'caption': dict,
199
'like_count': int,
200
'comment_count': int,
201
'user': dict
202
}]
203
}
204
```