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())

Discover available tools

Sync

from paperclip_sdk import Paperclip

with Paperclip() as paperclip:
    print(paperclip.list_tools())

Async

import asyncio

from paperclip_sdk import AsyncPaperclip


async def main() -> None:
    async with AsyncPaperclip() as paperclip:
        print(await paperclip.list_tools())


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>(...)
  • Registered tools can be discovered through paperclip.list_tools()
  • 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.6.0.tar.gz (9.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.6.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paperclip_sdk-0.6.0.tar.gz
  • Upload date:
  • Size: 9.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.6.0.tar.gz
Algorithm Hash digest
SHA256 286c3314ba40480beb000a5661b740e30de8cffca436b963fd32e651d54d9417
MD5 dc03ed7e121aaaea97d8d726a18032cb
BLAKE2b-256 4b8346849bf7ba0071e20076169aa13f23905ddc4ade808dd4add0a96dcb1ab7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: paperclip_sdk-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bcd8f678317b54571e85bf1807626aeb342d3688e7ba44025eac5469bb2ac786
MD5 6935a616dfaf58fa14d991a7e0ec84dd
BLAKE2b-256 2a89b1b60b27eb238631b66f15cf37db100a4cda342f304dfea42990be88f7fb

See more details on using hashes here.

Provenance

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