You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ruby client for the AT Protocol, with support for oauth/dpop authentication.
Installation
Add this line to your application's Gemfile:
gem'atproto_client'
Usage
# Initialize with your private key and existing access tokenclient=AtProto::Client.new(private_key:,access_token:)# Then requestclient.request(:get,"https://boletus.us-west.host.bsky.network/xrpc/app.bsky.feed.getPostThread",params: {uri: "at://did:plc:sdy3olcdgcxvy3enfgsujz43/app.bsky.feed.post/3lbr6ey544s2k"})# Body and params are optionals# Body will be stringified to json if it's a hashclient.request(:post,"#{pds_endpoint}/xrpc/com.atproto.repo.createRecord",body: {repo: did,collection: "app.bsky.feed.post",record: {text: "Posting from ruby",createdAt: Time.now.iso8601,}})# Can make requests with headers and custom body type client.request(:post,"#{pds_endpoint}/xrpc/com.atproto.repo.uploadBlob",body: image_data,headers: {"Content-Type": content_type,"Content-Length": content_length})# Refresh token when needed# Tokens are returned so they can be storedclient.refresh_token!(refresh_token:,jwk:,client_id:,site:,endpoint: )# Get initial access_token# (to be used in oauth flow -- see https://github.com/lasercatspro/omniauth-atproto)client=AtProto::Client.new(private_key: key)client.get_token!(code:,jwk:,client_id:,site:,endpoint:,code_verifier)
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.