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.1.tar.gz (8.7 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.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paperclip_sdk-0.4.1.tar.gz
  • Upload date:
  • Size: 8.7 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.1.tar.gz
Algorithm Hash digest
SHA256 8dcc0ba1088f19378329e91fd51247bc4d3e83e38bb4a7ee393668080e6b9977
MD5 6c1dd85e4bda0f0df8d3d4d7ad1040c9
BLAKE2b-256 b7a4d9ade620bd4aabdd71a9f64b8b891aeac3a356d3056c65909cb7e7fffdd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperclip_sdk-0.4.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: paperclip_sdk-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3029b3ffb577905f8f8abb5972d5e465db54c2df3b49d9654fd001fc50d3359
MD5 2cb7ecfee2e1aa5ee675f1e70d73f049
BLAKE2b-256 9985f4573794574e8a2839bd93895e9e626c1b7d3fcd61020e83766859849b8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperclip_sdk-0.4.1-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