Event Streaming
Event Streaming
ZeroDB includes event streaming for real-time agent communication and application state tracking.
Create an Event
curl -X POST https://api.ainative.studio/api/v1/public/zerodb/{project_id}/database/events \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"topic": "agent.task_completed",
"event_payload": {
"agent_id": "agent_123",
"task": "research",
"result": "Found 5 relevant papers"
}
}'
List Events
curl "https://api.ainative.studio/api/v1/public/zerodb/{project_id}/database/events?topic=agent.task_completed&limit=20" \
-H "Authorization: Bearer $TOKEN"
Event Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
topic | string | Yes | Event topic (e.g., agent.task_completed) |
event_payload | object | Yes | Event payload |
Python SDK
import requests
headers = {"Authorization": "Bearer YOUR_API_KEY"}
project_id = "YOUR_PROJECT_ID"
base = f"https://api.ainative.studio/api/v1/public/zerodb/{project_id}/database/events"
## Create an event
requests.post(base, headers=headers, json={
"topic": "agent.task_completed",
"event_payload": {
"agent_id": "agent_456",
"task": "research",
"duration_ms": 2340,
"result": "success"
}
})
## Query events by topic
response = requests.get(base, headers=headers, params={
"topic": "agent.task_completed",
"limit": 50
})
for event in response.json()["events"]:
print(f"[{event['published_at']}] {event['topic']}: {event['event_payload']}")
Use Cases
Agent Coordination
Audit Logging
State Sync
Workflow Triggers
Endpoints
All paths below are relative to /api/v1/public/zerodb/{project_id}.
| Method | Path | Description |
|---|---|---|
| POST | /database/events | Create an event |
| GET | /database/events | List events (filter by topic, paginate with skip/limit) |
| GET | /database/events/{event_id} | Get a specific event |
| POST | /database/events/batch | Create multiple events at once |
| GET | /database/events/stats | Aggregate event statistics |
| GET / POST | /database/events/subscriptions | List / create event subscriptions |
| DELETE | /database/events/subscriptions/{subscription_id} | Remove a subscription |