Availability
Streaming is available on all plans. Organizations may maintain multiple concurrent stream connections subject to plan limits. API-key connection limits are resolved from the organization’s billing limits.Access
Streaming requests must be authenticated and associated with an organization. Client examples use thex-api-key gRPC metadata header.
Subscriptions are scoped to trading accounts owned by the authenticated principal’s organization. Subscribe requests must include a valid trading account UUID and at least one event type.
Subscriptions
Once connected, your client can subscribe to message types for a trading account. The subscription messages are defined in protobuf via the proto repository: anthid-labs/proto.Service Definition
Streaming Models
Anthid supports two streaming patterns.StreamEvents
A bidirectional gRPC stream intended for backend and native applications. Clients can dynamically subscribe and unsubscribe from trading accounts over an existing connection.SubscribeEvents
A server-streaming endpoint intended for clients with a fixed subscription. The subscription is established when the request is created and remains active for the lifetime of the stream.Endpoints
Authentication
Streaming requests must include an API key using gRPC metadata.Event Types
Applications can subscribe to one or more event types.Subscribing to
EVENT_TYPE_BROKER_POSITION or EVENT_TYPE_BROKER_TRADE on an Alpaca account is accepted, but no events of that type arrive: the Alpaca integration does not yet report holdings or emit per-execution records. See Alpaca.Subscription Requests
Subscribe
trading_account_id out, or send it empty, to subscribe to every trading
account in your organization at once. Each event names the account it belongs
to, so one stream can carry the whole organization. The organization is taken
from the credentials on the request, never from the request body, so this is
still only ever your own accounts.
Unsubscribe
Unsubscribe is only available on the bidirectional StreamEvents RPC.
trading_account_id unsubscribes the organization-wide subscription,
matching how it was subscribed. It does not cancel the per-account
subscriptions, which are separate and are each unsubscribed by name.
Stream Events
The server may emit the following event types.Heartbeat
Indicates that the connection remains healthy. The server emits heartbeats approximately every 5 seconds.Status
Returned when a subscription is added or removed successfully. Successful messages aresubscribed and unsubscribed.
Error
Returned when a request cannot be processed.BrokerOrder
Represents a real-time order lifecycle update. Events may include:- New orders
- Accepted orders
- Partial fills
- Filled orders
- Cancelled orders
- Rejected orders
BrokerPosition
Represents a real-time position update received from a broker. Position updates are emitted whenever Anthid receives a change in account holdings.BrokerTrade
Represents one execution against an order. An order can fill in many pieces, so this is the fill-by-fill record thatBrokerOrder aggregates into filled_quantity and average_price.
Subscribe to this only if you need per-fill detail, such as building a VWAP or reconciling against a broker’s execution report. If you want to know how much of an order has traded, read
filled_quantity on BrokerOrder, which already aggregates these.Connection Lifecycle
- Connect to the streaming endpoint.
- Authenticate using an API key.
- Subscribe to one or more trading accounts.
- Receive status confirmation.
- Receive real-time events.
- Reconnect and resubscribe if the connection is interrupted.
Recommended Usage
Use the Streaming API for:- Live order monitoring
- Position synchronization
- Trading dashboards
- Notifications
- Automated trading workflows
- Intent submission
- Historical queries
- Search and filtering
- Reporting
- Reconciliation workflows