presentation.routers.api.v1.events¶
src.presentation.routers.api.v1.events
¶
SSE Events Endpoint.
Provides Server-Sent Events streaming for real-time client notifications. This is a pure handler function - routing is done via ROUTE_REGISTRY.
Architecture
- Uses existing Dashtam Bearer token authentication
- Category-based filtering via query params
- Last-Event-ID support for reconnection replay
- Heartbeat comments to detect stale connections
Reference
- docs/architecture/sse-architecture.md
Attributes¶
Classes¶
Functions¶
get_events
async
¶
get_events(
request: Request,
current_user: Annotated[
CurrentUser, Depends(get_current_user)
],
subscriber: Annotated[
SSESubscriberProtocol, Depends(get_sse_subscriber)
],
categories: Annotated[
list[str] | None,
Query(
description="Filter by event categories. Valid: data_sync, provider, ai, import, portfolio, security"
),
] = None,
last_event_id: Annotated[
str | None,
Query(
alias=Last - Event - ID,
description="Resume from last received event ID (if retention enabled)",
),
] = None,
) -> StreamingResponse
Stream real-time events via Server-Sent Events (SSE).
Authentication: Standard Bearer token (same as all endpoints).
Connect to receive push notifications for: - Data sync progress (accounts, transactions, holdings) - Provider connection health - Balance/portfolio updates - AI response streaming - Security notifications
Reconnection: The client should automatically reconnect if
disconnected. Include Last-Event-ID header to resume from
where you left off (if event retention is enabled).
Categories: Filter events by category:
- data_sync: Account/transaction sync events
- provider: Provider health events
- ai: AI response streaming
- import: File import progress
- portfolio: Balance/holdings updates
- security: Session/security alerts
Returns:
| Type | Description |
|---|---|
StreamingResponse
|
StreamingResponse with SSE content type. |
Source code in src/presentation/routers/api/v1/events.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |