atproto#
- class atproto.AsyncClient(base_url: Optional[str] = None, *args, **kwargs)#
Bases:
SessionMethodsMixin
,TimeMethodsMixin
,AsyncClientRaw
High-level client for XRPC of ATProto.
- async delete_post(post_rkey: str, profile_identify: Optional[str] = None) bool #
Delete post.
- Parameters:
post_rkey – ID (slug) of the post.
profile_identify – Handler or DID. Who created the post.
- Returns:
Success status.
- Return type:
bool
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- async like(subject: Main) Response #
Like the post.
- Parameters:
subject – Reference to the post that should be liked.
- Returns:
Reference to the created like record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- async login(login: Optional[str] = None, password: Optional[str] = None, session_string: Optional[str] = None) ProfileViewDetailed #
Authorize a client and get profile info.
- Parameters:
login – Handle/username of the account.
password – Main or app-specific password of the account.
session_string – Session string (use
export_session_string
to obtain it).
Note
Either session_string or login and password should be provided.
- Returns:
Profile information.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- async repost(subject: Main, profile_identify: Optional[str] = None) Response #
Repost post.
Note
If profile_identify is not provided will be sent to the current profile.
- Parameters:
subject – Reference to the post that should be reposted.
profile_identify – Handle or DID. Where to make repost.
- Returns:
Reference to the reposted post record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- async send_image(text: str, image: bytes, image_alt: str, profile_identify: Optional[str] = None, reply_to: Optional[Union[ReplyRef, ReplyRef]] = None) Response #
Send post with attached image.
Note
If profile_identify is not provided will be sent to the current profile.
- Parameters:
text – Text of the post.
image – Binary image to attach.
image_alt – Text version of the image
profile_identify – Handle or DID. Where to send post.
reply_to – Root and parent of the post to reply to.
- Returns:
Reference to the created post record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- async send_post(text: str, profile_identify: Optional[str] = None, reply_to: Optional[Union[ReplyRef, ReplyRef]] = None, embed: Optional[Union[Main, Main, Main, Main]] = None, langs: Optional[List[str]] = None) Response #
Send post.
Note
If profile_identify is not provided will be sent to the current profile.
The async default language is
en
. Available languages are async defined inatproto.xrpc_client.models.languages
.- Parameters:
text – Text of the post.
profile_identify – Handle or DID. Where to send post.
reply_to – Root and parent of the post to reply to.
embed – Embed models that should be attached to the post.
langs – List of used languages in the post.
- Returns:
Reference to the created post record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- async unlike(record_key: str, profile_identify: Optional[str] = None) bool #
Unlike the post.
- Parameters:
record_key – ID (slog) of the post.
profile_identify – Handler or DID. Who did the like.
- Returns:
Success status.
- Return type:
bool
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- class atproto.AtUri(host: str, pathname: str, hash_: str, search_params: List[Tuple[str, Any]])#
Bases:
object
ATP URI Scheme.
Examples
Repository: at://alice.host.com
Repository: at://did:plc:bv6ggog3tya2z3vxsub7hnal
Collection: at://alice.host.com/io.example.song
Record: at://alice.host.com/io.example.song/3yI5-c1z-cc2p-1a
Record Field: at://alice.host.com/io.example.song/3yI5-c1z-cc2p-1a#/title
- property collection: str#
Get collection name.
- property hostname: str#
Get hostname.
- property http: str#
Convert instance to HTTP URI.
- property origin: str#
Get origin.
- property protocol: str#
Get protocol.
- property rkey: str#
Get record key (rkey).
- class atproto.CAR(root: CID, blocks: Dict[CID, dict])#
Bases:
object
CAR file.
- classmethod from_bytes(data: bytes) CAR #
Decode CAR file.
Note
You could pass as data response of client.com.atproto.sync.get_repo, for example. And other responses of methods in the sync namespace.
Example
>>> from atproto import CAR, Client >>> client = Client() >>> client.login('my-handle', 'my-password') >>> repo = client.com.atproto.sync.get_repo({'did': client.me.did}) >>> car_file = CAR.from_bytes(repo) >>> print(car_file.root) >>> print(car_file.blocks)
- Parameters:
data – Content of the CAR file.
- Returns:
Parsed CAR file.
- Return type:
- class atproto.CID(_cid: str, version: int, codec: int, hash: atproto.cid.Multihash)#
Bases:
object
- codec: int#
- encode() str #
- version: int#
- class atproto.Client(base_url: Optional[str] = None, *args, **kwargs)#
Bases:
SessionMethodsMixin
,TimeMethodsMixin
,ClientRaw
High-level client for XRPC of ATProto.
- delete_post(post_rkey: str, profile_identify: Optional[str] = None) bool #
Delete post.
- Parameters:
post_rkey – ID (slug) of the post.
profile_identify – Handler or DID. Who created the post.
- Returns:
Success status.
- Return type:
bool
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- like(subject: Main) Response #
Like the post.
- Parameters:
subject – Reference to the post that should be liked.
- Returns:
Reference to the created like record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- login(login: Optional[str] = None, password: Optional[str] = None, session_string: Optional[str] = None) ProfileViewDetailed #
Authorize a client and get profile info.
- Parameters:
login – Handle/username of the account.
password – Main or app-specific password of the account.
session_string – Session string (use
export_session_string
to obtain it).
Note
Either session_string or login and password should be provided.
- Returns:
Profile information.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- repost(subject: Main, profile_identify: Optional[str] = None) Response #
Repost post.
Note
If profile_identify is not provided will be sent to the current profile.
- Parameters:
subject – Reference to the post that should be reposted.
profile_identify – Handle or DID. Where to make repost.
- Returns:
Reference to the reposted post record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- send_image(text: str, image: bytes, image_alt: str, profile_identify: Optional[str] = None, reply_to: Optional[Union[ReplyRef, ReplyRef]] = None) Response #
Send post with attached image.
Note
If profile_identify is not provided will be sent to the current profile.
- Parameters:
text – Text of the post.
image – Binary image to attach.
image_alt – Text version of the image
profile_identify – Handle or DID. Where to send post.
reply_to – Root and parent of the post to reply to.
- Returns:
Reference to the created post record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- send_post(text: str, profile_identify: Optional[str] = None, reply_to: Optional[Union[ReplyRef, ReplyRef]] = None, embed: Optional[Union[Main, Main, Main, Main]] = None, langs: Optional[List[str]] = None) Response #
Send post.
Note
If profile_identify is not provided will be sent to the current profile.
The default language is
en
. Available languages are defined inatproto.xrpc_client.models.languages
.- Parameters:
text – Text of the post.
profile_identify – Handle or DID. Where to send post.
reply_to – Root and parent of the post to reply to.
embed – Embed models that should be attached to the post.
langs – List of used languages in the post.
- Returns:
Reference to the created post record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- unlike(record_key: str, profile_identify: Optional[str] = None) bool #
Unlike the post.
- Parameters:
record_key – ID (slog) of the post.
profile_identify – Handler or DID. Who did the like.
- Returns:
Success status.
- Return type:
bool
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- class atproto.NSID(segments: ~typing.List[str] = <factory>)#
Bases:
object
NameSpaced IDs (NSIDs).
Examples
com.example.status
io.social.getFeed
net.users.bob.ping
- property authority: str#
Get authority of NSID.
com.example.thing ^^^^^^^^^^^——–> example.com
delim joined self.segments[:-1][::-1]
- property name: str#
Get name.
- segments: List[str]#
Subpackages#
- atproto.car
- atproto.cbor
- atproto.cid
- atproto.cli
- atproto.codegen
append_code()
camel_case_split()
capitalize_first_symbol()
convert_camel_case_to_snake_case()
format_code()
gen_description_by_camel_case_name()
get_code_intent()
get_def_model_name()
get_file_path_parts()
get_import_path()
get_import_path_old()
get_model_path()
get_sync_async_keywords()
join_code()
sort_dict_by_key()
write_code()
- Subpackages
- atproto.firehose
- atproto.lexicon
- Submodules
- atproto.lexicon.models
LexArray
LexBlob
LexBoolean
LexBytes
LexCidLink
LexDefinition
LexDefinitionType
LexInteger
LexNumber
LexObject
LexPrimitive
LexPrimitiveType
LexRecord
LexRef
LexRefUnion
LexString
LexSubscription
LexToken
LexUnknown
LexXrpcBody
LexXrpcError
LexXrpcParameters
LexXrpcProcedure
LexXrpcQuery
LexXrpcSubscriptionMessage
LexiconDoc
- atproto.lexicon.parser
- atproto.lexicon.models
- Submodules
- atproto.nsid
- atproto.uri
- atproto.xrpc_client
- atproto.xrpc_server
Submodules#
- atproto.exceptions
AtProtocolError
BadRequestError
DAGCBORDecodingError
FirehoseDecodingError
FirehoseError
InvalidAtUriError
InvalidCARFile
InvalidNsidError
InvokeTimeoutError
LexiconParsingError
ModelError
ModelFieldNotFoundError
NetworkError
RequestErrorBase
RequestException
UnauthorizedError
UnknownDefinitionTypeError
UnknownPrimitiveTypeError