MarshalX / atproto

The AT Protocol (🦋 Bluesky) SDK for Python 🐍
https://atproto.blue
MIT License
278 stars 30 forks source link

Add record namespaces with get, list, create, delete methods #263

Closed MarshalX closed 7 months ago

MarshalX commented 7 months ago

The implementation is hardcoded but works well... now input and returned records are well-typed. and record namespaces provide some kind of syntax sugar (i hope)

usage example:

client = Client(base_url='https://bsky.social')
client.login(os.environ['USERNAME'], os.environ['PASSWORD'])

posts = client.app.bsky.feed.post.list(client.me.did, limit=10)
for uri, post in posts.records.items():
     print(uri, post.text)

post = client.app.bsky.feed.post.get(client.me.did, AtUri.from_str(uri).rkey)
print(post.value.text)

post_record = models.AppBskyFeedPost.Main(text='test record namespaces', created_at=client.get_current_time_iso())
new_post = client.app.bsky.feed.post.create(client.me.did, post_record)
print(new_post)

deleted_post = client.app.bsky.feed.post.delete(client.me.did, AtUri.from_str(new_post.uri).rkey)
print(deleted_post)

rly idk will it helps a lot

closes #233