A lightweight API that extracts direct media URLs from Instagram posts, reels, and videos.
- Get direct URLs for images and videos
- Supports posts with multiple media items (carousels)
- In-memory caching to improve performance for repeated requests
- Supports both proxy and proxyless modes
- Clean and simple JSON output
You can test the API at:
🔗 https://insta.selfhoster.nl/
GET /— Basic usage infoGET /dl?url=INSTAGRAM_URL— Extracts direct media URLs
GET /dl?url=https://www.instagram.com/p/BgSlRglAKBn{
"urls": [
"https://scontent-fra3-1.cdninstagram.com/o1/v/t16/f2/m84/AQOSM1RUWv-dukL6Q6ctpt60upNiJLWXk_iXV0Ee9YKYfrt9eMc_LQziON4Tgme8K4i3ar5Rcv5zQKacoeU7nq9VVLXLs7R3BSPTxgY.mp4?stp=dst-mp4&efg=eyJxZV9ncm91cHMiOiJbXCJpZ193ZWJfZGVsaXZlcnlfdnRzX290ZlwiXSIsInZlbmNvZGVfdGFnIjoidnRzX3ZvZF91cmxnZW4uZmVlZC5jMi42NDAuYmFzZWxpbmUifQ&_nc_cat=103&vs=851637283349429_3931091210&_nc_vs=HBksFQIYTGlnX2JhY2tmaWxsX3RpbWVsaW5lX3ZvZC9DRjQ4Qjk5MzAyMkU2RDFDQ0Q1RTE2M0RBQURENzVCOV92aWRlb19kYXNoaW5pdC5tcDQVAALIARIAFQIYOnBhc3N0aHJvdWdoX2V2ZXJzdG9yZS9HRWVhWkJkTUVkWjc1emtCQUtIM0JORGpMZUptYnBrd0FBQUYVAgLIARIAKAAYABsAFQAAJvzMh4fxlOQBFQIoAkMzLBdAIO6XjU%2FfOxgSZGFzaF9iYXNlbGluZV8xX3YxEQB16gdl8J0BAA%3D%3D&_nc_rid=67e894ed42&ccb=9-4&oh=00_AfR5PWU9vZN2NL6Apkjx3HoN36viC7O0hDoTJNqxqgRafA&oe=687DF52A&_nc_sid=d885a2"
]
}-
Clone the repository:
git clone https://github.com/mustafachyi/Instagram-Direct-Media-URL-Extractor.git cd Instagram-Direct-Media-URL-Extractor -
Install dependencies:
bun install
-
Start the server:
bun start
PORT— Port for the server (default:3000)PROXY_URL— Optional HTTP proxy URLCACHE_TTL_SECONDS- Cache duration for API responses (default:3600)
- Proxy Mode: Uses the
PROXY_URLto make requests to Instagram - Proxyless Mode: Makes requests directly to Instagram (may be rate-limited)
MIT License
Inspired by instagram-direct-url