DID Document

Check out how to resolve a DID Document in atproto_identity/identity.

After a DID document has been resolved, atproto-specific information needs to be extracted. This parsing process is agnostic to the DID method used to resolve the document.

SDK automatically parses the DID document and provides a DID document object after resolving.

If you got a DID document from other sources, you can also parse it:

from atproto import Client, DidDocument

client = Client()
client.login('username', 'password')

response = client.com.atproto.repo.describe_repo({'repo': 'did:plc:kvwvcn5iqfooopmyzvb4qzba'})
did_doc = DidDocument.from_dict(response.did_doc)
print(did_doc.get_pds_endpoint())
print(did_doc.get_handle())

Read more about DID document in official documentation: https://atproto.com/specs/did

class atproto_core.did_doc.DidDocument

Bases: BaseModel

DID document.

field also_known_as: List[str] | None = None
field id: str [Required]
field service: List[Service] | None = None
field verification_method: List[VerificationMethod] | None = None
classmethod from_dict(did_doc: Dict[str, Any] | Any) DidDocument

Parse a DID document.

Parameters:

did_doc – The raw DID document.

Returns:

The parsed DID document.

Return type:

DidDocument

get_did() str

Return the DID of the given DID document.

Returns:

The DID of the given DID document.

Return type:

str

get_did_key() str | None

Return the DID key of the given DID document.

Returns:

The DID key of the given DID document, or None if not found.

Return type:

str

get_feed_gen_endpoint() str | None

Return the feed generator endpoint of the given DID document.

Returns:

The feed generator endpoint of the given DID document, or None if not found.

Return type:

str

get_handle() str | None

Return the handle of the given DID document.

Returns:

The handle of the given DID document, or None if not found.

Return type:

str

get_notif_endpoint() str | None

Return the notification endpoint of the given DID document.

Returns:

The notification endpoint of the given DID document, or None if not found.

Return type:

str

get_pds_endpoint() str | None

Return the personal data server endpoint of the given DID document.

Returns:

The personal data server endpoint of the given DID document, or None if not found.

Return type:

str

get_service_endpoint(id_: str, type_: str) str | None

Return the service endpoint of the given DID document.

Parameters:
  • id – The service ID.

  • type – The service type.

Returns:

The service endpoint of the given DID document, or None if not found.

Return type:

str

get_signing_key() SigningKey | None

Return the signing key of the given DID document.

Returns:

The signing key of the given DID document, or None if not found.

Return type:

SigningKey

to_atproto_data() AtprotoData

Return the AtprotoData of the given DID document.

Returns:

The AtprotoData of the given DID document.

Return type:

AtprotoData

class atproto_core.did_doc.Service

Bases: BaseModel

Service.

field id: str [Required]
field service_endpoint: str | Any [Required]
field type: str [Required]
class atproto_core.did_doc.SigningKey(type: str, public_key_multibase: str)

Bases: object

Public signing key for the account.

public_key_multibase: str
type: str
class atproto_core.did_doc.VerificationMethod

Bases: BaseModel

Verification method.

field controller: str [Required]
field id: str [Required]
field public_key_multibase: str | None = None
field type: str [Required]
atproto_core.did_doc.is_valid_did_doc(did_doc: Dict[str, Any] | Any) bool

Return whether the given DID document is valid.

Parameters:

did_doc – The raw DID document.

Returns:

Whether the given DID document is valid.

Return type:

bool