Python SDK for BundleUp
Project description
BundleUp Python SDK
Official Python SDK for the BundleUp API.
Installation
pip install bundleup-sdk
Features
- Pythonic API Design - Context managers, property decorators, and Python best practices
- Custom Exception Hierarchy - Specific exception types for different error scenarios
- Connection Pooling - Efficient HTTP connection reuse with
requests.Session - Type Hints - Full type annotation support for better IDE integration
- Comprehensive Testing - 70+ unit tests with mocked HTTP requests
Usage
Initialize the Client
The SDK supports both regular initialization and context manager usage:
from bundleup import BundleUp
# Regular usage
client = BundleUp("your-api-key")
# Context manager (automatically closes connections)
with BundleUp("your-api-key") as client:
connections = client.connections.list()
Working with Connections
# List all connections
connections = client.connections.list()
# Create a new connection
connection = client.connections.create({
"name": "My Connection",
"integration_id": "integration-id"
})
# Retrieve a specific connection
connection = client.connections.retrieve("connection-id")
# Update a connection
updated = client.connections.update("connection-id", {
"name": "Updated Name"
})
# Delete a connection
client.connections.delete("connection-id")
Working with Integrations
# List all integrations
integrations = client.integrations.list()
# Retrieve a specific integration
integration = client.integrations.retrieve("integration-id")
Working with Webhooks
# List all webhooks
webhooks = client.webhooks.list()
# Create a new webhook
webhook = client.webhooks.create({
"url": "https://example.com/webhook",
"events": ["connection.created"]
})
# Update a webhook
updated = client.webhooks.update("webhook-id", {
"url": "https://example.com/new-webhook"
})
# Delete a webhook
client.webhooks.delete("webhook-id")
Using the Proxy API
# Create a proxy instance
proxy = client.proxy("connection-id")
# Make requests to the connected service
response = proxy.get("/users")
response = proxy.post("/users", {"name": "John"})
response = proxy.put("/users/123", {"name": "Jane"})
response = proxy.patch("/users/123", {"email": "jane@example.com"})
response = proxy.delete("/users/123")
Using the Unify API
The Unify API provides a standardized interface across different integrations.
Chat
# Get unified chat channels
channels = client.unify("connection-id").chat.channels()
# With pagination parameters
channels = client.unify("connection-id").chat.channels({
"limit": 50,
"include_raw": True
})
Git
unify = client.unify("connection-id")
# Get repositories
repos = unify.git.repos()
# Get pull requests
pulls = unify.git.pulls()
# Get tags
tags = unify.git.tags()
# Get releases
releases = unify.git.releases()
Project Management
# Get issues
issues = client.unify("connection-id").pm.issues()
# With pagination
issues = client.unify("connection-id").pm.issues({
"limit": 100,
"after": "cursor-id"
})
Error Handling
The SDK uses a hierarchy of custom exceptions:
from bundleup import BundleUp
from bundleup.exceptions import (
BundleUpError, # Base exception
ValidationError, # Input validation errors
APIError, # General API errors
AuthenticationError, # 401 errors
NotFoundError, # 404 errors
RateLimitError # 429 errors
)
try:
client = BundleUp("your-api-key")
connections = client.connections.list()
except AuthenticationError:
print("Invalid API key")
except NotFoundError:
print("Resource not found")
except RateLimitError:
print("Rate limit exceeded")
except APIError as e:
print(f"API error: {e.status_code} - {e}")
except ValidationError as e:
print(f"Validation error: {e}")
Advanced Usage
Custom Session
You can provide your own requests.Session for advanced configuration:
import requests
from bundleup import BundleUp
session = requests.Session()
session.timeout = 30
session.verify = True
client = BundleUp("your-api-key", session=session)
Query Parameters
The list() method supports query parameters:
# List with filters
connections = client.connections.list(status="active", limit=50)
Requirements
- Python 3.8+
- requests
- typing-extensions
License
MIT License - see LICENSE file for details.
Documentation
For more information, visit https://docs.bundleup.io
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
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
File details
Details for the file bundleup_sdk-0.1.0.tar.gz.
File metadata
- Download URL: bundleup_sdk-0.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a7a58bd903dafa541db1947ace001f0c6a0fd201ae15e6a9cb13605465e6b42
|
|
| MD5 |
ea2fdfc3d1e6ac9f8fe270a9b42ece31
|
|
| BLAKE2b-256 |
858bbe0d74cd4f0ed3fd1d3e0b46cb8aedc6d1b99cd40306abeefac6dc3bb943
|
File details
Details for the file bundleup_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bundleup_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2fa3859dd0525dddc47761c650bde45839ec28368ea1826bade29008511c24b
|
|
| MD5 |
dd44c5288263298b22ffbb98995776a1
|
|
| BLAKE2b-256 |
28a80c4f6df95b22fc725d850ad3627c2131e98fe2f781563b1d5e57e8901777
|