Skip to content

SUDEEPBOTS/Bhaigram-Backend-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Typing SVG



A lightning-fast, ultra-secure, and fully autonomous backend API for Instagram Data Extraction.

Last Commit Issues FastAPI Vercel Python


πŸ“– Table of Contents


🌟 Overview

The Bhaigram Backend API is a next-generation wrapper around instagrapi, optimized specifically for serverless deployment on Vercel.

Whether you are building a custom Telegram Bot, a full-stack Web Application, or a social media analytics dashboard, this API handles all the heavy lifting. It fetches HD media, extracts deep profile metadata, and grabs original Instagram audio tracks instantly.

Note: This API is explicitly designed as a READ-ONLY service. All endpoints that perform write operations (like commenting or liking) have been permanently disabled to ensure 100% safety of the underlying Instagram session account from bans or restrictions.


✨ Key Features

  • πŸš€ Serverless Ready: Works seamlessly on Vercel's Python 3.12 serverless functions.
  • πŸ›‘οΈ Built-in Rate Limiting: Prevents DoS attacks and account bans with a hard 30 req/min limit per IP.
  • 🎡 Direct Audio Extraction: Grabs original .mp4 audio containers for any Reel or Music search.
  • πŸ“₯ HD Media Downloads: Direct CDN links to watermark-free Reels, Posts, and Carousels.
  • πŸ” Deep Search: Real-time search for Instagram Users, Hashtags, and Audio Tracks.
  • πŸ‘€ Advanced Profile Scraping: Returns WhatsApp numbers, pronouns, locations, and Account Types.

πŸ›‘οΈ Security & Rate Limiting

To protect the Instagram account configured in the IG_SESSION_ID environment variable, this API employs a strict security policy:

  1. Read-Only Enforced: No endpoint exists to alter Instagram state.
  2. Global Rate Limiter: A custom FastAPI middleware tracks requests via x-forwarded-for (Vercel IP).
  3. Threshold: If an IP exceeds 30 requests per 60 seconds, the API blocks them with a HTTP 429 Too Many Requests status, preserving the Instagram account's health.

πŸš€ Live Endpoints Directory

All endpoints are hosted at the root domain (/).

Feature Category Endpoint Path Method Description
System /health GET API Health Check
Downloads /download/media GET Get download URLs and metadata for any IG Link.
Profile /profile/info GET Get advanced info (Followers, Contact, Location).
Profile /profile/stories GET Download currently active stories for a user.
Profile /profile/highlights GET Fetch highlight folders for a user.
Profile /profile/posts GET Fetch the latest posts/reels of a user in bulk.
Network /profile/followers GET Fetch followers list for a user.
Network /profile/following GET Fetch following list for a user.
Search /search/users GET Search for accounts globally.
Search /search/hashtag GET Fetch top trending media for a hashtag.
Search /search/music GET Search IG Music Library for Audio Download Links.

πŸ“š Detailed API Documentation

1. Media & Reels Downloader

Extracts metadata, view counts, likes, music information, and the direct HD .mp4 URL for any Instagram Reel.

Endpoint: GET /download/media

Parameters:

  • url (string, required): The URL of the Instagram Reel or Post.

Example Request:

curl -X GET "https://insta.yukiapi.site/download/media?url=https://www.instagram.com/reel/DbGNF90Rx9J/"

Example Response:

{
  "success": true,
  "data": {
    "shortcode": "DbGNF90Rx9J",
    "play_count": 6157648,
    "video_duration": 22.23,
    "music_info": {
      "title": "Chokra Jawaan",
      "artist": "Amit Trivedi, Vishal Dadlani",
      "audio_url": "https://scontent-iad6-1...mp4?strext=1"
    },
    "video_url": "https://scontent-iad3-1...mp4",
    "thumbnail_url": "https://scontent-iad6-1...jpg"
  }
}

2. Advanced Profile Info

Fetches deep account information, including business category, linked WhatsApp, and live active stories.

Endpoint: GET /profile/info

Parameters:

  • query (string, required): The Username or Profile URL.

Example Request:

curl -X GET "https://insta.yukiapi.site/profile/info?query=zuck"

Example Response:

{
  "success": true,
  "data": {
    "username": "zuck",
    "full_name": "Mark Zuckerberg",
    "follower_count": 16939494,
    "whatsapp_number": "",
    "account_type": 3,
    "has_active_story": false,
    "active_stories": [],
    "location_data": {
      "city_name": "",
      "address_street": ""
    },
    "profile_pic_url_hd": "https://scontent-iad3-1...jpg"
  }
}

3. Profile Stories & Highlights

Endpoint: GET /profile/stories Fetches all currently active 24h stories for a user, complete with direct MP4/JPG links.

Endpoint: GET /profile/highlights Fetches all permanent highlight folders (titles and cover images).


4. Search Music & Audio

Access Instagram's internal music library. Enter any song name and get back the official audio track download URL.

Endpoint: GET /search/music

Parameters:

  • query (string, required): The song name or artist.

Example Request:

curl -X GET "https://insta.yukiapi.site/search/music?query=barbad"

Example Response:

{
  "success": true,
  "data": [
    {
      "title": "Tum Ho Toh (Movie: Saiyaara)",
      "artist": "Vishal Mishra",
      "audio_url": "https://scontent-iad3-1...mp4?strext=1",
      "duration_ms": 318217,
      "cover_url": "https://scontent-iad3-1...jpg"
    }
  ]
}

5. Network (Followers/Following)

Quickly fetch the list of users someone is following or followed by.

Endpoints:

  • GET /profile/followers?username=user&amount=20
  • GET /profile/following?username=user&amount=20

πŸ’» Tech Stack

  • Language: Python 3.12
  • Framework: FastAPI (Uvicorn)
  • Instagram Core: Instagrapi (Headless Client)
  • Database: MongoDB (PyMongo)
  • Hosting: Vercel Serverless Functions

βš™οΈ Setup & Deployment

1. Local Development

# Clone the repository
git clone https://github.com/SUDEEPBOTS/Bhaigram-Backend-API.git
cd Bhaigram-Backend-API

# Install Dependencies using UV or PIP
pip install -r requirements.txt

# Set Environment Variables
export IG_SESSION_ID="your_instagram_sessionid_cookie_here"

# Run the API
uvicorn api.index:app --reload --port 8000

2. Vercel Deployment

This project is configured out-of-the-box for Vercel.

  1. Link the repository to Vercel.
  2. In Vercel Environment Variables, set IG_SESSION_ID.
  3. Vercel will automatically build the api/index.py using Python 3.12.

πŸ“œ License

This project is licensed under the MIT License. Use at your own risk. This is an unofficial API wrapper and is not affiliated with, endorsed by, or sponsored by Instagram or Meta Platforms, Inc.

# trigger redeploy

About

A highly optimized, custom backend server for Bhaigram providing an exact replica of Instagram Reels feed, direct media downloads, and profile lookups using FastAPI and instagrapi.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages