Extract Instagram posts, profiles, reels, and comments at scale.
Powered by Thordata's residential proxy network & Web Scraper API.
- 📸 Posts: Scrape posts by profile URL or post URL with date range filtering.
- 👤 Profiles: Extract profile information by username or profile URL.
- 🎬 Reels: Get reel details by URL or list all reels from a profile.
- 💬 Comments: Extract comments from posts and reels.
- 🛡️ Anti-Bot Bypass: Automatically handles CAPTCHAs, IP rotation, and headers.
- 📅 Date Filtering: Filter posts/reels by start and end dates.
- 🔍 Post Type Filtering: Filter by Post, Reel, or both.
Get your free scraping token from the Thordata Dashboard.
git clone https://github.com/Thordata/instagram-scraper-python.git
cd instagram-scraper-python
pip install -r requirements.txtCopy .env.example to .env and fill in your tokens:
THORDATA_SCRAPER_TOKEN=your_token
THORDATA_PUBLIC_TOKEN=your_public
THORDATA_PUBLIC_KEY=your_keyGet Posts by Profile:
python main.py posts --profile "https://www.instagram.com/marcusfaberfdp" --limit 5 --start-date "01-01-2025" --end-date "03-01-2025"Get Post Details:
python main.py post "https://www.instagram.com/p/Cuf4s0MNqNr"Get Reel Details:
python main.py reel "https://www.instagram.com/reel/C4GLo_eLO2e/"Get Comments:
python main.py comments "https://www.instagram.com/cats_of_instagram/reel/C4GLo_eLO2e/"Get Profile Info (by username):
python main.py profile "username"Get Profile Info (by URL):
python main.py profile "https://www.instagram.com/username"Get Reels from Profile:
python main.py reels "https://www.instagram.com/username" --limit 10Get Reels List from Profile:
python main.py reels-list "https://www.instagram.com/username" --limit 10 --start-date "01-28-2025" --end-date "01-28-2026"All data is saved to output/ in JSON format. If a task fails, error details are saved to output/error_*.json.
This scraper uses Thordata's Web Scraper API (Hybrid Mode):
- Task Creation: Sends scraping parameters to Thordata's cloud cluster.
- Auto-Polling: The SDK (
run_task) automatically polls for completion. - Result Retrieval: Downloads the clean JSON data once ready.
This architecture uses Thordata's Web Scraper API and proxy infrastructure, so the example does not require local browser automation.
This repository is an example client for authorized Thordata Web Scraper API requests. It does not include Instagram login cookies, private account access, or browser session data.
The example does not grant rights to access, reuse, train on, or redistribute third-party content. Use it only for lawful and authorized data workflows.
Never place API keys, cookies, personal information, or private data in source files, logs, README files, or commits.
An API request may fail because of invalid credentials, unsupported parameters, rate limits, endpoint restrictions, or temporary service errors.
When a request fails, treat the response as an error rather than valid Instagram data. Check the terminal output and returned API response for details. Exact error codes and limits depend on the account and endpoint.
When modifying or running this example:
- Read
.env.exampleand keep credentials in environment variables. - Check
src/config.pybefore inventing scraper IDs or request parameters. - Follow the existing README examples and preserve the current request flow.
- Never print or commit API keys, cookies, private URLs, or personal data.
- Review returned profile, post, reel, or comment data before sharing it.
- Treat returned Instagram data as third-party data subject to applicable terms and usage restrictions.
MIT License. See LICENSE for details.