atproto_client.client.client¶
- class atproto_client.client.client.Client(base_url: str | None = None, *args: Any, **kwargs: Any)¶
Bases:
SessionDispatchMixin,SessionMethodsMixin,TimeMethodsMixin,HeadersConfigurationMethodsMixin,ClientRawHigh-level client for XRPC of ATProto.
- delete_post(post_uri: str) bool¶
Delete post.
- Parameters:
post_uri – AT URI of the post.
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- follow(subject: str) CreateRecordResponse¶
Follow the profile.
- Parameters:
subject – DID of the profile.
- Returns:
Reference to the created record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_author_feed(actor: str, cursor: str | None = None, filter: str | None = None, limit: int | None = None, include_pins: bool = False) Response¶
Get author (profile) feed.
- Parameters:
actor – Actor (handle or DID).
cursor – Cursor of the last like in the previous page.
filter – Filter.
limit – Limit count of likes to return.
include_pins – Include pins.
- Returns:
Feed.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_followers(actor: str, cursor: str | None = None, limit: int | None = None) Response¶
Get followers of the profile.
- Parameters:
actor – Actor (handle or DID).
cursor – Cursor of the next page.
limit – Limit count of followers to return.
- Returns:
Followers.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_follows(actor: str, cursor: str | None = None, limit: int | None = None) Response¶
Get follows of the profile.
- Parameters:
actor – Actor (handle or DID).
cursor – Cursor of the next page.
limit – Limit count of follows to return.
- Returns:
Follows.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_likes(uri: str, cid: str | None = None, cursor: str | None = None, limit: int | None = None) Response¶
Get likes.
- Parameters:
uri – AT URI.
cid – CID.
cursor – Cursor of the last like in the previous page.
limit – Limit count of likes to return.
- Returns:
Likes.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_post(post_rkey: str, profile_identify: str | None = None, cid: str | None = None) GetRecordResponse¶
Get post.
- Parameters:
post_rkey – ID (slug) of the post.
profile_identify – Handler or DID. Who created the post.
cid – The CID of the version of the post.
- Returns:
Post.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_post_thread(uri: str, depth: int | None = None, parent_height: int | None = None) Response¶
Get post thread.
- Parameters:
uri – AT URI.
depth – Depth of the thread.
parent_height – Height of the parent post.
- Returns:
Post thread.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_posts(uris: List[str]) Response¶
Get posts.
- Parameters:
uris – Uris (AT URI).
Example
client.get_posts(['at://did:plc:kvwvcn5iqfooopmyzvb4qzba/app.bsky.feed.post/3k2yihcrp6f2c'])
- Returns:
Posts.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_profile(actor: str) ProfileViewDetailed¶
Get profile.
- Parameters:
actor – Actor (handle or DID).
- Returns:
Profile.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_profiles(actors: List[str]) Response¶
Get profiles.
- Parameters:
actors – List of actors (handles or DIDs).
- Returns:
Profiles.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_reposted_by(uri: str, cid: str | None = None, cursor: str | None = None, limit: int | None = None) Response¶
Get reposted by (reposts).
- Parameters:
uri – AT URI.
cid – CID.
cursor – Cursor of the last like in the previous page.
limit – Limit count of likes to return.
- Returns:
Reposts.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- get_timeline(algorithm: str | None = None, cursor: str | None = None, limit: int | None = None) Response¶
Get home timeline.
- Parameters:
algorithm – Algorithm.
cursor – Cursor of the last like in the previous page.
limit – Limit count of likes to return.
- Returns:
Home timeline.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- like(uri: str, cid: str) CreateRecordResponse¶
Like the record.
- Parameters:
cid – The CID of the record.
uri – The URI of the record.
Note
Record could be post, custom feed, etc.
- Returns:
Reference to the created record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- login(login: str | None = None, password: str | None = None, session_string: str | None = None, auth_factor_token: str | None = 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_stringto get it).auth_factor_token – Auth factor token (for Email 2FA).
Note
Either session_string or login and password should be provided.
- Returns:
Profile information.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- mute(actor: str) bool¶
Mute actor (profile).
- Parameters:
actor – Actor (handle or DID).
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- post(text: str | TextBuilder, profile_identify: str | None = None, reply_to: ReplyRef | None = None, embed: Main | Main | Main | Main | Main | None = None, langs: List[str] | None = None, facets: List[Main] | None = None) CreateRecordResponse¶
Alias for
send_post
- repost(uri: str, cid: str) CreateRecordResponse¶
Repost post.
- Parameters:
cid – The CID of the post.
uri – The URI of the post.
- Returns:
Reference to the reposted record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- resolve_handle(handle: str) Response¶
Resolve the handle.
- Parameters:
handle – Handle.
- Returns:
Resolved handle (DID).
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- send_image(text: str | TextBuilder, image: bytes, image_alt: str, profile_identify: str | None = None, reply_to: ReplyRef | None = None, langs: List[str] | None = None, facets: List[Main] | None = None, image_aspect_ratio: AspectRatio | None = None) CreateRecordResponse¶
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.
langs – List of used languages in the post.
facets – List of facets (rich text items).
image_aspect_ratio – Aspect ratio of the image.
- Returns:
Reference to the created record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- send_images(text: str | TextBuilder, images: List[bytes], image_alts: List[str] | None = None, profile_identify: str | None = None, reply_to: ReplyRef | None = None, langs: List[str] | None = None, facets: List[Main] | None = None, image_aspect_ratios: List[AspectRatio] | None = None) CreateRecordResponse¶
Send post with multiple attached images (up to 4 images).
Note
If profile_identify is not provided will be sent to the current profile.
- Parameters:
text – Text of the post.
images – List of binary images to attach. The length must be less than or equal to 4.
image_alts – List of text version of the images. The length should be shorter than or equal to the length of images.
profile_identify – Handle or DID. Where to send post.
reply_to – Root and parent of the post to reply to.
langs – List of used languages in the post.
facets – List of facets (rich text items).
image_aspect_ratios – List of aspect ratios of the images. The length should be shorter than or equal to the length of images.
- Returns:
Reference to the created record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- send_post(text: str | TextBuilder, profile_identify: str | None = None, reply_to: ReplyRef | None = None, embed: Main | Main | Main | Main | Main | None = None, langs: List[str] | None = None, facets: List[Main] | None = None) CreateRecordResponse¶
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.
facets – List of facets (rich text items).
- Returns:
Reference to the created record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- send_video(text: str | TextBuilder, video: bytes, video_alt: str | None = None, profile_identify: str | None = None, reply_to: ReplyRef | None = None, langs: List[str] | None = None, facets: List[Main] | None = None, video_aspect_ratio: AspectRatio | None = None) CreateRecordResponse¶
Send post with attached video.
Note
If profile_identify is not provided will be sent to the current profile.
- Parameters:
text – Text of the post.
video – Binary video to attach.
video_alt – Text version of the video.
profile_identify – Handle or DID. Where to send post.
reply_to – Root and parent of the post to reply to.
langs – List of used languages in the post.
facets – List of facets (rich text items).
video_aspect_ratio – Aspect ratio of the video.
- Returns:
Reference to the created record.
- Return type:
- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- unfollow(follow_uri: str) bool¶
Unfollow the profile.
- Parameters:
follow_uri – AT URI of the follow.
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- unlike(like_uri: str) bool¶
Unlike the post.
- Parameters:
like_uri – AT URI of the like.
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- unmute(actor: str) bool¶
Unmute actor (profile).
- Parameters:
actor – Actor (handle or DID).
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- unrepost(repost_uri: str) bool¶
Unrepost the post (delete repost).
- Parameters:
repost_uri – AT URI of the repost.
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.
- unsend(post_uri: str) bool¶
Alias for
delete_post
- update_handle(handle: str) bool¶
Update the handle.
- Parameters:
handle – New handle.
- Returns:
Success status.
- Return type:
bool- Raises:
atproto.exceptions.AtProtocolError – Base exception.