Skip to content

Getting Started

SaeedX edited this page Jun 25, 2026 · 1 revision

Getting Started

This page walks you through running the API locally for development.

Requirements

  • Python 3.10+ (3.11 recommended)
  • A Neon PostgreSQL database (or any PostgreSQL connection string)
  • pip / venv

1. Clone the repository

git clone https://github.com/TSun-FreeFire/TSun-FF-JWT-API.git
cd TSun-FF-JWT-API

2. Create a virtual environment (recommended)

python -m venv .venv
# Linux / macOS
source .venv/bin/activate
# Windows (PowerShell)
.venv\Scripts\Activate.ps1

3. Install dependencies

pip install -r requirements.txt

The pinned dependencies are:

Package Purpose
flask Web framework
httpx Async HTTP client
protobuf==6.33.5 Protocol Buffers runtime
pycryptodome AES encryption
gunicorn + gevent Production WSGI server
python-dotenv Loads .env
psycopg2-binary PostgreSQL driver

4. Configure environment variables

Copy the example file and fill in your own values:

cp .env.example .env
# Master API Key (never expires, used by the frontend by default)
VALID_API_KEY=Your_Api_Key

# Admin Key (used to generate / revoke temporary API keys)
ADMIN_KEY=Your_admin_Key

# Neon PostgreSQL connection string
DATABASE_URL=your_neon_database_connection_string

See Configuration for the full list, including the optional remote config.json.

5. Run the development server

python app.py

The app starts on http://127.0.0.1:5000 with Flask's debug server. On startup it will:

  1. Download the runtime config.json (release version + login URL).
  2. Validate that VALID_API_KEY, ADMIN_KEY and DATABASE_URL are set.
  3. Connect to PostgreSQL and create the api_keys table if it doesn't exist.

If any required variable or the database connection is missing, the process exits immediately with a CRITICAL ERROR message.

6. Make your first request

curl "http://127.0.0.1:5000/v1/auth/Your_Api_Key?uid=12345678&password=YOURGUESTPASSWORD"

Open http://127.0.0.1:5000/ in a browser to use the built‑in dashboard ("TSun Jwt Maker").

For production, do not use python app.py (debug server). Use Gunicorn / Docker instead — see Deployment.

Clone this wiki locally