Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ianklatzco/atprototools
easy-to-use and ergonomic library for interacting with bluesky
https://github.com/ianklatzco/atprototools
Last synced: 15 days ago
JSON representation
easy-to-use and ergonomic library for interacting with bluesky
- Host: GitHub
- URL: https://github.com/ianklatzco/atprototools
- Owner: ianklatzco
- License: mit
- Created: 2023-01-24T21:44:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-18T16:39:44.000Z (over 1 year ago)
- Last Synced: 2024-12-10T00:42:11.633Z (24 days ago)
- Language: Python
- Homepage:
- Size: 75.2 KB
- Stars: 74
- Watchers: 9
- Forks: 12
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-atproto - Easy-to-use and ergonomic library for interacting with bluesky
- awesome-bluesky-tools - Atprototools - Comprehensive library for Bluesky API. (Development & SDKs)
- awesome-bluesky - atprototools - Low level library to copy/create posts via Bsky API (Migration / Web)
README
## atprototools
Easy-to-use and ergonomic library for interacting with bluesky,
packaged so you can `pip install atprototools` and go.this library should serve as a gentle guide of mostly natural-language
python to get as many people writing bsky code as possible.## ONE-LINER TO GET STARTED *INSTANTLY* (ノ ゜Д゜)ノ ︵:
```
pip install atprototools && export BSKY_USERNAME="yourname.bsky.social" && export BSKY_PASSWORD="yourpassword" && python -i -c "import atprototools, os; atp = atprototools.Session(os.environ.get('BSKY_USERNAME'), os.environ.get('BSKY_PASSWORD')); atp.postBloot('hello world from atprototools!')"
# now use atp.whatever_you_need
```## TWO-LINER TO GET STARTED YOUR SECOND TIME
```
export BSKY_USERNAME="yourname.bsky.social" && export BSKY_PASSWORD="yourpassword"
python -i -c "import atprototools, os; atp = atprototools.Session(os.environ.get('BSKY_USERNAME'), os.environ.get('BSKY_PASSWORD'))"
# now use atp.whatever_you_need
```Usage:
```bash
pip install atprototools
export BSKY_USERNAME="yourname.bsky.social"
export BSKY_PASSWORD="yourpassword"
``````python
from atprototools import Session
import osUSERNAME = os.environ.get("BSKY_USERNAME")
PASSWORD = os.environ.get("BSKY_PASSWORD")session = Session(USERNAME, PASSWORD)
# make a text post
resp = session.postBloot("hello world from atprototools")# post an image
# session.postBloot("here's an image!", "path/to/your/image")# get bloots/posts
latest_bloot = session.getLatestNBloots('klatz.co',1).content# get archive
# carfile = session.getArchive().content# reply to a post
# Get first post details for replying to, you can also reply to other posts
# from getting bloots other ways
# Using "hello world" bloot from above:
first_post = resp.json()
# Create reply_ref:
# - root is the highest up original post
# - parent is the comment you want to reply to directly
# if you want to reply to root make both the same
reply_ref = {"root": first_post, "parent": first_post}
session.postBloot("this is the reply", reply_to=reply_ref)
# TODO write a test for replies
```PEP8 formatted; use autopep8.
### Running tests
```
# clone repo
cd atprototools
python -m unittest
```### changelog
- 0.0.17: chaged case to consistently be camelCase - thanks BSculfor!
- 0.0.16: replies! added to post_bloot, thanks to Jxck-S
- 0.0.15: get_bloot_by_url switched to getPosts instead of getPostThread
- 0.0.14: refactoring for cbase talk
- 0.0.13: register(), thanks Chief!
- 0.0.12: Set your own ATP_HOST! get_skyline. Thanks Shreyan.
- 0.0.11: images! in post_bloot.
- 0.0.10: follow, getProfile
- 0.0.9: move everything into a session class
- 0.0.8: get_bloot_by_url, rebloot
- 0.0.7: getRepo (car files) and get_latest_n_bloots### Thanks to
- alice
- [sirodoht](https://github.com/sirodoht)