🔥 Fastest & Simplest Python Package For Instagram Automation
Project description
🤖 Ensta - Simple Instagram API
This package lets you use Instagram's Internal Web API through simple functions and classes, that can help developers like you build your dream projects with very few and reliable lines of code.
It supports three types of classes - Guest, Host, Stream.
Installation
It's recommended to install this package using Python's PIP, as the GitHub versions may be unstable and may require testing before being used in production.
To install this library, run this command in a terminal window:
pip install ensta
To upgrade the installed version of this library, run:
pip install ensta --upgrade
Guest Mode
This mode doesn't require login and can be used to fetch publicly available data from Instagram's Servers. Following methods are supported till now:
- Check if username is available
- Fetch someone's profile information
- Convert username to userid
- Convert userid to username
Here's an example where an instance of Guest is created to fetch Cristiano Ronaldo's profile information:
from ensta import Guest
guest = Guest()
profile = guest.profile("cristiano")
if profile is None:
print("Something went wrong.")
else:
print(profile.biography)
print(profile.follower_count)
print(profile.following_count)
Host Mode
This mode requires the user to login through their SessionID. SessionID shall be passed as an argument while initializing this class. It can be used to fetch data that's available only when the user is logged in. Additionally, the user can perform several actions on their profile.
Methods supported till now are listed below:
- Check authentication status of the user
- Follow someone's account
- Unfollow someone's account
- Get someone's follower list of specified size
- Get someone's following list of specified size
- Toggle account privacy - 'Private' or 'Public'
Here's an example where an instance of Host is created to follow Cristiano Ronaldo's profile:
from ensta import Host
sessionid = "123456:abcdefg" # Place your SessionId here
host = Host(sessionid)
status = host.follow("cristiano")
if status is None:
print("Something went wrong.")
else:
if status.following:
print("Following!")
elif status.follow_requested:
print("Requested to follow!")
Stream Mode
This mode pulls data at realtime, so the program can process it simultaneously. It requires login through SessionID.
In a situation where you might need to fetch someone's entire follower list, this mode comes handy.
These are the methods supported till now:
- Fetch someone's follower list
- Fetch someone's following list
Here's an example where an instance of Stream is created to fetch Cristiano Ronaldo's first 100 followers:
from ensta import Stream
sessionid = "123456:abcdefg" # Place your SessionId here
stream = Stream(sessionid)
followers = stream.followers("cristiano")
for user in followers:
if user is None:
print("Something went wrong.")
break
print(user.username)
print(user.full_name)
Considerations
Here are some key points to consider when using this library in production:
-
You can use Guest, Host & Stream classes simultaneously, and create multiple instances of the same class when required.
-
Functions should return None on failure. So, add clauses for the same.
-
Some functions take Identifier as an argument while others take Username. These are the key differences between the two:
- The argument Identifier means you can pass either Username or UserID.
- The argument Username means you must pass the Username only, and not the UserID.
Session ID
When you log in to instagram.com in your browser, your browser store your credentials in the form of Cookies. The type of cookie that instagram uses to remember your session is 'SessionID'.
In order to use the Host Class, you need to pass this cookie as an argument so that Ensta can use it to log into your account. Follow these steps to get your SessionID:
- Visit Instagram.com and log into your account.
- Once you're logged in, open DevTools (Ctrl + Shift + I).
- Switch to Application tab.
- Under Storage options, expand the Cookies tab, and tap the first item.
- Once done, you will see the list of all cookies.
- Copy value of cookie named 'sessionid' and pass it as an argument whenever you use the Host Class.
An alternative way to automatically fetch SessionID is to run the fetch-sessionid.py script. Currently, this script can only fetch cookies from Google Chrome, and not any other browser.
Donate ❤️
If this library has added value to your projects, you may consider supporting me in the development of this library by donating here:
Disclaimer
This is a third-party library, not an official library from Instagram. The use of the library does not promote creation of bot accounts or spamming Instagram Users. You are liable for all the actions you take through this library. Use of such libraries maybe against Instagram's Community Guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ensta-1.8.tar.gz
.
File metadata
- Download URL: ensta-1.8.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8830e44e6b68a792d59dcf4fb4929fdb160a2f7cd53d7b8fb2845f63e3316c1e |
|
MD5 | 8d1d65603b2030c6005db378cfd78805 |
|
BLAKE2b-256 | 511f24e86c2c8a2a3b9813ce2169a258adc8334825a97d1e9549ffb109dbf245 |