Frame models
The wire format of AT Protocol XRPC subscriptions: each frame is two concatenated DAG-CBOR items, a header and a body. Frame.from_bytes decodes one into a MessageFrame or an ErrorFrame, depending on the op field of its header.
A message frame carries header.t, its type such as #commit, and an undecoded body. That type is what the per-lexicon parsers (parse_subscribe_repos_message and friends) dispatch on, and what you filter on to avoid parsing messages you do not want.
Note
These are re-exported as atproto.firehose_models, which is the import you will see in the examples and in most existing code.
Wire format of AT Protocol XRPC subscriptions: DAG-CBOR framed messages.
- class atproto_subscription.frames.ErrorFrame(header: ErrorFrameHeader, body: ErrorFrameBody)
Bases:
FrameSubscription error frame.
- header: ErrorFrameHeader
Header.
- body: ErrorFrameBody
Body.
- class atproto_subscription.frames.ErrorFrameBody(error: str, message: str | None = None)
Bases:
objectBody of error frame.
- error: str
Code of the error.
- class atproto_subscription.frames.ErrorFrameHeader(op: FrameType = FrameType.ERROR)
Bases:
objectHeader of the error frame.
- op: FrameType = -1
Operation. For Error header is
FrameType.ERRORalways.
- class atproto_subscription.frames.Frame(header: MessageFrameHeader | ErrorFrameHeader, body: ErrorFrameBody | dict)
Bases:
objectBase subscription frame.
- header: MessageFrameHeader | ErrorFrameHeader
Header.
- body: ErrorFrameBody | dict
Body
- static from_bytes(data: bytes | bytearray) MessageFrame | ErrorFrame
Decode frame from bytes of stream of bytes.
- Parameters:
data – Bytes or stream of bytes of frame.
- Returns:
- Raises:
atproto.exceptions.SubscriptionError – Invalid data frame.
- atproto_subscription.frames.FrameHeader
Base frame header.
alias of
MessageFrameHeader|ErrorFrameHeader
- class atproto_subscription.frames.FrameType(*values)
Bases:
EnumType of frame.
- class atproto_subscription.frames.MessageFrame(header: MessageFrameHeader, body: dict)
Bases:
FrameSubscription message frame.
- header: MessageFrameHeader
Header.
- body: dict
Body.
- class atproto_subscription.frames.MessageFrameHeader(op: FrameType = FrameType.MESSAGE, t: str | None = None)
Bases:
objectHeader of the message frame.
- op: FrameType = 1
Operation. For Message header is
FrameType.MESSAGEalways.
- atproto_subscription.frames.parse_frame(header: MessageFrameHeader | ErrorFrameHeader, raw_body: dict) ErrorFrame | MessageFrame
- atproto_subscription.frames.parse_frame_header(raw_header: dict) MessageFrameHeader | ErrorFrameHeader