the old web is dying. a new web struggles to be born. now is the time of posting.

~ David Buchanan (@retr0-id.translate.goog)

Bluesky is built on (…and building…) the AT Protocol, a protocol for federated social networking. You can install the atproto library to get higher level constructs for working with the AT Protocol, as of July 2023 this appears to be the best Python library available for this task.

To make a post with a link card embedded in it, you can run and remix this snippet:

from atproto import Client
from atproto.xrpc_client.models import AppBskyEmbedExternal

BSKY_USERNAME = "<your_username>"
BSKY_PASSWORD = "<your_password>"
URL = "https://chris.partridge.tech/notes/post-link-on-bluesky-atproto-python/"
URL_TITLE = "cool notes"
URL_DESCRIPTION = "this taught me how to link post"
POST_TEXT = "test post please ignore!"

client = Client()
client.login(BSKY_USERNAME, BSKY_PASSWORD)
external_link = AppBskyEmbedExternal.External(uri=URL, title=URL_TITLE, description=URL_DESCRIPTION)
client.send_post(text=POST_TEXT, embed=AppBskyEmbedExternal.Main(external=external_link))