Skip to content

Universal Social Media API Platform - Unified interface for Instagram, TikTok, Twitter, Facebook, LinkedIn. Same code, multiple platforms.

License

Notifications You must be signed in to change notification settings

LiuLucian/uniapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

UniAPI - Universal Social Media API Platform

Official API-style unified interface for multi-platform social media

License: MIT Python 3.8+ FastAPI Playwright GitHub stars GitHub forks GitHub issues GitHub last commit


UniAPI Demo

โœจ One interface, 5 platforms - that's it.

๐ŸŽฏ Why UniAPI?

Feature Official APIs UniAPI
Approval Days/Weeks waiting โœ… Instant - use immediately
Cost $$$-$$$$$ monthly โœ… Free & Open Source
Rate Limits Strict (often 100-500/day) โœ… Flexible
Feature Access Limited by API โœ… Full platform features
Multi-platform Code 5 different APIs to learn โœ… 1 unified interface
Setup Time Hours of reading docs โœ… 5 minutes
Breaking Changes Frequent API deprecations โœ… Stable interface

โœจ Features

  • ๐ŸŽฏ Unified Interface: All platforms use the same API interface with minimal learning curve
  • ๐Ÿš€ Official-style Design: API design mimics official APIs for simplicity and elegance
  • ๐Ÿ” Cookie Authentication: Browser cookie-based auth, no developer approval needed
  • ๐Ÿค– Browser Automation: Uses Playwright to bypass API limitations
  • ๐Ÿ“ฆ One-Click Deployment: Automated installation and startup scripts
  • ๐ŸŒ Multi-Platform Support: Twitter, Instagram, TikTok, Facebook, LinkedIn

๐Ÿš€ Supported Platforms

Platform Bridge Server SDK Status
Twitter Port 5001 twitter_sdk.py โœ… 100%
Instagram Port 5002 instagram_sdk.py โœ… 100%
TikTok Port 5003 tiktok_sdk.py โœ… 100%
Facebook Port 5004 facebook_sdk.py โœ… 100%
LinkedIn Port 5005 linkedin_sdk.py โœ… 100%

๐Ÿ’ผ Use Cases

Perfect for:

  • ๐Ÿ“ˆ Marketing Automation - Schedule and distribute content across all platforms
  • ๐Ÿ” Lead Generation - Auto-reply to comments containing specific keywords
  • ๐Ÿ“Š Social Listening - Monitor brand mentions and competitor activity
  • ๐Ÿค– Chatbot Development - Build automated response systems
  • ๐Ÿ“ฑ Content Distribution - Publish once, reach 5 platforms instantly
  • ๐ŸŽฏ Agency Tools - Manage multiple client accounts from one interface
  • ๐Ÿ”ฌ Research Projects - Collect social media data for analysis
  • ๐ŸŽ“ Educational Projects - Learn API design and browser automation

Real-world example:

# Monitor competitor posts and auto-respond to their followers
from instagram_sdk import InstagramAPI

api = InstagramAPI()
competitors = ["competitor1", "competitor2"]

for competitor in competitors:
    posts = api.get_user_posts(competitor, limit=5)
    for post in posts:
        comments = api.get_post_comments(post.url)
        for comment in comments:
            # Engage with their audience
            api.send_dm(comment.username, "Check out our product!")

๐Ÿ—๏ธ Architecture

User Code
   โ†“
Python SDK (instagram_sdk.py, tiktok_sdk.py, etc.)
   โ†“
FastAPI Main Server (Port 8000)
   โ†“
Bridge Servers (Ports 5001-5005)
   โ†“
Playwright Browser Automation
   โ†“
Social Media Platforms

๐Ÿ“ฆ Quick Start

1๏ธโƒฃ Clone the Project

git clone https://github.com/LiuLucian/uniapi.git
cd uniapi

2๏ธโƒฃ One-Click Installation

cd backend
./install.sh

This will automatically install:

  • Python dependencies (FastAPI, Playwright, etc.)
  • Playwright browser drivers
  • Create necessary directories and configuration files

3๏ธโƒฃ Configure Authentication

Edit backend/platforms_auth.json and add your platform cookies:

{
  "instagram": {
    "cookies": {
      "sessionid": "your_instagram_sessionid"
    }
  },
  "twitter": {
    "cookies": {
      "auth_token": "your_twitter_auth_token",
      "ct0": "your_twitter_ct0"
    }
  }
  // ... other platforms
}

๐Ÿ’ก How to get cookies? See QUICK_START.md

4๏ธโƒฃ Start Services

cd backend
./start_uniapi.sh

After startup, automatic health checks will run. All โœ… marks indicate success.

5๏ธโƒฃ Use the API

Method 1: Python SDK (Recommended)

from instagram_sdk import InstagramAPI
from tiktok_sdk import TikTokAPI

# Instagram example
insta = InstagramAPI()
user = insta.get_user("instagram")
print(f"Username: {user['username']}, Followers: {user['followers']}")

insta.like_post("https://www.instagram.com/p/ABC123/")
insta.send_dm("username", "Hello from UniAPI!")

# TikTok example
tiktok = TikTokAPI()
user = tiktok.get_user("@username")
tiktok.like_video("https://www.tiktok.com/@user/video/123")

Method 2: Direct REST API

# View API documentation
open http://localhost:8000/api/docs

# Test with curl
curl http://localhost:8000/api/v1/instagram/users/instagram

# Like a post
curl -X POST http://localhost:8000/api/v1/instagram/posts/like \
  -H "Content-Type: application/json" \
  -d '{"post_url": "https://www.instagram.com/p/ABC123/"}'

๐Ÿ—๏ธ Unified API Interface

All platform SDKs follow the same interface design:

# User operations
api.get_user(username)              # Get user info
api.follow_user(username)           # Follow user

# Content operations
api.like_post(url)                  # Like/favorite
api.comment(url, text)              # Comment
api.send_dm(username, message)      # Send DM

# Batch operations
api.batch_like(urls, delay=5)       # Batch like with auto-delay

๐Ÿ› ๏ธ Management Commands

# Start all services
cd backend && ./start_uniapi.sh

# Stop all services
cd backend && ./stop_uniapi.sh

# View logs
tail -f backend/logs/fastapi.log
tail -f backend/logs/instagram_bridge.log

# Check service status
curl http://localhost:8000/health
curl http://localhost:5002/health  # Instagram bridge

๐Ÿ“ Project Structure

uniapi/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ main.py                 # FastAPI main server
โ”‚   โ”œโ”€โ”€ platforms/              # Platform bridge servers
โ”‚   โ”‚   โ”œโ”€โ”€ twitter/
โ”‚   โ”‚   โ”œโ”€โ”€ instagram/
โ”‚   โ”‚   โ”œโ”€โ”€ tiktok/
โ”‚   โ”‚   โ”œโ”€โ”€ facebook/
โ”‚   โ”‚   โ””โ”€โ”€ linkedin/
โ”‚   โ”œโ”€โ”€ api/v1/                 # FastAPI routes
โ”‚   โ”œโ”€โ”€ core/                   # Core configuration
โ”‚   โ”œโ”€โ”€ start_uniapi.sh         # Startup script
โ”‚   โ”œโ”€โ”€ stop_uniapi.sh          # Stop script
โ”‚   โ””โ”€โ”€ install.sh              # Installation script
โ”œโ”€โ”€ instagram_sdk.py            # Instagram Python SDK
โ”œโ”€โ”€ tiktok_sdk.py               # TikTok Python SDK
โ”œโ”€โ”€ facebook_sdk.py             # Facebook Python SDK
โ”œโ”€โ”€ linkedin_sdk.py             # LinkedIn Python SDK
โ”œโ”€โ”€ twitter_sdk.py              # Twitter Python SDK
โ”œโ”€โ”€ demo.py                     # Example code
โ”œโ”€โ”€ QUICK_START.md              # Quick start guide
โ””โ”€โ”€ README.md                   # This file

๐Ÿ”ง Tech Stack

  • FastAPI - High-performance Python web framework
  • Playwright - Cross-browser automation tool
  • Flask - Bridge server framework
  • Pydantic - Data validation and type hints
  • Httpx - Async HTTP client

๐Ÿ“ FAQ

Q: Why not use official APIs directly?

A: Most social media platforms' official APIs:

  • Require developer approval (complex review process)
  • Have limited functionality (e.g., Instagram doesn't support DM API)
  • Have strict rate limits
  • Require payment (e.g., LinkedIn API)

UniAPI bypasses these limitations through browser automation, providing a more flexible solution.

Q: Do cookies expire?

A: Yes. Cookie validity is typically 30-90 days. After expiration, you need to log in again and update platforms_auth.json.

Q: Does this violate platform rules?

A: Automated operations may violate platform terms of service. Please use only for personal learning and testing, not for commercial purposes or large-scale operations.

Q: How to avoid detection?

A:

  • Use auto_delay=True to enable random delays
  • Don't operate too frequently (recommended 5-10 seconds between operations)
  • Use dedicated accounts, not your main account

๐Ÿ“„ License

This project is open-sourced under the MIT License.

๐Ÿค Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

๐Ÿ—บ๏ธ Roadmap

โœ… Completed (v1.0)

  • Unified API for 5 platforms (Instagram, Twitter, TikTok, Facebook, LinkedIn)
  • FastAPI main server with Swagger docs
  • Browser automation with Playwright
  • Cookie-based authentication
  • One-click installation and startup

๐Ÿšง In Progress (v1.1 - Q1 2025)

  • Webhook support for real-time events
  • Scheduled posting with cron-like syntax
  • Rate limiting and retry mechanisms
  • Enhanced error logging

๐Ÿ”ฎ Planned (v2.0 - Q2 2025)

  • Analytics dashboard (engagement metrics across platforms)
  • Multi-account management per platform
  • AI-powered content generation (GPT integration)
  • Advanced search and filtering
  • Export data to CSV/JSON

๐Ÿ’ก Under Consideration

  • YouTube support
  • Reddit integration
  • WhatsApp Business API
  • Discord webhook support
  • Telegram bot API

Vote for features: Open a discussion to suggest or vote on features!

โญ Star History

Star History Chart

Help us grow! Star the repo if you find it useful ๐ŸŒŸ

โš ๏ธ Disclaimer

This project is for educational purposes only. Users are responsible for any consequences of using this project. The author assumes no liability.


Built something cool with UniAPI? Add this badge to your project:

Built with UniAPI

[![Built with UniAPI](https://img.shields.io/badge/Built%20with-UniAPI-blue?style=for-the-badge)](https://github.com/LiuLucian/uniapi)

About

Universal Social Media API Platform - Unified interface for Instagram, TikTok, Twitter, Facebook, LinkedIn. Same code, multiple platforms.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors