Manage AT Protocol Account¶
The AtProtoConfiguration class lets you manage your AT Protocol account.
A class to hold the configuration for the AT Protocol.
- param endpoint:
Your ATP endpoint
- param username:
The username for your ATP account
- param password:
The password for your ATP account
Example:
import pyatproto
import os
ENDPOINT = os.environ.get("ATPROTO_ENDPOINT")
USERNAME = os.environ.get("ATPROTO_USERNAME")
PASSWORD = os.environ.get("ATPROTO_PASSWORD")
if not ENDPOINT or not USERNAME or not PASSWORD:
raise ValueError(
"Please set the ATPROTO_ENDPOINT, ATPROTO_USERNAME and ATPROTO_PASSWORD environment variables."
)
ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD)
create_post = ap.create_post("My First Post")
print(create_post)
Get Followers¶
- pyatproto.AtProtoConfiguration.get_followers(self, user=None) list¶
Get the followers of a user.
- Returns:
The list of followers
- Return type:
Example:
import pyatproto import os ENDPOINT = os.environ.get("ATPROTO_ENDPOINT") USERNAME = os.environ.get("ATPROTO_USERNAME") PASSWORD = os.environ.get("ATPROTO_PASSWORD") ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD) followers = ap.get_followers() print(followers)
Create a Post¶
- pyatproto.AtProtoConfiguration.create_post(self, title, reply_id=None, cid=None, url=None, thumbnail=None)¶
Create a post.
- Parameters:
title – The title of the post
- Returns:
The rkey of the post
Example:
import pyatproto import os ENDPOINT = os.environ.get("ATPROTO_ENDPOINT") USERNAME = os.environ.get("ATPROTO_USERNAME") PASSWORD = os.environ.get("ATPROTO_PASSWORD") ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD) create_post = ap.create_post("My First Post") print(create_post)
Delete a Post¶
- pyatproto.AtProtoConfiguration.delete_post(self, rkey)¶
Delete a post.
- Parameters:
rkey – The rkey of the post to delete
Example:
import pyatproto import os ENDPOINT = os.environ.get("ATPROTO_ENDPOINT") USERNAME = os.environ.get("ATPROTO_USERNAME") PASSWORD = os.environ.get("ATPROTO_PASSWORD") ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD) ap.delete_post("rkey")
Get User Feed¶
- pyatproto.AtProtoConfiguration.get_user_feed(self, user) dict¶
Get the feed of posts from a user.
- Returns:
The user feed
- Return type:
Example:
import pyatproto import os ENDPOINT = os.environ.get("ATPROTO_ENDPOINT") USERNAME = os.environ.get("ATPROTO_USERNAME") PASSWORD = os.environ.get("ATPROTO_PASSWORD") ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD) user_feed = ap.get_user_feed() print(user_feed)
Get Notifications¶
Get a Post¶
Get Posts a User Has Liked¶
List Users a User Follows¶
Get User Timeline¶
- pyatproto.AtProtoConfiguration.get_user_timeline(self, did=None) dict¶
Get the timeline from a user’s homepage.
- Returns:
The user timeline.
- Return type:
Example:
import pyatproto ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD) user_timeline = ap.get_user_timeline() print(user_timeline)
Change Username to Domain¶
- pyatproto.AtProtoConfiguration.change_username_to_domain(self, domain)¶
Change the username to a domain.
- Parameters:
domain – The domain to change to
Example:
import pyatproto ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD) ap.change_username_to_domain("example.com")
Convert Username to DID¶
- pyatproto.username_to_did(endpoint, username)[source]¶
Get the DID associated with a username.
- Parameters:
endpoint – The ATP endpoint to use
username – The username to get the DID of
- Returns:
The DID associated with the username
Example:
import pyatproto did = pyatproto.username_to_did(ENDPOINT, "username") print(did)