Self-hosted integration platform for Python applications
Project description
PlugFn Python SDK
Self-hosted integration platform for Python applications
Native Python SDK with async/await support for building integrations with 75+ APIs.
Installation
pip install plugfn
Quick Start
import asyncio
from plugfn import PlugFn
from plugfn.providers import github_provider
async def main():
plug = PlugFn(
database=adapter,
auth=auth_provider,
base_url="https://myapp.com",
encryption_key="your-32-character-key-here!!!!",
integrations={
"github": {
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"scopes": ["repo", "issues", "user"]
}
}
)
plug.providers.register(github_provider)
# Execute an action
issue = await plug.github.issues.create(
user_id="user-123",
params={
"owner": "myorg",
"repo": "myrepo",
"title": "Bug report",
"body": "Something is broken"
}
)
print(f"Created issue #{issue['number']}")
if __name__ == "__main__":
asyncio.run(main())
Features
- ✅ Type hints: Full Python type hints
- ✅ Async/await: Native async support
- ✅ OAuth built-in: Complete OAuth 2.0 flow
- ✅ Webhooks: Real-time event handling with FastAPI/Flask
- ✅ Workflows: Chain actions together
- ✅ Pydantic models: Data validation with Pydantic
- ✅ Testing utilities: Mock providers and pytest fixtures
Coming Soon
The Python SDK is under active development. Current status:
- 🚧 Core architecture (in progress)
- 📋 Provider implementations (planned)
- 📋 HTTP adapters (FastAPI, Flask) (planned)
- 📋 CLI tool integration (planned)
Planned API
Basic Usage
from plugfn import PlugFn, Config
from plugfn.providers import GitHubProvider, SlackProvider
# Configure
config = Config(
base_url="https://myapp.com",
encryption_key="your-key",
integrations={
"github": {"client_id": "...", "client_secret": "..."},
"slack": {"client_id": "...", "client_secret": "..."}
}
)
plug = PlugFn(config)
plug.providers.register(GitHubProvider())
plug.providers.register(SlackProvider())
Webhooks
from fastapi import FastAPI
from plugfn.adapters.fastapi import mount_plugfn
app = FastAPI()
mount_plugfn(app, plug, prefix="/api/plugfn")
@plug.webhooks.on("github", "issues.opened")
async def handle_issue(event):
await plug.slack.chat.post_message(
user_id=event.user_id,
params={
"channel": "#engineering",
"text": f"New issue: {event.data.issue.title}"
}
)
Workflows
from plugfn import Workflow
workflow = (
Workflow("github-to-linear")
.trigger(plug.github.on("issues.opened"))
.action(lambda ctx: plug.linear.issues.create(
user_id=ctx.user_id,
params={
"team_id": "team-123",
"title": ctx.trigger.issue.title,
"description": ctx.trigger.issue.body
}
))
.action(lambda ctx: plug.slack.chat.post_message(
user_id="system",
params={
"channel": "#synced",
"text": f"Synced issue to Linear: {ctx.data.linear_issue.url}"
}
))
.enable()
)
Development
# Install dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type checking
mypy plugfn
# Linting
ruff check plugfn
Architecture
python/
├── plugfn/
│ ├── __init__.py
│ ├── core/
│ │ ├── plug_fn.py
│ │ ├── connection_manager.py
│ │ ├── action_executor.py
│ │ └── workflow_engine.py
│ ├── auth/
│ │ ├── oauth.py
│ │ ├── api_key.py
│ │ └── jwt.py
│ ├── providers/
│ │ ├── github.py
│ │ ├── slack.py
│ │ ├── discord.py
│ │ ├── linear.py
│ │ └── stripe.py
│ ├── storage/
│ │ ├── connection_storage.py
│ │ ├── workflow_storage.py
│ │ └── adapters/
│ ├── middleware/
│ │ ├── retry.py
│ │ ├── rate_limiter.py
│ │ ├── cache.py
│ │ └── logging.py
│ ├── webhooks/
│ │ └── webhook_handler.py
│ ├── adapters/
│ │ ├── fastapi.py
│ │ └── flask.py
│ ├── testing/
│ │ ├── mock_provider.py
│ │ └── fixtures.py
│ └── types.py
├── tests/
├── examples/
└── docs/
Contributing
See CONTRIBUTING.md for guidelines.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
plugfn-0.0.1.tar.gz
(42.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
plugfn-0.0.1-py3-none-any.whl
(34.0 kB
view details)
File details
Details for the file plugfn-0.0.1.tar.gz.
File metadata
- Download URL: plugfn-0.0.1.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8394e0efb41b99331d31f93aaebaf788de0f05eb0684287db210e773d880e455
|
|
| MD5 |
d77d9399352e92f3a6ed2c5dda774067
|
|
| BLAKE2b-256 |
d5ba0ecce048ea738386331bed8d28fcd0bf406410d7d0c6957e52f598f297c9
|
File details
Details for the file plugfn-0.0.1-py3-none-any.whl.
File metadata
- Download URL: plugfn-0.0.1-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8436ee772407bde974b300bc8176c7cd82df4da848baf34f1cd17e3f92711884
|
|
| MD5 |
fe1b36d2e4ef3a18673d0bf1ea0ed07f
|
|
| BLAKE2b-256 |
fbeaacecb43a996c5bcb96c0441fe5857e96e93132e5599bdb693b2556d603c4
|