Metadata-Version: 2.4
Name: vihaya-events
Version: 0.1.0
Summary: Official Python SDK for the Vihaya Events platform. Fetch events, register attendees, and verify Razorpay payments with a fully-typed client.
Project-URL: Homepage, https://vihaya.app
Project-URL: Documentation, https://events.vihaya.app/profile/developer/docs
Project-URL: Repository, https://github.com/Vishnu252005/vihaya-sdk-python
Project-URL: Issues, https://github.com/Vishnu252005/vihaya-sdk-python/issues
Project-URL: Changelog, https://github.com/Vishnu252005/vihaya-sdk-python/blob/main/CHANGELOG.md
Author-email: Vihaya Team <vihaya.app@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Vihaya Team
        
        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: event-management,events,razorpay,sdk,ticketing,vihaya
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
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: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1; extra == 'dev'
Requires-Dist: twine>=4.0; extra == 'dev'
Description-Content-Type: text/markdown

# Vihaya Events — Python SDK

[![PyPI version](https://img.shields.io/pypi/v/vihaya-events.svg)](https://pypi.org/project/vihaya-events/)
[![Python versions](https://img.shields.io/pypi/pyversions/vihaya-events.svg)](https://pypi.org/project/vihaya-events/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

The official Python SDK for the [Vihaya Events](https://vihaya.app) platform.
Fully typed, built on [httpx](https://www.python-httpx.org/) and
[Pydantic v2](https://docs.pydantic.dev/), with feature parity across our
JavaScript and Flutter SDKs.

## Install

```bash
pip install vihaya-events
```

Requires Python 3.9+.

## Quick start

```python
from vihaya import Vihaya

vh = Vihaya("vh_live_...")  # get your key from the developer dashboard

for event in vh.events.list():
    print(f"{event.title} — {event.location}")
```

Use it as a context manager to guarantee the connection pool gets closed:

```python
with Vihaya("vh_live_...") as vh:
    event = vh.events.get("evt_8x42j9")
    print(event.title, event.date)
```

## Fetch a full event

`events.get()` returns an `Event` with every piece of metadata the organizer
has configured — speakers, agenda, sponsors, FAQs, custom fields, pricing
tiers, and sub-events for mega events.

```python
event = vh.events.get("evt_8x42j9")

print(event.title)
print(f"Mode: {event.event_mode}  Timezone: {event.timezone}")

for speaker in event.speaker_list or []:
    print(f"- {speaker.name} ({speaker.role})")

for item in event.agenda_list or []:
    print(f"[{item.time}] {item.title}")

for tier in event.special_prices or []:
    print(f"  {tier.name}: ₹{tier.amount}")
```

### Mega events

If `event.event_type == "megaEvent"`, it contains sub-events. Each sub-event
has its own tiers, custom fields, etc.

```python
if event.event_type == "megaEvent":
    for sub in event.sub_events or []:
        price = "Free" if sub.is_free else f"₹{sub.price}"
        print(f"- {sub.title} ({price})")
```

## Register an attendee

```python
from vihaya import RegisterData

registration = RegisterData(
    name="Anjali Mehta",
    email="anjali@example.com",
    phone="+919820012345",
    custom_fields={"T-Shirt Size": "L", "College": "Vihaya Institute"},
)

result = vh.events.register("evt_8x42j9", registration)

if result.get("isPaid"):
    order_id = result["orderId"]
    # Launch Razorpay checkout with this order_id, then verify server-side:
    vh.payments.verify(
        payment_id="pay_xxx",
        order_id=order_id,
        signature="sig_xxx",
    )
else:
    print(f"Registered! ID: {result['registrationId']}")
```

You can also pass a plain `dict` instead of `RegisterData` if you prefer.

## Error handling

All API failures raise `VihayaError` with the status code and raw body:

```python
from vihaya import VihayaError

try:
    vh.events.get("evt_does_not_exist")
except VihayaError as exc:
    print(f"{exc.message} (status={exc.status})")
    print(exc.data)
```

## API reference

### `Vihaya(api_key, *, base_url=..., headers=..., timeout=30.0)`

The main client. All arguments after `api_key` are keyword-only.

### `vh.events`

| Method | Returns | Description |
| --- | --- | --- |
| `list()` | `list[Event]` | All events on the authenticated account. |
| `get(event_id)` | `Event` | Full metadata for one event. |
| `register(event_id, data)` | `dict` | Submit a registration. `data` can be `RegisterData` or `dict`. |

### `vh.payments`

| Method | Returns | Description |
| --- | --- | --- |
| `verify(*, payment_id, order_id, signature, amount=None)` | `dict` | Server-side Razorpay signature verification. |

> **Security:** never hard-code a live secret key in client-side code. Use
> environment variables and perform payment verification from a trusted
> backend environment only.

## Development

```bash
git clone https://github.com/Vishnu252005/vihaya-sdk-python.git
cd vihaya-sdk-python
pip install -e ".[dev]"
pytest
```

## License

MIT — see [LICENSE](LICENSE).
