Metadata-Version: 2.5
Name: airboxhq
Version: 0.1.0
Summary: Python SDK for the Airbox API: WhatsApp and Instagram messages through one REST API.
Project-URL: Source, https://github.com/airboxhq/airbox-python
License-Expression: MIT
License-File: LICENSE
Keywords: airbox,api,instagram,messaging,sdk,whatsapp
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Communications :: Chat
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# Airbox Python SDK

WhatsApp and Instagram messages through one REST API, from Python.

> Early release (0.1.0): sending and reading messages. Media, templates, consent and channels come next.

## Install

```bash
pip install airboxhq
```

Python 3.9 or newer. No dependencies.

## Send a message

```python
import os

from airboxhq import Airbox

client = Airbox(api_key=os.environ["WHATSAPP_API_KEY"])

data = client.messages.send(
    to="+77011234567",
    channel="whatsapp",
    type="text",
    text={"body": "Your order is ready"},
    idempotency_key="order-1042",
)

print(data)
```

A test key sends to the simulator, so you can try every call before connecting a number.

## Read a message back

```python
message = client.messages.get(data["id"])
print(message["status"])
```

## With asyncio

```python
import asyncio
import os

from airboxhq import AsyncAirbox


async def main():
    async with AsyncAirbox(api_key=os.environ["WHATSAPP_API_KEY"]) as client:
        data = await client.messages.send(to="+77011234567", channel="whatsapp", type="text", text={"body": "Hi"})
        print(data)


asyncio.run(main())
```

## Errors

A refused request raises `airboxhq.AirboxError` with the API's own code and the request id:

```python
from airboxhq import AirboxError

try:
    client.messages.send(to="+77011234567", channel="whatsapp", type="text", text={"body": "Hi"})
except AirboxError as error:
    print(error.code, error.request_id)
```

## License

MIT
