A flexible and powerful webhook integration platform that allows you to bridge webhooks into your tools or internal integrations.
- π API Versioning: Support for versioned API endpoints (
/v1
,/latest
) - π Plugin System: Dynamic plugin loading and execution
- π οΈ Flexible Configuration: Extensive CLI and programmatic configuration options
- π Rich Documentation: Interactive API documentation with Swagger UI and ReDoc
- π Secure: Built-in security features and error handling
- π Logging: Comprehensive logging and error tracking
You can install via pip:
pip install webhook_bridge
Or install from source:
git clone https://github.com/loonghao/webhook_bridge.git
cd webhook_bridge
pip install -e .
- Launch the server:
webhook-bridge --host localhost --port 8000
- Test with a sample request:
curl -X POST "http://localhost:8000/v1/plugin/example" \
-H "Content-Type: application/json" \
-d '{"message": "Hello, World!"}'
- Access the API documentation:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
- Swagger UI:
webhook-bridge --help
--host
: Host to bind the server to (default: "0.0.0.0")--port
: Port to bind the server to (default: 8000)--log-level
: Logging level (DEBUG/INFO/WARNING/ERROR/CRITICAL)
--title
: API title--description
: API description--docs-url
: URL for API documentation--redoc-url
: URL for ReDoc documentation--openapi-url
: URL for OpenAPI schema
--plugin-dir
: Directory containing webhook plugins
WEBHOOK_BRIDGE_SERVER_PLUGINS
: Additional plugin directories (separated by system path separator)
Create a Python file in your plugin directory:
from typing import Dict, Any
from webhook_bridge.plugin import BasePlugin
class MyPlugin(BasePlugin):
"""Custom webhook plugin."""
def run(self, data: Dict[str, Any]) -> Dict[str, Any]:
"""Process webhook data.
Args:
data: Input data from webhook
Returns:
Dict[str, Any]: Processed result
Example:
{
"status": "success",
"data": {"key": "processed_value"}
}
"""
# Process your webhook data here
result = {
"status": "success",
"data": {"message": f"Processed: {data}"}
}
return result
The plugin must:
- Inherit from
BasePlugin
- Implement the
run
method - Return a dictionary containing at least:
status
: String indicating success or failuredata
: Dictionary containing the processed result
- Python 3.8 or higher
- nox for development environment management
- Clone the repository:
git clone https://github.com/loonghao/webhook_bridge.git
cd webhook_bridge
- Install nox:
pip install -r requirements-dev.txt
- Run tests:
nox -s pytest
- Run linting:
nox -s lint-fix
webhook_bridge/
βββ webhook_bridge/ # Main package directory
β βββ api/ # API endpoints
β βββ models/ # Data models
β βββ templates/ # HTML templates
βββ tests/ # Test files
βββ pyproject.toml # Project metadata and dependencies
βββ README.md # This file
GET api/v1/plugins
: List all available webhook plugins- Response 200:
{ "status_code": 200, "message": "success", "data": { "plugins": ["plugin1", "plugin2"] } }
- Response 200:
POST api/v1/plugin/{plugin_name}
: Execute a specific webhook plugin- Parameters:
plugin_name
: Name of the plugin to execute- Request body: JSON data to be processed by the plugin
- Response 200:
{ "status_code": 200, "message": "success", "data": { "plugin": "example", "src_data": {"key": "value"}, "result": { "status": "success", "data": {"key": "value"} } } }
- Error Responses:
- 404: Plugin not found
- 500: Plugin execution failed
- Parameters:
The API uses standard HTTP status codes and returns detailed error messages:
{
"status_code": 404,
"message": "Plugin not found",
"data": {
"error": "Plugin not found"
}
}
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request