Metadata-Version: 2.4
Name: wyro
Version: 0.2.0
Summary: Official Python client for the wyro API: publish and schedule posts on Instagram, TikTok, LinkedIn, X and more.
License: MIT
Project-URL: Homepage, https://wyroapi.com
Project-URL: Documentation, https://wyroapi.com/en/docs/sdks
Keywords: wyro,social media,instagram,tiktok,linkedin,api,sdk,agents
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"

# wyro (Python)

Official Python client for the [wyro API](https://wyroapi.com): publish and schedule posts on Instagram, Facebook, TikTok, LinkedIn, X, Threads, YouTube and Pinterest from your app or agent.

- Python 3.9+, **no dependencies** (standard library `urllib`), typed (`TypedDict`, `py.typed`).
- Retries on `429` and `5xx`, honoring `Retry-After`. Creates are only retried when you pass an `idempotency_key`.
- Typed errors (`WyroError`) with `code`, `message`, `fix` and `details`.
- Webhook signature verification.


## Quick start

```python
import os, uuid
from wyro import Wyro

wyro = Wyro(api_key=os.environ["WYRO_API_KEY"])  # no key yet? POST https://wyroapi.com/v1/sandbox

post = wyro.posts.create(
    {"text": "Launching something new", "platforms": ["instagram", "linkedin"], "media": [{"url": "https://…/a.jpg"}]},
    idempotency_key=str(uuid.uuid4()),
)
print(post["status"], post["preview_url"])
```

## Resources

| | |
| --- | --- |
| Posts | `posts.create(post, idempotency_key=…)` (with `overrides`, `first_comment`, `queue`), `posts.get(id)`, `posts.list(limit=, cursor=)`, `posts.iterate()`, `posts.reschedule(id, when)`, `posts.cancel(id)`, `posts.bulk(csv, dry_run=False)` |
| Queue | `queue.get()`, `queue.set(slots, timezone=None)`, `queue.next(count)` |
| Limited keys | `keys.create(scopes, name=None)`, `keys.list()`, `keys.revoke(id)` |
| Accounts | `accounts.list()`, `accounts.disconnect(id)` |
| Connect | `connect(platform, return_url=None, idempotency_key=…)` |
| Media | `media.upload(data, content_type, filename, uploader=None)`, `media.upload_small(...)`, `media.create_upload(...)` |
| Webhooks | `webhooks.set(url)`, `webhooks.get()`, `webhooks.delete()` |
| Partners | `partner.workspaces.create/list/get/delete/rotate_key/create_key/list_keys`, `for_client(external_id)` |

Files over 4 MB get an upload ticket (`media.create_upload`); pass `uploader(ticket, data, auth_headers) -> url` to `media.upload` to send the bytes where the ticket says.

### Partners

```python
wyro = Wyro(partner_token=os.environ["WYRO_PARTNER_TOKEN"])
wyro.partner.workspaces.create("client-123", idempotency_key="create-client-123")

client = wyro.for_client("client-123")  # sends X-Wyro-External-Id
client.connect("instagram", "https://yourapp.com/integrations")
```

### Errors

```python
from wyro import WyroError

try:
    wyro.posts.create({"text": "Hello", "platforms": ["linkedin"]})
except WyroError as e:
    if e.code == "duplicate_post":
        print("Already posted:", e.details["existing_post_id"])
    else:
        raise
```

### Webhooks

```python
from wyro import verify_signature

# raw_body: the request body exactly as received (bytes or str)
ok = verify_signature(secret, request.headers["X-Wyro-Timestamp"], raw_body, request.headers["X-Wyro-Signature"])
```

Dedupe events on `id`: retries (header `X-Wyro-Attempt`) keep the same id. Contract: https://wyroapi.com/en/docs/webhooks

## Tests

```
pip install pytest && pytest
```

## Español

SDK oficial de Python para la API de wyro. Sin dependencias, con tipos, reintentos ante `429` y `5xx` (respetando `Retry-After`; las creaciones solo se reintentan con `idempotency_key`), errores tipados (`WyroError` con `code`, `message`, `fix`) y verificación de firmas de webhooks (`verify_signature`).


```python
from wyro import Wyro

wyro = Wyro(api_key=os.environ["WYRO_API_KEY"])
post = wyro.posts.create({"text": "Lanzamos algo nuevo", "platforms": ["instagram"], "media": [{"url": "https://…"}]}, idempotency_key=str(uuid.uuid4()))
```

Documentación: https://wyroapi.com/docs/sdks

## License

MIT
