Skip to content

Latest commit

 

History

History
186 lines (139 loc) · 4.16 KB

File metadata and controls

186 lines (139 loc) · 4.16 KB

TikTok Streak API

Created by dewhush Python FastAPI

REST API for automating TikTok streak messages. Control your TikTok Streak Bot via API endpoints.

✨ Features

  • FastAPI: Modern, fast (high-performance) web framework
  • Secure: All configurations via environment variables - no hardcoded secrets
  • API Key Auth: Protected endpoints with X-API-Key header
  • Telegram Notifications: Get notified when streaks are sent
  • Auto Documentation: Swagger UI and ReDoc included

🛠️ Setup

1. Clone Repository

git clone https://github.com/dewhush/TikTok-Streak-API.git
cd TikTok-Streak-API

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment

Copy the example environment file:

# Linux/Mac
cp .env.example .env

# Windows
copy .env.example .env

Edit .env and fill in your values:

# Required
API_KEY=your-secure-api-key-here
TELEGRAM_BOT_TOKEN=your-telegram-bot-token
TELEGRAM_CHAT_ID=your-telegram-chat-id

4. Setup TikTok Cookies

  1. Login to TikTok in your browser
  2. Export cookies as cookies.json in the project root
  3. The bot will use these cookies to authenticate

5. Add Contacts

Create contacts.json:

{
    "contacts": ["username1", "username2"]
}

🚀 Running the API

Windows (Batch Script):

run_api.bat

Manual:

uvicorn api:app --host 0.0.0.0 --port 8000 --reload

Python:

python api.py

📚 API Documentation

Once running, access:

Endpoints

Method Endpoint Auth Description
GET / Welcome message
GET /health Health check
GET /status Server status
POST /v1/streak Run streak bot
GET /v1/contacts List contacts
POST /v1/contacts Add contact
DELETE /v1/contacts/{nickname} Remove contact

Authentication

Protected endpoints require X-API-Key header:

curl -X GET "http://localhost:8000/v1/contacts" \
  -H "X-API-Key: your-api-key-here"

Example Requests

Run Streak Bot:

curl -X POST "http://localhost:8000/v1/streak" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"message": "Hey! Streak time 🔥"}'

Response:

{
  "success": true,
  "message": "Streak bot started in background",
  "data": {
    "custom_message": "Hey! Streak time 🔥",
    "started_at": "2026-01-17T01:30:00.000000"
  }
}

Add Contact:

curl -X POST "http://localhost:8000/v1/contacts" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"nickname": "friend_username"}'

List Contacts:

curl -X GET "http://localhost:8000/v1/contacts" \
  -H "X-API-Key: your-api-key-here"

Remove Contact:

curl -X DELETE "http://localhost:8000/v1/contacts/friend_username" \
  -H "X-API-Key: your-api-key-here"

📁 Project Structure

TikTok-Streak-API/
├── api.py              # FastAPI app & routes
├── config.py           # Configuration (loads from .env)
├── streak_bot.py       # Main bot logic
├── requirements.txt    # Python dependencies
├── .env.example        # Environment template
├── .gitignore          # Git exclusions
├── run_api.bat         # Windows startup script
└── README.md           # This file

⚠️ Security Notes

  • Never commit .env - Contains your secrets
  • Never commit cookies.json - Contains session data
  • Never commit contacts.json - Contains user data
  • Use strong API keys - Generate random secure keys
  • Rotate Telegram tokens - If exposed, regenerate via @BotFather

📄 License

MIT License - See LICENSE file for details.


👤 Credits

Created by dewhush