# Python SDK — API Reference

> Python SDK API reference for Aerostack — auth, database, realtime, storage, AI, and cache methods for server-side Python applications.

## Auth

```python
client.auth.verify_token(token)                  # User | None
client.auth.register(email, password, **kwargs)  # AuthResult
client.auth.login(email, password)               # AuthResult
client.auth.send_otp(email=None, phone=None)     # None
client.auth.verify_otp(code, email=None, phone=None) # AuthResult
```

## Database

```python
client.db.query(sql, params=[])                  # QueryResult (list of dicts)
client.db.query_one(sql, params=[])              # dict | None
client.db.exec(sql)                              # None
client.db.batch(statements)                      # list[QueryResult]
```

## Cache

```python
client.cache.get(key)                            # Any | None
client.cache.set(key, value, ttl=None)           # None
client.cache.delete(key)                         # None
client.cache.has(key)                            # bool
```

## Storage

```python
client.storage.upload(file_bytes, path=None, content_type=None) # UploadResult
client.storage.delete(key)                       # None
```

## AI

```python
client.ai.complete(prompt, model=None, max_tokens=512, temperature=0.7) # CompletionResult
client.ai.embed(text)                            # list[float]
```

## Realtime

```python
channel = client.realtime.channel(topic)
channel.on(event, callback)                      # Registers async callback
channel.subscribe()
channel.unsubscribe()
channel.publish(event, data, persist=False)
channel.track(state_dict)
channel.untrack()
await channel.get_history(limit=50, before=None) # list[HistoryMessage]

client.socket.emit(event, data, room_id)         # Server-side broadcast
```

## Queue

```python
await client.queue.send(type, payload, delay_seconds=0, max_retries=3) # None
```

## Secrets

```python
await client.secrets.get(name)                   # str | None
```
