Instagram Scraper API
Python client for the GetSocialAPI Instagram Scraper API.
- No cookies required — you never provide Instagram session cookies
- No accounts needed — zero ban risk for your own profiles
- Raw Instagram JSON responses, REST endpoints — no transformations
- Automatic retries with
Retry-After, typed exceptions
Installation
pip install getsocialapi-instagram
Migration from getsocialapi (git installs)
Before the PyPI release this SDK was installed from git as getsocialapi.
Old imports keep working via a deprecated shim, but please migrate:
pip uninstall getsocialapi
pip install getsocialapi-instagram
# before
from getsocialapi import Client
# after
from getsocialapi_instagram import Client
Quickstart
from getsocialapi_instagram import Client
# Get your API key at https://getsocialapi.com/dashboard/
client = Client(api_key="gsa_live_...") # or set GETSOCIALAPI_API_KEY
# Profile by numeric id (or user_by_username for usernames)
user = client.instagram.user_info(25025320)
print(user["user"]["follower_count"])
# Posts (grid)
medias = client.instagram.user_medias(25025320, count=12)
# Followers / following — paginated on unverified accounts: pass `next_max_id`
# back as `max_id`. Verified accounts (blue checkmark) expose ~50 followers max.
page = client.instagram.followers(43586162288, count=25)
page = client.instagram.followers(43586162288, max_id=page["next_max_id"])
# All comments of a post — cursor is next_min_id -> min_id (sort_order="recent" by default)
comments, cursor = [], None
while True:
page = client.instagram.media_comments(4012386322294878415, count=50, min_id=cursor)
comments += page["comments"]
cursor = page.get("next_min_id")
if not cursor:
break
Base URL: https://api.getsocialapi.com/v1 — authenticate with the API key
from your dashboard.
Client
Client(api_key=None, base_url="https://api.getsocialapi.com/v1", timeout=30, max_retries=3)
| Parameter | Default | Description |
|---|---|---|
api_key |
env GETSOCIALAPI_API_KEY |
your API key |
base_url |
API endpoint | override only for testing |
timeout |
30 |
per-request timeout, seconds |
max_retries |
3 |
retries on 429/503/5xx and network errors |
Methods
| Method | Route | Description |
|---|---|---|
profile(user_id) |
/profile/<id> |
profile by numeric id |
user_info(user_id) |
/ig/user/info/<id> |
profile by numeric id |
user_by_username(username) |
/ig/user/username_info/<username> |
profile by username |
user_about(user_id) |
/user/about/<id> |
About this account: country, joined, former usernames, shared-followers count, verified |
search_username(query, count=10) |
/search/username/<q> |
search users, resolve username → pk |
similar_users(user_id) |
/ig/user/similar/<id> |
suggested accounts |
user_medias(user_id, count=12, max_id=None) |
/ig/user/media/<id> |
profile grid posts |
user_tags(user_id, count=12, max_id=None) |
/ig/user/tags/<id> |
posts with the user tagged |
user_stories(user_id) |
/ig/user/stories/<id> |
active stories |
user_highlights(user_id) |
/ig/user/highlights/<id> |
highlights tray |
highlight_stories(highlight_id) |
/ig/highlight/stories/<id> |
media of a highlight |
followers(user_id, count=50, max_id=None, query=None) |
/followers/<id> |
followers list |
following(user_id, count=25, max_id=None, query=None) |
/following/<id> |
following list |
media_info(media) |
/ig/media/info/<pk|shortcode> |
full media card; accepts numeric pk or shortcode |
media_likers(media) |
/ig/media/likers/<pk|shortcode> |
users who liked (up to ~100, no pagination) |
media_comments(media, count=None, sort_order="recent", min_id=None) |
/ig/media/comments/<pk|shortcode> |
media comments; cursor pagination next_min_id → min_id |
search_clips(keyword) |
/ig/media/search_clips/<kw> |
search reels by keyword |
hashtag_info(tag) |
/ig/hashtag/info/<tag> |
hashtag card |
hashtag_search(query) |
/ig/hashtag/search/<q> |
search hashtags |
hashtag_posts(tag, max_id=None) |
/v2/hashtag/posts/<tag> |
posts by hashtag |
location_info(pk) |
/ig/location/info/<pk> |
location card |
location_media(pk, max_id=None) |
/ig/location/media/<pk> |
media by location |
Every method returns the raw JSON of the API route as received — nothing is
unwrapped, filtered or renamed. Where the API supports pagination (followers*, following, user_medias,
user_tags, hashtag_posts, location_media), pass the cursor from the
previous response (next_max_id) as max_id.
media_comments paginates with a different cursor: always request with
sort_order="recent" (the default) and pass next_min_id back as min_id
until it comes back null — pages are chronological and disjoint. Instagram
never returns next_max_id for comments, so max_id must not be used there.
*followers works on unverified accounts (nearly the full list, plus the
query filter); verified accounts (blue checkmark) expose no more than ~50
followers — one page, no cursor, query ignored. For lists without cursors
(search_clips, hashtag_search) each call simply returns the service page.
Full request/response reference with live examples: docs.getsocialapi → API Reference (see the Documentation section on getsocialapi.com).
Errors
| Exception | HTTP | Notes |
|---|---|---|
GetSocialAPIError |
— | base class; also network errors |
APIKeyError |
401 | invalid or missing key |
BadRequestError |
400 | .field points to the bad parameter |
NotFoundError |
404 | object does not exist — never retried |
RateLimitError |
429 | .retry_after seconds |
ServiceUnavailableError |
503 | no live accounts, .retry_after |
InstagramError |
any | upstream Instagram error, .status |
from getsocialapi_instagram import NotFoundError, RateLimitError
import time
try:
client.instagram.user_info(25025320)
except NotFoundError:
... # object does not exist
except RateLimitError as e:
time.sleep(e.retry_after)
Only successful responses (HTTP 200 and 404) count against your quota.
Rate limits and plans: pricing.
Support
- Telegram: @getsocialapi
- Email: hello@getsocialapi.com
- Website: getsocialapi.com
- Documentation: getsocialapi.com/docs
- Status: getsocialapi.com/status
License
MIT
Metadata
Release files for getsocialapi-instagram 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| getsocialapi_instagram-0.1.0.tar.gz | 14.0 kB | With provenance | Details for getsocialapi_instagram-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| getsocialapi_instagram-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for getsocialapi_instagram-0.1.0-py3-none-any.whl |
Total release size: 25.4 kB
Security for getsocialapi-instagram 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.