Metadata-Version: 2.5
Name: pandafile
Version: 0.2.0
Summary: Official Pandafile SDK: send large files with resumable uploads, file requests, e-signatures and webhooks.
Project-URL: Homepage, https://pandafile.co/developers/sdks
Project-URL: Documentation, https://pandafile.co/developers
Project-URL: API reference, https://pandafile.co/developers/api
Project-URL: Repository, https://github.com/pandafileco/pandafile-python
Project-URL: Issues, https://github.com/pandafileco/pandafile-python/issues
Author-email: 3XAYA LTD <hello@pandafile.co>
License-Expression: MIT
License-File: LICENSE
Keywords: file transfer,large files,pandafile,resumable,sdk,tus,upload,webhooks
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Communications :: File Sharing
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx<1,>=0.24
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

# pandafile

The official Python SDK for [Pandafile](https://pandafile.co): send files of any size with resumable uploads, collect
files with file requests, get documents signed and react to webhooks.

- Python 3.9+, one dependency (`httpx`). Sync **and** async clients.
- `transfers.send()` does everything: create, upload (tus, chunked, parallel, resumable), complete, return the link.
- Automatic `Idempotency-Key` on every POST/PATCH/PUT, retries with backoff on 429/5xx honouring `Retry-After`,
  typed errors, auto-pagination, webhook signature verification, TypedDicts generated from the OpenAPI document.

The API is included with Pandafile Pro and Team. Create a key in **Dashboard → Domain & API**.

## Install

```sh
pip install pandafile
```

## Quick start

```python
from pandafile import Pandafile

pf = Pandafile()  # reads PANDAFILE_API_KEY (pf_live_… or pf_test_…)

result = pf.transfers.send(
    ["final-cut.mov", "stills/"],          # folders keep their structure
    recipients=["client@example.com"],
    title="Final cut",
    on_progress=lambda p: print(f"{p.percent:.1f} %"),
)
print(result.url)  # https://pandafile.co/d/k3x9q2m7ab
```

Files can be paths, `(name, bytes)`, `{"name": ..., "data": ...}`, `{"path": ..., "name": ...}` or binary file objects.

### Async

```python
import asyncio
from pandafile import AsyncPandafile

async def main():
    async with AsyncPandafile() as pf:
        result = await pf.transfers.send(["film.mov"])
        async for t in pf.transfers.list():
            print(t["id"], t["title"])

asyncio.run(main())
```

## Resumable sends

```python
import json, pathlib
p = pathlib.Path("send-state.json")
state = json.loads(p.read_text()) if p.exists() else None
result = pf.transfers.send(["huge.mxf"], state=state, on_state=lambda s: p.write_text(json.dumps(s)))
```

Finished files are skipped and the unfinished one continues at the byte the server has.

## Every endpoint

```python
pf.me.retrieve()
for t in pf.transfers.list(view="active"):        # auto-pagination
    ...
page = pf.transfers.list(limit=50).page()          # one page: page.data, page.has_more, page.next_page()
pf.transfers.retrieve("k3x9q2m7ab")
pf.transfers.update("k3x9q2m7ab", title="v2", password="blue-river-42")
pf.transfers.add_recipients("k3x9q2m7ab", ["producer@example.com"])
pf.transfers.delete("k3x9q2m7ab")

pf.requests.create(title="Photos from the wedding")
draft = pf.signatures.create("nda.pdf")
pf.signatures.send(draft["id"], signers=[{"name": "Ada", "email": "ada@example.com"}],
                   fields=[{"signer": 0, "kind": "signature", "page": 0, "x": 0.1, "y": 0.8, "w": 0.3, "h": 0.06}])
pf.branding.update(name="Studio Nord", color="#1F7A4D")
pf.team.invite(["sam@example.com"])
pf.events.list(since="2026-11-25T00:00:00Z", type="transfer.downloaded")
pf.hooks.create(url="https://example.com/pandafile-webhook", events=["transfer.ready"])
pf.request("GET", "/me")                           # anything else, by hand
```

Responses are plain dicts; `pandafile.types` has a `TypedDict` for each (`Transfer`, `TransferDetail`, `Event`, …).

## Errors

```python
from pandafile import NotFoundError, PandafileError

try:
    pf.transfers.retrieve("nope1234")
except NotFoundError as e:
    print(e.code)                                  # resource_missing
except PandafileError as e:
    print(e.type, e.code, e.status, e.request_id, e.param)
```

Classes: `InvalidRequestError` (`NotFoundError`), `AuthenticationError`, `PermissionDeniedError`, `IdempotencyError`,
`RateLimitError` (`retry_after`), `APIError`, `APIConnectionError`, `UploadError`, `SignatureVerificationError`.

## Webhooks

```python
from flask import Flask, request, abort
from pandafile import webhooks

app = Flask(__name__)

@app.post("/pandafile-webhook")
def hook():
    body = request.get_data()                      # the raw bytes
    if not webhooks.verify(body, request.headers.get("Pandafile-Signature"), SECRET, tolerance=300):
        abort(400)
    event = request.get_json()
    return "", 200
```

`webhooks.construct_event(body, header, secret)` verifies and parses (raises `SignatureVerificationError`).
`Pandafile.webhooks` is the same module.

## Options

```python
Pandafile(api_key="pf_live_…", base_url="https://pandafile.co", max_retries=3, timeout=60.0, http_client=None)
```

`pf.last_response["headers"]` holds the `ratelimit-*` headers of the last call.

## Links

- Guide: https://pandafile.co/developers
- API reference: https://pandafile.co/developers/api
- SDKs and CLI: https://pandafile.co/developers/sdks
