Official Python SDK for the PinBridge API
Project description
PinBridge Python SDK
Official Python SDK for the PinBridge API.
Installation
pip install pinbridge-sdk
For local development from this monorepo:
pip install -e .[dev]
Requirements
- Python
>=3.10 - PinBridge API URL (default:
https://api.pinbridge.io) - Authentication via API key and/or bearer token
Client Initialization
from pinbridge_sdk import PinbridgeClient
client = PinbridgeClient(
base_url="https://api.pinbridge.io", # optional
api_key="pb_live_...", # optional
bearer_token=None, # optional
timeout=30.0, # optional
headers={"x-request-source": "my-app"},
)
Use as a context manager to close internal HTTP resources automatically:
with PinbridgeClient(api_key="pb_live_...") as client:
print(client.system.health().status)
Authentication Patterns
1. API key auth
from pinbridge_sdk import PinbridgeClient
with PinbridgeClient(api_key="pb_live_...") as client:
keys = client.api_keys.list()
2. Login to bearer token
from pinbridge_sdk import PinbridgeClient
from pinbridge_sdk.models import LoginRequest
with PinbridgeClient() as client:
auth = client.auth.login(LoginRequest(email="you@example.com", password="super-secret"))
client.set_bearer_token(auth.access_token)
print(client.auth.me().workspace.name)
3. Switching auth at runtime
client.set_api_key("pb_live_new")
client.set_bearer_token("new-jwt")
client.clear_auth() # removes both
Async Client
from pinbridge_sdk import AsyncPinbridgeClient
async def run() -> None:
async with AsyncPinbridgeClient(api_key="pb_live_...") as client:
pricing = await client.billing.pricing()
print(pricing.source)
Resource Guide
All sync resources are available on PinbridgeClient; async equivalents have identical names on AsyncPinbridgeClient.
System (client.system)
root()health()stripe_webhook(body, stripe_signature=...)
health = client.system.health()
print(health.status, health.database)
Auth (client.auth)
register(RegisterRequest | dict)login(LoginRequest | dict)me()get_profile()update_profile(ProfileUpdateRequest | dict)
API Keys (client.api_keys)
create(APIKeyCreate | dict)list()update(key_id, APIKeyUpdate | dict)revoke(key_id)
Pinterest (client.pinterest)
start_oauth()oauth_callback(code=..., state=..., follow_redirects=False)list_accounts()revoke_account(account_id)list_boards(account_id)create_board(BoardCreateRequest | dict)delete_board(board_id, account_id=...)
from pinbridge_sdk.models import BoardCreateRequest
accounts = client.pinterest.list_accounts()
boards = client.pinterest.list_boards(accounts[0].id)
created = client.pinterest.create_board(
BoardCreateRequest(account_id=accounts[0].id, name="SDK Board")
)
Pins and Jobs (client.pins, client.jobs)
client.pins.create(PinCreate | dict)client.pins.get(pin_id)client.pins.list(limit=50, offset=0)client.pins.delete(pin_id)client.jobs.get(job_id)
from pinbridge_sdk.models import PinCreate
pin = client.pins.create(
PinCreate(
account_id="...",
board_id="...",
title="Hello",
description="From SDK",
image_url="https://example.com/image.jpg",
idempotency_key="my-idempotency-key",
)
)
status = client.jobs.get(pin.id)
print(status.status)
Schedules (client.schedules)
create(ScheduleCreate | dict)get(schedule_id)list(limit=50, offset=0)cancel(schedule_id)
Webhooks (client.webhooks)
create(WebhookCreate | dict)list()get(webhook_id)update(webhook_id, WebhookUpdate | dict)delete(webhook_id)
Billing and Rate Meter (client.billing, client.rate_meter)
client.billing.pricing()client.billing.checkout(CheckoutRequest | dict)client.billing.portal()client.billing.status()client.rate_meter.get(account_id)
Typed Models
All methods return typed Pydantic models from pinbridge_sdk.models.
Use either model instances or plain dictionaries as method input.
from pinbridge_sdk.models import WebhookCreate
created = client.webhooks.create(
WebhookCreate(
url="https://example.com/hook",
secret="0123456789012345",
events=["pin.published", "pin.failed"],
)
)
Error Handling
Raised exceptions:
pinbridge_sdk.AuthenticationErrorpinbridge_sdk.NotFoundErrorpinbridge_sdk.ValidationErrorpinbridge_sdk.RateLimitErrorpinbridge_sdk.APIError
from pinbridge_sdk import APIError, PinbridgeClient
try:
with PinbridgeClient(api_key="bad") as client:
client.auth.me()
except APIError as exc:
print(exc.status_code, exc.message, exc.code)
Extending the SDK
You can register custom resources without changing core classes.
from pinbridge_sdk import PinbridgeClient
from pinbridge_sdk.resources.base import SyncAPIResource
class DiagnosticsResource(SyncAPIResource):
def ping(self):
return self._request("GET", "/healthz").json()
with PinbridgeClient(api_key="pb_live_...") as client:
client.register_resource("diagnostics", DiagnosticsResource)
print(client.diagnostics.ping())
This keeps new API groups low-risk: add models + resource class and register/bind it.
Testing, Formatting, Coverage
black .
ruff check .
pytest --cov=pinbridge_sdk --cov-config=.coveragerc --cov-report=term-missing --cov-report=xml
Coverage config file: .coveragerc
CI
GitHub Actions CI runs on push to main and on pull requests.
- Lint:
ruff check .+black --check . - Test + coverage:
pytest --cov=pinbridge_sdk ... - Build verification:
python -m build+twine check dist/*
Workflow file: .github/workflows/ci.yml
Publish to PyPI
Release workflow file: .github/workflows/publish.yml
Trigger options:
- Push a version tag (for example:
v0.1.0) - Manual
workflow_dispatchwith explicit version input
Detailed release runbook: RELEASING.md
Project details
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 pinbridge_sdk-0.1.4.tar.gz.
File metadata
- Download URL: pinbridge_sdk-0.1.4.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99f1cffaded9bda49f0301f48f3637554e8d35603b32a18e6beb195a4e065c10
|
|
| MD5 |
da570865f294cc5300edbdc57c93ea7c
|
|
| BLAKE2b-256 |
0485872ac5876a2e58ace6e3a6f3e39f612784df1e72a512af84405236774aad
|
Provenance
The following attestation bundles were made for pinbridge_sdk-0.1.4.tar.gz:
Publisher:
publish.yml on pinbridge/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pinbridge_sdk-0.1.4.tar.gz -
Subject digest:
99f1cffaded9bda49f0301f48f3637554e8d35603b32a18e6beb195a4e065c10 - Sigstore transparency entry: 984178233
- Sigstore integration time:
-
Permalink:
pinbridge/python-sdk@4d041254b8d5160b4c559660d5b43176b0695fcb -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/pinbridge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4d041254b8d5160b4c559660d5b43176b0695fcb -
Trigger Event:
push
-
Statement type:
File details
Details for the file pinbridge_sdk-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pinbridge_sdk-0.1.4-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caeaa30265430aeb8ef9d8f71700c1d731ee5d08b995ec9dc4fbf369eabf00ea
|
|
| MD5 |
778bc8ef5b7d3ffa9c57948c2f866dbb
|
|
| BLAKE2b-256 |
e82ab1cc57b2f8c5cd1eb0bdb90a33f77f7a35ad63eda19e4ec209d23c3a7216
|
Provenance
The following attestation bundles were made for pinbridge_sdk-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on pinbridge/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pinbridge_sdk-0.1.4-py3-none-any.whl -
Subject digest:
caeaa30265430aeb8ef9d8f71700c1d731ee5d08b995ec9dc4fbf369eabf00ea - Sigstore transparency entry: 984178241
- Sigstore integration time:
-
Permalink:
pinbridge/python-sdk@4d041254b8d5160b4c559660d5b43176b0695fcb -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/pinbridge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4d041254b8d5160b4c559660d5b43176b0695fcb -
Trigger Event:
push
-
Statement type: