Models
Every lexicon of the network, generated as a Pydantic model. Browse by NSID: the authority, then the namespace, then the record or method.
- atproto_client.models.create_strong_ref(model: _StrongRefSource) Main
Create a strong ref from the model.
- Parameters:
model β Any model with cid and uri fields.
Example
>>> from atproto import Client >>> client = Client() >>> client.login('my-handle', 'my-password') >>> response = client.send_post(text='Hello World from Python!') >>> strong_ref = create_strong_ref(response)- Returns:
Strong ref.
- Return type:
- atproto_client.models.get_or_create(model_data: M | Mapping[str, Any] | None, model: Type[M] | None = None, *, strict: bool = True, strict_string_format: bool = False) M | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | DotDict | None
Get model instance from raw data.
Note
The record could have additional fields and be completely custom. For example, third-party bsky clients add a βviaβ field to indicate that it was posted using a not official client. Such records are corresponding to the lexicon, but have additional fields. This is called βextended recordβ. Extended records will be decoded to proper models with extra, non-typehinted fields available only in runtime. Unknown record types will be decoded to
atproto.xrpc_client.models.base.DotDict. A union member with an unrecognized β$typeβ is decoded to a DotDict too, without failing the rest of the model.Note
By default, the method raises an exception on custom models if you have passed the expected model. To fall back to a
atproto.xrpc_client.models.base.DotDicttype, disable strict mode using the argument.Note
Model auto-resolve works only with a Record type for now.
- Parameters:
model_data β Raw data.
model β Class of the model or any another type. If None, it will be resolved automatically.
strict β Disable fallback to dictionary (
atproto.xrpc_client.models.base.DotDict) if it canβt be properly deserialized in provided model. Will raise the exception instead.strict_string_format β Enable strict string format validation.
- Returns:
Instance of
modelorNoneoratproto.xrpc_client.models.dot_dict.DotDictif strict is disabled.
- atproto_client.models.is_record_type(model: ModelBase | DotDict | None, expected_type: Any) bool
Verify that the model is the expected Record type.
Note
Passing a Python module or a Record class narrows the type of model for static type checkers. Narrowing is not performed for the NSID form because a string carries no type information.
Warning
A custom or extended record that failed validation is decoded to
atproto_client.models.dot_dict.DotDict. Such a model matches its own type by NSID, so the narrowed type is not guaranteed to be an instance of the Record class in runtime.- Parameters:
model β Model to be verified.
Noneis never a record.expected_type β Excepted type. Could be NSID, Python Module, or Record class.
Example
>>> from atproto import Client, models >>> from atproto_client.models import ids, is_record_type >>> client = Client() >>> client.login('username', 'pass') >>> record = client.com.atproto.repo.get_record(...) >>> # using NSID: >>> is_record_type(record.value, ids.AppBskyFeedPost) >>> # using Python module: >>> is_record_type(record.value, models.AppBskyFeedPost) >>> # using Record class: >>> is_record_type(record.value, models.AppBskyFeedPost.Record)- Returns:
Is record or not.
- Return type:
Lexicons
One page per NSID, generated from the lexicons the network publishes.
Application lexicons: everything an app exposes to the people using it.
Private messaging lexicons.
The protocol itself, plus the lexicons of third-party services.
Internal lexicons that are not part of the public API.
Infrastructure services behind the network.
Place.
Websites published on atproto.
Social.
Tooling for the people who operate the network.
Core
The hand-written machinery every generated model is built on.
Base classes every generated model inherits from.
References to blobs stored on a PDS.
Lexicon bytes, carried as base64 in JSON.
Types shared across the generated models.
Dict wrapper that also allows attribute access.
ISO language codes used by posts.
Lazy import of the generated model modules.
Registry mapping record NSIDs to their model.
Validation of the AT Protocol string formats.
Conversion between models, dicts, and raw JSON.
Fallback for records of an unrecognised type.
Fallback for union members of an unrecognised type.
Helpers for working with model instances.