Instagram Login API with 2FA | Session Cookie Authentication
Pricing
from $0.09 / login
Instagram Login API with 2FA | Session Cookie Authentication
Login to Instagram with email/password and two-factor authentication. Stores session cookies server-side for use with the Instagram Automation API. No browser needed.
Pricing
from $0.09 / login
Rating
0.0
(0)
Developer

Zen Studio
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
3 days ago
Last modified
Categories
Share
Instagram Login & Cookie Extractor | 2FA Support
Log in to Instagram programmatically and extract session cookies. Handles email verification and two-factor authentication. No browser required.
RELATED ACTORS
| Instagram ➤ | Instagram Automation API |
|---|
- Session cookies — Returns
sessionid,csrftoken,ds_user_id, and browser fingerprint cookies - 2FA support — Handles email verification codes and authenticator apps
- Residential proxies — Country selection to match your usual login location
- No browser — Direct GraphQL authentication, fast and lightweight
How It Works
-
Run 1 (Login) — Provide
email+password. If the account has no 2FA, returns cookies immediately. If 2FA is enabled, returnspending_2faand triggers the verification code. -
Run 2 (Verify) — Provide
email+code(the 6-digit code from your email or authenticator app). Completes authentication and returns cookies.
Output
Successful Login
{"status": "ok","email": "your_email","message": "Login successful (no 2FA required)","ds_user_id": "548591854","cookies": {"sessionid": "548591854%3AaBcDeFgHiJkL%3A1","csrftoken": "aBcDeFgHiJkLmNoPqRsTuV","ds_user_id": "548591854","datr": "xY2aBcDeFgHiJk","mid": "ZaBcDeFgHiJkLm","ig_did": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890"}}
Pending 2FA
{"status": "pending_2fa","email": "your_email","message": "Enter the code that we sent to y***@e*****.com"}
Error
{"status": "error","error_code": "invalid_password","message": "The password you entered is incorrect"}
Quick Start
Login (No 2FA)
{"email": "your_instagram_email","password": "your_password","country": "US"}
Login (With 2FA)
Step 1 — Start login:
{"email": "your_instagram_email","password": "your_password","country": "US"}
Output: status: "pending_2fa" — check your email for the code.
Step 2 — Submit code:
{"email": "your_instagram_email","code": "123456"}
Output: status: "ok" with session cookies.
Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Instagram email or username |
password | string | For login | Instagram password (not needed for 2FA completion) |
code | string | For 2FA | 6-digit verification code from email or authenticator |
country | string | No | Login country code (default: US) |
Login Country
Use the country where your Instagram account is normally accessed from. Logging in from an unexpected location may trigger additional security challenges.
API Integration
Python
from apify_client import ApifyClientclient = ApifyClient("your_token")# Step 1: Start loginrun = client.actor("zen-studio/instagram-login").call(run_input={"email": "your_email","password": "your_password","country": "US",})result = client.dataset(run["defaultDatasetId"]).list_items().items[0]if result["status"] == "pending_2fa":code = input("Enter 2FA code: ")# Step 2: Complete 2FArun = client.actor("zen-studio/instagram-login").call(run_input={"email": "your_email","code": code,})result = client.dataset(run["defaultDatasetId"]).list_items().items[0]# Use cookies in your own requestscookies = result["cookies"]print(f"Session ID: {cookies['sessionid']}")
JavaScript
import { ApifyClient } from 'apify-client';const client = new ApifyClient({ token: 'your_token' });// Step 1: Start loginlet run = await client.actor('zen-studio/instagram-login').call({email: 'your_email',password: 'your_password',country: 'US',});let { items } = await client.dataset(run.defaultDatasetId).listItems();if (items[0].status === 'pending_2fa') {// Step 2: Complete 2FArun = await client.actor('zen-studio/instagram-login').call({email: 'your_email',code: '123456',});({ items } = await client.dataset(run.defaultDatasetId).listItems());}// Use cookies in your own requestsconst { cookies } = items[0];console.log(`Session ID: ${cookies.sessionid}`);
Pricing
Pay-per-event pricing. You only pay for successful logins.
| Event | Price |
|---|---|
| Actor start | $0.00005 |
| Successful login | $0.099 |
Failed logins, pending 2FA states, and errors are not charged.
FAQ
Q: How long do sessions last? A: Sessions typically last days to weeks depending on account activity and Instagram's security policies.
Q: What if I enter the wrong 2FA code? A: The actor returns an error. Run it again with the correct code. The pending state persists between runs.
Q: Does this work with authenticator apps? A: Yes. Any 6-digit TOTP code from Google Authenticator, Authy, or similar apps works.
Q: Why use a specific login country? A: Instagram flags logins from unusual locations. Use the country where you normally access your account to avoid additional security challenges.
Legal Compliance
This actor authenticates with credentials you provide for your own Instagram account. You are responsible for complying with Instagram's Terms of Service and applicable data protection regulations.