Metadata-Version: 2.4
Name: vzaps
Version: 0.1.0
Summary: Official Python SDK for the VZaps public API.
Project-URL: Documentation, https://docs.vzaps.com
Project-URL: Homepage, https://vzaps.com
Project-URL: Repository, https://github.com/VZaps/vzaps-sdk-python
Project-URL: Issues, https://github.com/VZaps/vzaps-sdk-python/issues
Author-email: VZaps <dev@vzaps.com>
Maintainer-email: VZaps <dev@vzaps.com>
License: MIT License
        
        Copyright (c) 2026 VZaps
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: api,sdk,vzaps,whatsapp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
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<1,>=0.27
Requires-Dist: pydantic<3,>=2
Requires-Dist: websockets<16,>=12
Provides-Extra: dev
Requires-Dist: build<2,>=1.2; extra == 'dev'
Requires-Dist: mypy<2,>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio<2,>=0.23; extra == 'dev'
Requires-Dist: pytest-cov<8,>=5; extra == 'dev'
Requires-Dist: pytest<9,>=8; extra == 'dev'
Requires-Dist: respx<1,>=0.21; extra == 'dev'
Requires-Dist: ruff<1,>=0.6; extra == 'dev'
Requires-Dist: twine<7,>=5; extra == 'dev'
Description-Content-Type: text/markdown

# VZaps Python SDK

[![CI](https://github.com/VZaps/vzaps-sdk-python/actions/workflows/ci.yml/badge.svg)](https://github.com/VZaps/vzaps-sdk-python/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/vzaps.svg)](https://pypi.org/project/vzaps/)
[![Python](https://img.shields.io/pypi/pyversions/vzaps.svg)](https://pypi.org/project/vzaps/)

Official Python SDK for the VZaps public API.

## Requirements

- Python 3.10+
- `client_token` and `client_secret` from VZaps
- `instance_token` for instance-scoped operations

## Installation

```bash
pip install vzaps
```

For local development:

```bash
pip install -e ".[dev]"
```

## Quick Start

```python
from vzaps import VZapsClient

with VZapsClient(
    client_token="your-client-token",
    client_secret="your-client-secret",
) as client:
    instances = client.instances.list()
    print(instances)
```

Send a text message:

```python
from vzaps import VZapsClient

client = VZapsClient(client_token="...", client_secret="...")

client.messages.send_text(
    instance_id="VZ...",
    instance_token="instance-token",
    phone="5511999999999",
    message="Hello from Python",
)
client.close()
```

## Async

```python
from vzaps import AsyncVZapsClient

async with AsyncVZapsClient(
    client_token="your-client-token",
    client_secret="your-client-secret",
) as client:
    await client.messages.send_text(
        instance_id="VZ...",
        instance_token="instance-token",
        phone="5511999999999",
        message="Hello from async Python",
    )
```

## Authentication

The SDK exchanges `client_token` and `client_secret` for an access token using `POST /token`.
Tokens are cached and refreshed before expiration. Requests include:

- `Authorization: Bearer <access_token>`
- `X-Client-Token`
- `X-Instance-Token` when the call is scoped to an instance

## Resources

The client exposes:

- `auth`
- `instances`
- `sessions`
- `messages`
- `webhooks`
- `contacts`
- `groups`
- `users`
- `queues`
- `typebots`
- `chatwoot`
- `chats`
- `events`

All request arguments use Python `snake_case`.

## Generic Request

```python
client.request(
    "POST",
    "/instances/get",
    body={"id": "VZ..."},
)
```

## Realtime

Realtime subscriptions are async-first:

```python
async with AsyncVZapsClient(client_token="...", client_secret="...") as client:
    async with client.events.subscribe(
        instance_id="VZ...",
        instance_token="instance-token",
        events=["Message", "Connected"],
    ) as sub:
        @sub.on("Message")
        async def handle_message(event):
            print(event.id, event.data)

        await sub.wait_closed()
```

Handlers registered for `All` receive every event. The SDK sends an ack after handlers
complete and reconnects by default with `last_event_id` tracking.

## Errors

```python
from vzaps import VZapsAPIError, VZapsAuthenticationError, VZapsRateLimitError

try:
    client.instances.get("VZ...")
except VZapsAuthenticationError:
    ...
except VZapsRateLimitError:
    ...
except VZapsAPIError as exc:
    print(exc.status_code, exc.details)
```

## Documentation

See [docs.vzaps.com](https://docs.vzaps.com) for API and SDK guides.
