The official Python SDK for Inscrape — the AI-first web scraping API for Instagram, X & beyond.
Project description
inscrape
The official Python SDK for Inscrape — the AI-first web scraping API for Instagram, X & beyond.
Features
- 🚀 3-line usage — scrape any site with one function call
- 📸 Screenshots — full-page or element-targeted PNG capture
- 📝 Markdown — get clean Markdown instead of raw HTML
- 📊 Structured JSON — first-class Instagram & X/Twitter profile parsing
- ⚡ Async support —
AsyncInscrapefor high-concurrency workflows - 🛡️ Smart errors — typed exceptions for rate limits, auth, and quota
Installation
pip install inscrape
For async + HTTP/2 support:
pip install "inscrape[async]"
Quick Start
from inscrape import Inscrape
client = Inscrape("sk_your_token_here")
# Scrape any URL
result = client.scrape("https://example.com")
print(result.content)
# Instagram profile → structured JSON
profile = client.instagram("gkhetawat1")
print(profile["followers"])
# X/Twitter profile → structured JSON
user = client.twitter("elonmusk")
print(user["bio"])
# Full-page screenshot → PNG bytes
png = client.screenshot("https://example.com")
with open("screenshot.png", "wb") as f:
f.write(png)
# Get Markdown
md = client.markdown("https://example.com")
print(md)
Async Usage
import asyncio
from inscrape import AsyncInscrape
async def main():
client = AsyncInscrape("sk_your_token_here")
# All methods are async
profile = await client.instagram("gkhetawat1")
print(profile)
# Concurrent scraping
results = await asyncio.gather(
client.scrape("https://example.com"),
client.scrape("https://httpbin.org/get"),
client.twitter("naval"),
)
for r in results:
print(r)
await client.close()
asyncio.run(main())
API Reference
Inscrape(token, base_url="https://api.inscrape.io")
Create a client instance.
client.scrape(url, **kwargs) → ScrapeResult
Full-parameter scrape. Pass any Inscrape API parameter as a keyword argument:
result = client.scrape(
"https://example.com",
render=True,
super_proxy=True, # maps to super=true
geo_code="IN", # maps to geoCode=IN
wait_selector="div.content",
block_resources=True,
timeout=30000,
)
print(result.content)
print(result.status_code)
print(result.credits_used)
client.instagram(username, **kwargs) → dict
Shortcut for Instagram profiles. Automatically sets render=True, super=True, output=json.
client.twitter(username, **kwargs) → dict
Shortcut for X/Twitter profiles. Same smart defaults.
client.screenshot(url, full_page=True, **kwargs) → bytes
Returns decoded PNG bytes.
client.markdown(url, **kwargs) → str
Returns clean Markdown text.
client.estimate(url, **kwargs) → dict
Get estimated credit cost before scraping.
Error Handling
from inscrape import Inscrape, AuthError, RateLimitError, QuotaExhaustedError, InscrapeError
client = Inscrape("sk_xxx")
try:
result = client.scrape("https://example.com")
except AuthError:
print("Invalid API token")
except RateLimitError as e:
print(f"Rate limited — retry after {e.retry_after}s")
except QuotaExhaustedError:
print("Monthly quota used up — upgrade your plan")
except InscrapeError as e:
print(f"Scrape failed: {e.message} (code: {e.code})")
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inscrape-0.1.0.tar.gz.
File metadata
- Download URL: inscrape-0.1.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97c06f517679c652385d8cc64750892b9200c685f49501233ba32e1df5e2cf04
|
|
| MD5 |
7a63fb09d61dd0513a3f91817a30907b
|
|
| BLAKE2b-256 |
75d8472807f47365e05ce7be2ce25f2ff5738535742272c7634ae1a4065eea67
|
File details
Details for the file inscrape-0.1.0-py3-none-any.whl.
File metadata
- Download URL: inscrape-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b1822a384348a51dd8adbb5596d28dcf39a88fe7f1441ca451a57e8898f66dc
|
|
| MD5 |
971c994a5029e42b9110c5e93ce48caa
|
|
| BLAKE2b-256 |
85464625973292517ab4fe0c4b90d8d6c86b1f5bf25a95b4689aec434985b374
|