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:

list

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:

dict

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

pyatproto.AtProtoConfiguration.get_notifications(self) dict

Get notifications.

Returns:

The notifications

Return type:

dict

Example:

import pyatproto

ap = pyatproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD)

notifications = ap.get_notifications()

print(notifications)

Get a Post

pyatproto.AtProtoConfiguration.get_post(self, atp_uri: str) dict

Get a post.

Parameters:

atp_uri – The ATP URI of the post

Returns:

The post

Return type:

dict

Example:

import pyatproto

ap = atproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD)

post = ap.get_post("atp://rkey")

print(post)

Get Posts a User Has Liked

pyatproto.AtProtoConfiguration.get_likes(self, user=None) dict

Get the likes of a user.

Returns:

The likes

Return type:

dict

Example:

import pyatproto

ap = pyatproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD)

likes = ap.get_likes()

print(likes)

List Users a User Follows

pyatproto.AtProtoConfiguration.get_following(self, user=None) dict

Get the following of a user.

Returns:

The following

Return type:

dict

Example:

import pyatproto

ap = pyatproto.AtProtoConfiguration(ENDPOINT, USERNAME, PASSWORD)

following = ap.get_following()

print(following)

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:

dict

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)

Check if XRPC Method is Supported

pyatproto.is_supported_method(method: str) bool[source]

Check if a method is supported by this library.

Parameters:

method – The method to check

Returns:

Whether the method is supported

Return type:

bool

Example:

import pyatproto

print(pyatproto.is_supported_method("com.atproto.handle.change"))