atproto_client.models.utils.create_strong_ref(model: ModelBase) Main

Create a strong ref from the model.


model – Any model with cid and uri fields.


>>> 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)

Strong ref.

Return type:


atproto_client.models.utils.get_model_as_dict(model: DotDict | BlobRef | ModelBase) Dict[str, Any]
atproto_client.models.utils.get_model_as_json(model: DotDict | BlobRef | ModelBase) str
atproto_client.models.utils.get_or_create(model_data: M | Dict[str, Any] | None, model: Type[M] | None = None, *, strict: bool = True) M | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | Record | DotDict | None

Get model instance from raw data.


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.


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.DotDict type, disable strict mode using the argument.


Model auto-resolve works only with a Record type for now.

  • 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.


Instance of model or None or atproto.xrpc_client.models.dot_dict.DotDict if strict is disabled.

atproto_client.models.utils.get_response_model(response: Response, model: Type[M]) M
atproto_client.models.utils.is_json(json_data: str | bytes) bool
atproto_client.models.utils.is_record_type(model: ModelBase | DotDict, expected_type: str | module) bool

Verify that the model is the expected Record type.

  • model – Model to be verified.

  • expected_type – Excepted type. Could be NSID or Python Module.


>>> 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)

Is record or not.

Return type: