- Python 3.8 or higher
- pip (Python package installer)
-
Clone the repository
git clone https://github.com/smswithoutborders/RelaySMS-CAPTCHA-Server.git cd RelaySMS-CAPTCHA-Server -
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env
Edit the
.envfile with your configuration settings. -
Run the server
uvicorn app:app --host 0.0.0.0 --port 8000 --reload
The server will be available at http://localhost:8000
http://localhost:8000/v1
All endpoints require authentication using either:
client_id(for CAPTCHA operations)client_secret(for token verification)
POST /v1/new
Generate a new CAPTCHA challenge.
Request Body:
{
"client_id": "your_client_id"
}Response:
{
"challenge_id": "unique_challenge_id",
"image": "base64_encoded_captcha_image"
}Status Codes:
200- Success401- Invalid client ID503- CAPTCHA service unavailable
POST /v1/solve
Submit an answer to a CAPTCHA challenge.
Request Body:
{
"client_id": "your_client_id",
"challenge_id": "challenge_id_from_new_endpoint",
"answer": "captcha_solution"
}Response:
{
"success": true,
"message": "CAPTCHA solved successfully.",
"token": "challenge_id-verification_token"
}Status Codes:
200- Success (checksuccessfield for actual result)400- Missing required fields or challenge already used401- Invalid client ID404- Challenge ID not found or expired
POST /v1/verify
Verify a CAPTCHA token obtained from solving a challenge.
Request Body:
{
"client_secret": "your_client_secret",
"token": "challenge_id-verification_token"
}Response:
{
"success": true,
"message": "Token verified successfully."
}Status Codes:
200- Success (checksuccessfield for actual result)400- Missing required fields401- Invalid client secret
- Request a CAPTCHA: Call
/v1/newwith yourclient_idto get a challenge ID and image - Display the CAPTCHA: Show the base64-encoded image to the user
- Collect user input: Get the CAPTCHA solution from the user
- Solve the CAPTCHA: Call
/v1/solvewith the challenge ID and answer to get a verification token - Verify the token: Use
/v1/verifywith yourclient_secretand the token to confirm completion
This project is licensed under the GPL-3.0-only License. See the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request