Skip to main content

blueskysocial

blueskysocial is a Python library for managing social media posts and images. It provides a Client class for interacting with social media platforms, as well as classes for representing posts and images.

Extended ducumentation provided by Devin AI DeepWiki: https://deepwiki.com/dmoggles/blueskysocial

Important Note About Issues

While I welcome issues and try to work on them, I also have come to realise that I frequently don't see them.

If you submit an issue, I kindly ask that you also send me a message to https://bsky.app/profile/dmitry.mclachbot.com to let me know about it

Installation

To install blueskysocial, you can use pip:

pip install blueskysocial

Usage

Making an individual post

from blueskysocial import Client, Post, Image

client = Client()
client.authenticate(user_name, password)

image = Image('path/to/image.jpg', alt_text='This is an image.')
post = Post('Hello, world!, This is my first post.', with_attachments=[image])
client.post(post)

Posting threads

from blueskysocial import Client, Post, Image

client = Client()
client.authenticate(user_name, password)

image = Image('path/to/image.jpg', alt_text='This is an image.')
post = Post('Hello, world!, This is my first post.', with_attachments=[image])
second_post = Post('Another Post')
client.post_thread([post,second_post])

Posting with a video.

As of version 1.5.0, embedding video in your post is supported. Currently video can only be embedded from a local file. Please note, that when embedding a video in a post, it may take several minutes for Bluesky to process your video, during which a video frame with "Video Not Found" will appear in your post.

The following video formats are supported

  • mp4
  • mpeg
  • webm
  • mov
from blueskysocial import Client, Post, Video
client = Client()
client.authenticate(user_name, password)

video = Video('path/to/video.mov')
post = Post('Video Post', with_attachments=video)
client.post(post)

Bluesky counts URL characters towards the 300 character limit. The solution to this is to format your links. blueskysocial supports markdown link formatting. If you format your post text in the following fashion

from blueskysocial import Client, Post

client = Client()
client.authenticate(user_name, password)
post = Post('Hello, world!, This is my first post.  But with a link.  [Click here](http://really.long.url.here)'),
clinet.post(post)

Your post text will be "Hello, world!, This is my first post. But with a link. Click here", with the words "Click here" being a link. In this fashion, only the characters in "Click here" count towards the limit

Web Cards

Webcards are the small preview images of a linked website that appear at the bottom of the posts and also serve as links. You can embed a webcard with the following syntax

from blueskysocial import Client, Post, WebCard

client = Client()
client.authenticate(user_name, password)
webcard = WebCard("http://url_to_link_to.com/article")
post = Post('Check out this article!', with_attachments=webcard)
clinet.post(post)

Direct Messsage Interface

Get all convos and show the member and last message of the last conversation

convos = client.get_convos()
print(convos[-1].participant)
print(convos[-1].last_message)

Get convos based ona filter. Many other filters are available, this is not an exhaustive list

convos = client.get_convos(
    bs.F.And(
        bs.F.Eq(bs.F.Participant, 'someusername.bsky.social'),
        bs.F.GT(bs.F.LastMessageTime, '2024-01-01')
    )
)
print(convos[-1].participant)
print(convos[-1].last_message)

Get all messages in a conversation

messages = convos[-1].get_messages()
print(messages[0].sent_at)
print(messages[-1].sent_at)
print(messages[0].text)

Please notice that the message list is ordered such that last message is first

2024-11-26 12:47:31.704000
2024-11-22 22:33:38.323000
Great stuff!

Get a conversation with a specific member or members. This is also how you create a new conversation if you want to DM someone you haven't sent messages to before

convo = client.get_convo_for_members('someusername.bsky.social')

Send a message

convo.send_message('Hello, World!')

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

blueskysocial is licensed under the MIT License. See LICENSE for more information.


Metadata

Release files for blueskysocial 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blueskysocial 2.1.0
File Size Uploaded Provenance
blueskysocial-2.1.0.tar.gz 43.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for blueskysocial 2.1.0
File Interpreter ABI Platform
blueskysocial-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 93.4 kB

Release files / blueskysocial-2.1.0.tar.gz

Download URL blueskysocial-2.1.0.tar.gz
Size 43.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9c72fdd38a469e92274a2e9da7e8e6d257ebb678cd77c82437c757065b5053fe
BLAKE2b-256 checksum
How to use checksums
5b3f3fc953c8def4a08e534231e508a2d0cff36e189c054a8a14e6123d13ec8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / blueskysocial-2.1.0-py3-none-any.whl

Download URL blueskysocial-2.1.0-py3-none-any.whl
Size 49.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1028f7cb2667b2d5158475ed25806166bfa2a923708ebfa24375ea32a51afd7e
BLAKE2b-256 checksum
How to use checksums
b92fd91e28d3e9dfd5545aa79a8931858770ae8d5b3f76230a02a4e5901e1f81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for blueskysocial 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page