Simple Website/API for downloading instagram videos made with Next.js 13.
A website that lets you download Instagram videos easily and quickly. You can paste the URL of any public Instagram post and get the video file in MP4 format. there is also an API that you can use to integrate this functionality into your own applications. The API is simple, and it returns JSON responses with the video URL and other metadata.
Note: Instagram stories aren't supported.
You can preview and try the website live in Vercel here : insta-video-saver.vercel.app
- Easy and User friendly UI (Interactions feedback and error messages).
- Responsive UI on mobile.
1. Cloning the repository:
git clone https://github.com/riad-azz/instagram-video-downloader.git
2. Installing dependencies:
cd instagram-video-downloader
npm install
3. Starting the server:
# Development
npm run dev
# Build
npm run build
# Start
npm run start
4. Running Tests:
I am using jest for testing, you can find all the test files in src/__tests__
.
# Run all tests
npm run test
# Run a single test
npx jest -t "<test-name>"
# Example
npx jest -t "success-fetchPostJson"
The Server API is disabled by default but you can enable it by :
- Go to
src/configs/instagram.ts
- Set
enableServerAPI
totrue
.
Now you can use the API and integrate this functionality in your other applications.
Parameters :
url
: Instagram Post or Reel link (required).
curl -i "http://localhost:3000/api/instagram?url=https://www.instagram.com/p/CGh4a0iASGS"
In order to reduce the load on the API and ensure optimal performance, I have implemented rate limiting using Upstash. This integration allows me to restrict the number of requests made to the API within a specified time frame, preventing excessive traffic and potential service disruptions.
To enable this feature follow these steps:
- Create an account on upstash.com.
- Create a new Redis database.
- Click on the newly created database.
- Scroll down to REST API, click on
.env
and copy the two variables provided. - Create a new
.env.local
file in the root directory. - Paste what you copied inside and add
USE_UPSTASH
and set it totrue
.
Here is what your .env.local
should look like:
# ...other variables
USE_UPSTASH="true"
UPSTASH_REDIS_REST_URL="YOUR-UPSTASH-URL"
UPSTASH_REDIS_REST_TOKEN="YOUR-UPSTASH-TOKEN"
All ratelimit configs can be found in src/configs/upstash.ts
.
If you would like to change the identifier (default is IP) you can change it in src/middleware.ts
.
This project is licensed under the [MIT] License - see the LICENSE.md file for details