A FastAPI application that bridges KoFi webhooks to WebSocket connections, enabling real-time notifications of KoFi events.
- Webhook endpoint for KoFi notifications
- WebSocket endpoint for real-time updates
- Verification token-based security
- Docker support
- Python 3.9 or higher
- Docker (optional, for containerized deployment)
git clone https://github.com/EventKit-Stream/KoFi-WebSocket.git
cd KoFi-WebSocket
pip install -r requirements.txt
To run the application locally, use the following command:
fastapi run ./app/main.py --host 0.0.0.0 --port 8000
The host
and port
are optional.
Build and run the Docker container:
docker build -t kofi-websocket .
docker run -p 8000:8000 kofi-websocket
Connect to the WebSocket endpoint using a verification token:
ws://localhost:8000/ws/{verification_token}
Send a POST request to the webhook endpoint with the required data:
POST /webhook
Content-Type: application/json
{
"data": {
"verification_token": "your_token",
"some_key": "some_value"
}
}
You can configure the application using the following environment variables:
HOST
: The host address to bind the server (default:0.0.0.0
)PORT
: The port to bind the server (default:8000
)
When running with Docker, you can pass environment variables using the -e
flag:
docker run -p 8000:8000 -e HOST=0.0.0.0 -e PORT=8000 kofi-websocket
Run the tests using pytest:
pytest
To check test coverage:
pytest --cov=app tests/ --cov-report=term-missing
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries or support, please contact [email protected].