AT Protocol SDK for Python

0.0.65 · active · verified Sun Apr 12

The `atproto` library is the official Python SDK for the AT Protocol, the decentralized social networking protocol behind Bluesky. It provides support for Lexicon Schemes, XRPC clients, Firehose, Identity, DID keys, signatures, and more, with all models, queries, and procedures automatically generated. As of version 0.0.65, the SDK is actively developed with frequent releases, though it remains in a pre-1.0.0 state where backward compatibility is not strictly guaranteed.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the synchronous `Client`, log in using environment variables for credentials, and send a simple text post to the AT Protocol network (e.g., Bluesky).

import os
from atproto import Client

def main():
    client = Client()
    try:
        # Use environment variables for sensitive credentials
        handle = os.environ.get('ATPROTO_USERNAME', 'your-handle.bsky.social')
        password = os.environ.get('ATPROTO_PASSWORD', 'your-app-password')

        profile = client.login(handle, password)
        print(f"Welcome, {profile.display_name}!")

        # Send a simple text post
        post_text = "Hello World from the AT Protocol Python SDK! #atproto #python"
        response = client.send_post(text=post_text)
        print(f"Posted: {post_text}\nURI: {response.uri}")

    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == '__main__':
    main()

view raw JSON →