AD
Boost Your Brand on BlueSky—Exclusive banner space to amplify your reach within the BlueSky community.
BSkyInfo LogoBskyInfo
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryArticlesGuidesGlossaryBluesky SDKsSponsor
Submit
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryGuidesGlossaryArticlesBluesky SDKsSponsorSubmit
  1. SDKs
  2. /Python
  3. /psychonaut
jbn

psychonaut

A Python SDK for Bluesky and AT Protocol by jbn

Python async bluesky client and TUI (eventually)

GitHub Stats

43stars
2forks
2contributors
1open issues

Dates

Created:April 16, 2023
Last updated:November 26, 2024

README

The following content is from psychonaut's GitHub repository. All rights reserved by the original author.

Tests Docs

Psychonaut helmet

PROGRESS REPORT

  • Finish pydantic validation for reference types

What is this?

An async python sdk for Bluesky.

I used to do a pretty absurd amount of experiments with twitter's api. But musk has decided to turn that platform into a pay-for-play version of LinkedIn and banished all the tinkerers. So, now I'm here.

It has a bit of a weird structure. You basically do things like,

async with get_simple_client_session() as sess:
    posts: GetPostsResp = await GetPostsReq(uris=[...]).do_xrpc(sess)
    ...

which feels backwards from the expected,

async with get_simple_client_session() as sess:
    posts: GetPostsResp = await sess.do_xrpc(GetPostsReq(uris=[...]))

or even,

async with get_simple_client_session() as sess:
    posts: GetPostsResp = await sess.get_posts(uris=[...])

It's kinda an artifact of the way I did code generation but I kinda like it and fuck it S-expressions worked so there is a (completely nonsensical) precedence.

And, just to clarify, every request and response gets validated against the lexicon schema, which is nice (although reference types are still a WIP). Moreover, the generated code is auto-complete/copilot friendly. And, in theory, you could override do_xrpc to do clever things like caching, instead of hacking each particular api call.

But mostly I'm lazy so this is how it is.

Should I use this?

Almost certainly not. Right now it's a bucket of slop. I offer no guarantees about the stability of the API, the correctness of the implementation, or the quality of the documentation.

If you want to use it, go ahead.

Every single api call exists with Pydantic models for requests and responses (but with a few outstanding validations missing).

It's still unstable but I've been using it pretty regularly.

# In your venv or mamba env or whatever
pip install psychonaut

to use it as a library. This also installs the psychonaut command line tool.

psychonaut --help

# Temporary login
export BSKY_USERNAME=yourusername
export BSKY_PASSWORD=yourpassword

# Permanent login (~/.psychonaut.json)
psychonaut save-login yourusername 

psychonaut poast "hey look, an annoying cron job"

But definitely be mindful of the version because I'm going to break your code.

Alternatively, just use pipx

pipx install psychonaut

export BSKY_USERNAME=yourusername
export BSKY_PASSWORD=yourpassword

psychonaut poast "hell yea, pipx"

Firehose

EXTREMELY EXPERIMENTAL AND STILL NOT FINISHED

repos-firehose-stream saves the raw messages for subsequent replay so you can at least collect now and i'll get the json emit / validation working later.

# Stream the firehose
psychonaut repos-firehose-stream stream_dir

# Stream the firehose but print to stdout too
psychonaut repos-firehose-stream --tee stream_dir

# Replay serialized
psychonaut repos-firehose-replay stream_dir

# Replay serialized file
psychonaut repos-firehose-replay stream_dir/your_stream.b64-lines

How is this made?

Initially, this was a collaboration between the atproto repo, me, and my friend ChatGPT (using GPT-4). I had been toying around with this automatic langa<->langb transpiler in langchain. My original goal was to jointly build that while making my python client from the atproto repo. However, the fine folks at OpenAI didn't give me GPT-4 API access, and GPT-3 isn't quite good enough to do the job. So instead, this was me testing the fences "manually" (with ChatGPT). And now it's just me.

This also means this project was a bit...like theft? IDK.

Question of the generative hour: where is the boundary?

See Also (for pythonistas)

  • arroba
  • lexrpc
  • atprotools

Topics

blueskybluesky-clientsocial-media

Related SDKs

dannguyendancow-bluesky-fun-api-tool

Just having fun with python and Bluesky's AT Protocol. Trying to build a simple CLI and enough of SDK to easily explore and collect my own Bluesky data

1•Python
TahomaSoftSaxeBlueskyPython

A small python library to post basic text and media to bsky.app via atproto's xrpc API.

1•Python
Gorcenskiskeeter-deleter

A script for auto-deleting Bluesky posts

65•Python
Zetaphorbsky-altometer

A site that measures the current percentage of Bluesky posts missing alt text

7•Python
snarfedbridgy-fed

🌉 A bridge between decentralized social networks

1002•Python
snarfedgranary

💬 The social web translator

485•Python

Resources

GitHub Repository

License

MIT

Author

jbn
jbn

Activity

Last commit: November 26, 2024
Commit frequency: Unknown

Our Sponsors

Your Brand Here!

50K+ engaged viewers every month

Limited spots available!

📧 Contact us via email🦋 Contact us on Bluesky
BSkyInfo LogoBskyInfo

The Most Comprehensive Bluesky Tools Directory

Stay updated with the latest Bluesky tools and ecosystem news 🦋

Bluesky butterfly logo
Quick LinksSubmit a ToolSponsorAboutLegal Information
ToolsFeed DirectoryLabeler DirectorySchedulingAnalyticsAll ToolsCategoriesCollectionsTags
ResourcesArticlesBluesky GuidesBluesky GlossaryBluesky SDKsBluesky ResourcesSkyRaffleMeida Coverage
Our ProductsRaffleBlueAiTeach ToolsLaiewAI affiliate listFirsto

This website may contain affiliate links

© 2025 BskyInfo. All rights reserved.