Skip to main content

Public Python SDK for calling remote functions, with sync and async clients.

Project description

paperclip-sdk

Python SDK for calling server-hosted Paperclip tools from scripts, workers, web apps, and async services.

Use it when you want to keep business logic, pricing rules, private workflows, or customer-specific functionality on the server while calling it from Python through a small client.

Install

poetry add paperclip-sdk

or

pip install paperclip-sdk

Configure authentication

export LEASEKEY_API_KEY="your-api-key"

Quickstart

Sync

from paperclip_sdk import Paperclip

with Paperclip() as paperclip: result = paperclip.tools.core.hello_world(name="Ada") print(result)

Async

import asyncio from paperclip_sdk import AsyncPaperclip

async def main() -> None: async with AsyncPaperclip() as paperclip: result = await paperclip.tools.core.hello_world(name="Ada") print(result)

asyncio.run(main())

Real-world examples

The tool names below are illustrative. Replace them with the tools your Paperclip server exposes.

Keep pricing logic on the server

from decimal import Decimal from paperclip_sdk import Paperclip

def quote_total(customer_id: str, sku: str, quantity: int) -> Decimal: with Paperclip() as paperclip: result = paperclip.tools.pricing.compute_quote( customer_id=customer_id, sku=sku, quantity=quantity, )

return Decimal(result["total"])

Use it inside an async API

from fastapi import FastAPI from paperclip_sdk import AsyncPaperclip

app = FastAPI()

@app.post("/tickets/{ticket_id}/summarize") async def summarize_ticket(ticket_id: str) -> dict: async with AsyncPaperclip() as paperclip: return await paperclip.tools.support.summarize_ticket( ticket_id=ticket_id, )

Build a remote plugin system

from paperclip_sdk import Paperclip

with Paperclip() as paperclip: result = paperclip.tools.plugins.transform_payload( payload={ "source": "stripe", "event": "invoice.paid", } ) print(result)

Reuse a tool handle

from paperclip_sdk import Paperclip

with Paperclip() as paperclip: enrich_contact = paperclip.tools.crm.enrich_contact

print(enrich_contact(email="ada@example.com"))
print(enrich_contact(email="grace@example.com"))

Reuse an async tool handle

import asyncio from paperclip_sdk import AsyncPaperclip

async def main() -> None: async with AsyncPaperclip() as paperclip: summarize = paperclip.tools.support.summarize_ticket

    print(await summarize(ticket_id="T-100"))
    print(await summarize(ticket_id="T-101"))

asyncio.run(main())

Notes

  • Tools are available under paperclip.tools.<namespace>.<name>(...)
  • The default base URL is https://leasekey.org, so passing base_url is optional
  • The SDK automatically sends User-Agent: paperclip-sdk/<version>
  • The SDK also sends X-Leasekey-SDK-Version: <version>
  • Built-in retry behavior covers retryable transport failures and these HTTP statuses: 408, 425, 429, 502, 503, 504

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

paperclip_sdk-0.4.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paperclip_sdk-0.4.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file paperclip_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: paperclip_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for paperclip_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0c290b7c9d266dbcf1dbe4751d914b1cccf72939f625fa464bd7d02a6e659be9
MD5 5189f9840aa0787a88cae12fd96c4b55
BLAKE2b-256 c85a3f6461b0d390ea7208b153e41a4ed5a2c87bf6a6246d42c10114ea6860d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperclip_sdk-0.4.0.tar.gz:

Publisher: publish.yml on janfilips/paperclip-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file paperclip_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: paperclip_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for paperclip_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 213e694b2e444d64b332ed9350e41385abf61c85845fa958f11b7e1f05dce8d2
MD5 464cd27261e393889fc582c639830235
BLAKE2b-256 c82c8eebad04b1570e0df665092127612be86000acbb95d214bbef05fc52c0f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperclip_sdk-0.4.0-py3-none-any.whl:

Publisher: publish.yml on janfilips/paperclip-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page