A powerful PHP-based API endpoint that proxies SaveInsta.to to download Instagram posts, reels, stories, and profiles returning clean structured JSON with thumbnails and resolutions.
🔐 No Instagram login, no cookies, no browser automation.
This script performs the following:
- ✅ Accepts
?url=https://instagram.com/...via GET param - ✅ Validates only safe Instagram links (profile, post, reel, story)
- 🧠 Scrapes
saveinsta.to/en/highlightsfor dynamic tokens (JavaScript-generated) - 🔓 Bypasses Cloudflare with short-lived access token via
userverifyendpoint - 📦 Sends final content request with all tokens to
ajaxSearch - 🔍 Parses the returned HTML using
DOMDocument+DOMXPath - 📤 Returns a structured response like this:
{
"success": true,
"media": {
"results_images": 1,
"results_videos": 0,
"images": [ ... ],
"videos": [ ... ]
}
}GET /insta-downloader.php?url=https://www.instagram.com/p/XXXXXXXX/Response (for image post):
{
"thumb_url": "https://...",
"resolutions_count": 2,
"resolution": [
{ "Original": "..." },
{ "HD": "..." }
]
}Response (for video post):
{
"thumb_url": "https://...",
"video_src": "https://dl.snapcdn.app/...",
"resolutions_count": 0,
"resolution": []
}- PHP 7.4 or newer
- cURL enabled
- A server or local environment (XAMPP, Laravel Valet, etc.)
1. Upload insta-downloader.php to your web server
2. Access in browser or programmatically:
http://yourdomain.com/insta-downloader.php?url=https://instagram.com/reel/xxxxThe script only accepts the following Instagram URL types:
- ✅ Profile:
https://instagram.com/username/ - ✅ Post:
https://instagram.com/p/abc123/ - ✅ Reel:
https://instagram.com/reel/xyz456/ - ✅ Story:
https://instagram.com/stories/username/789...
❌ If the URL is not valid, you'll get:
{ "error": "Only profile, post, reel, or story URLs are supported." }
| Task | What to Edit |
|---|---|
| Force fixed delay | $delay_mode = "fixed" |
| Delay settings | $fixed_delay, $delay_min, $delay_max |
| Allow more URL types | Add patterns to $validPatterns[] |
| Save media locally | Use file_put_contents() in rebuild_and_parse_media() |
| Add logging | Use error_log() or save to .log file |
| Customize output | Modify final json_encode() section |
💡 You can easily extend this to support downloading or storing files locally.
Each media item contains:
{
"thumb_url": "https://...",
"resolutions_count": 3,
"resolution": [
{ "Original": "..." },
{ "HD": "..." },
{ "Preview": "..." }
]
}{
"thumb_url": "https://...",
"video_src": "https://...",
"resolutions_count": 0,
"resolution": []
}✅ TODO: Add endpoint rate limiting (e.g., 5 reqs/min IP-based)
🧪 TODO: Extend this to support IGTV or multi-image carousel parsing
🔐 TODO: Add token-based protection to prevent abuse
🧰 TODO: Build a lightweight frontend UI using fetch() + TailwindCSS
🎯 TODO: Cache token requests for 10–15s for performance
- ⚠ Rate-limited by SaveInsta if used heavily
- 🔄 Tokens (
k_token,k_exp,cftoken) can change anytime - 🚫 No login/auth API this is strictly public-facing scraping
- 💥 Instagram may eventually change how link previews work
MIT License Free to use, modify, and share.
Please use ethically and responsibly.
Built by Syn Devs – coders of clean APIs and rebels against algorithmic exploitation.
If this helped you, consider giving the repo a 🌟 or forking it to your toolkit.
