Metadata-Version: 2.4
Name: brenox-sdk
Version: 0.1.0
Summary: Official Python SDK for the Brenox realtime communication platform (server / API-key integrations)
Project-URL: Homepage, https://www.breno-x.com/docs?sdk=python&v=0.1.0
Project-URL: Documentation, https://www.breno-x.com/docs?sdk=python
Project-URL: Repository, https://github.com/brainArt16/brenox-python
Project-URL: Issues, https://github.com/brainArt16/brenox-python/issues
Author: Brenox
License-Expression: MIT
License-File: LICENSE
Keywords: api,brenox,chat,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.9; extra == 'dev'
Description-Content-Type: text/markdown

# Official Python SDK for [Brenox](https://www.breno-x.com) — server-side API key integrations.

- **Documentation:** [www.breno-x.com/docs](https://www.breno-x.com/docs?sdk=python&v=0.1.0)
- **Requires:** Python 3.10+

## Install

```bash
pip install brenox-sdk
# or: uv add brenox-sdk
```

## Quick start

Create an app and API key in the [developer console](https://www.breno-x.com), then:

```python
import os
from brenox import BrenoxServer

server = BrenoxServer(
    base_url=os.environ.get("BRENOX_API_URL", "https://api.breno-x.com"),
    api_key=os.environ["BRENOX_API_KEY"],  # bx_test_* or bx_live_*
)

user = server.users.provision(external_id="user-123", username="alice")
channel = server.channels.create(name="general")
server.messages.send(
    channel_id=channel.id,
    external_id="user-123",
    content="Hello from Python!",
)

# Embed flow — issue a JWT for @brenox/react on the frontend (never expose the API key)
session = server.sessions.create(external_id="user-123", channel_id=channel.id)
# return session.token to the browser
```

### FastAPI sketch

```python
from fastapi import FastAPI
from brenox import BrenoxServer
import os

app = FastAPI()
brenox = BrenoxServer(
    base_url=os.environ["BRENOX_API_URL"],
    api_key=os.environ["BRENOX_API_KEY"],
)

@app.post("/chat/session")
def create_chat_session(external_id: str, channel_id: int):
    brenox.users.provision(external_id=external_id)
    session = brenox.sessions.create(
        external_id=external_id,
        channel_id=channel_id,
    )
    return {
        "token": session.token,
        "workspace_id": session.workspace_id,
        "channel_id": session.channel_id,
        "environment": session.environment,
    }
```

Use `@brenox/sdk` + `@brenox/react` in the browser with the returned `token`.

## API surface

| Resource | Methods |
|----------|---------|
| `server.users` | `provision` |
| `server.sessions` | `create` |
| `server.channels` | `create` |
| `server.messages` | `send`, `list` |

Auth: `Authorization: Bearer <api_key>` by default, or `auth_style="x-api-key"`.

| Key prefix | Use |
|------------|-----|
| `bx_test_*` | Development / sandbox |
| `bx_live_*` | Production |

Sandbox keys are rejected when `BRENOX_ENV` or `ENV` is `production`.

## Links

- [Documentation](https://www.breno-x.com/docs?sdk=python&v=0.1.0)
- [Developer console](https://www.breno-x.com)
- [TypeScript SDK](https://github.com/brainArt16/brenox-sdk) (client + React)

## Development

```bash
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check src tests
```

Integration smoke (optional, requires Brenox API on `localhost:8080`):

```bash
BRENOX_API_KEY=bx_test_... pytest tests/integration -m integration
```
