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
Metadata
Release files for plugfn 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| plugfn-0.0.1.tar.gz | 42.4 kB | Without provenance | Details for plugfn-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plugfn-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for plugfn-0.0.1-py3-none-any.whl |
Total release size: 76.4 kB
Release files / plugfn-0.0.1.tar.gz
| Download URL | plugfn-0.0.1.tar.gz |
|---|---|
| Size | 42.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8394e0efb41b99331d31f93aaebaf788de0f05eb0684287db210e773d880e455
|
|
BLAKE2b-256 checksum How to use checksums |
d5ba0ecce048ea738386331bed8d28fcd0bf406410d7d0c6957e52f598f297c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / plugfn-0.0.1-py3-none-any.whl
| Download URL | plugfn-0.0.1-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8436ee772407bde974b300bc8176c7cd82df4da848baf34f1cd17e3f92711884
|
|
BLAKE2b-256 checksum How to use checksums |
fbeaacecb43a996c5bcb96c0441fe5857e96e93132e5599bdb693b2556d603c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for plugfn 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.