Skip to content

Python library · Setup pages

instagrapi / Python

Point an instagrapi client at a mobile line, rotate sparingly and respect the library's own warnings.

instagrapi talks to the private API from Python. Its documentation says risk rises with rotating proxies and calls it better for research than production; a stable Full Access line per account group, with the rotation link used sparingly, is the least risky shape.

Proxy string

HTTP proxy URL

http://USER:PASS@HOST:PORT

SOCKS5 proxy URL

socks5://USER:PASS@HOST:PORT

Protocol. HTTP through the proxy URL form. SOCKS5 needs the socks extra of the requests library; keep DNS on the proxy with the socks5h scheme.

Setup steps

instagrapi / Python, step by step

  1. 1Install instagrapi and create a Client.
  2. 2Call set_proxy with the proxy URL before logging in.
  3. 3Log in once, dump the session settings to a file and reuse them; every fresh login is a new device to the platform.
  4. 4Keep one client per account and one line per account group; never move a session between lines.
  5. 5Handle challenge_required, feedback_required and please_wait_a_few_minutes by stopping, not by rotating.

Rotation link

Changing the IP on purpose

Rotate sparingly: call the rotation link, poll the status link until the exit has settled, then log the next client in. Keep calls at least 5 minutes apart. Do not rotate too frequently; it does more harm than good, and heavy rotation is the pattern the library itself warns about.

import time, requests
from instagrapi import Client

PROXY = "http://USER:PASS@HOST:PORT"

def rotate() -> None:
    requests.get("ROTATION_LINK", timeout=15).raise_for_status()
    for _ in range(24):
        time.sleep(5)
        state = requests.get("STATUS_LINK", timeout=15).json()
        if state.get("rotation", {}).get("phase") != "pending":
            return

cl = Client()
cl.set_proxy(PROXY)
cl.load_settings("session.json")  # reuse the device; do not log in fresh every run
cl.login("USERNAME", "PASSWORD")

The rotation and status links are on the line's page in the portal and in the API documentation. The daily allowance of customer-driven changes is in the fair-use policy.

DNS, timezone and leaks

Keep the fingerprint on the line

  • IncludedSet the client's device settings, locale and timezone offset to the line's country before the first login, and keep them stable.
  • IncludedOne line per account group; sessions never move between lines.
  • IncludedSpace actions like a person; the library's delay settings exist for this.

Accounts per line

How many accounts on one line

Research and monitoring can share a line; account operation wants the growth or maintenance numbers.

Platformgrowthmaintenance
Instagram / Threads3 per line8 per line
Open the calculator

Verification checklist

Before the first account

  • IncludedA request through the proxy to an IP-checking API returns a mobile-carrier address in the line's country.
  • IncludedThe first login succeeds without a challenge.
  • IncludedThe session file reloads on the next run without a new login.

What each check proves is on the verification page.

Pitfalls

What goes wrong

  • Fresh logins on every run look like new devices; persist the session.
  • Rotating on every error makes things worse; most errors are rate or behaviour signals, not network ones.
  • The rotation link is not a proxy address.

Questions

instagrapi / Python and mobile lines

All setup pages

No. The library warns against rotating proxies for account work. Use Full Access, keep the line stable, and rotate only when a group switches; rotating too frequently does more harm than good.