Install instagrapi
Python 3.10 or newer is required (3.10, 3.11, 3.12, 3.13, 3.14). MIT-licensed, installed via pip. Python 3.9 was dropped in v2.5.0 — pin instagrapi==2.4.5 if you need it.
Install
pip install instagrapi Using Poetry:
poetry add instagrapi For asyncio code: aiograpi
If your codebase is async/await, use aiograpi instead — same author, same API surface, async-first.
pip install aiograpi Not on Python? Use instagrapi-rest
If your codebase is in Node, Go, PHP, Java, C#, Ruby, Swift or anything else, run instagrapi-rest as a Docker sidecar and call it over HTTP. The cross-language guide has working snippets in six stacks.
docker run -d -p 127.0.0.1:8000:8000 subzeroid/instagrapi-rest Quickstart
from instagrapi import Client
cl = Client()
cl.login("YOUR_USERNAME", "YOUR_PASSWORD")
user = cl.user_info_by_username("instagram")
print(user.full_name, user.follower_count) Session persistence
Avoid re-logging in on every run — dump and reuse the session.
cl.dump_settings("session.json")
# next run:
cl.load_settings("session.json")
cl.login("YOUR_USERNAME", "YOUR_PASSWORD") # reuses cookies Next steps
Skip the infra?
Managed Instagram API — same endpoints, sessions and proxies handled.
Try HikerAPI → Full comparison