Work very much in progress
Feature | Status |
---|---|
http client | 🟡 |
identifiers | 🔴 |
bsky | 🔴 |
crypto | 🔴 |
mst | 🔴 |
lexicon | 🔴 |
identity | 🔴 |
streaming | 🟡 |
service auth | 🔴 |
plc | 🔴 |
oauth server | 🔴 |
The client is using Martian under the hood to handle the HTTP endpoints published by the Bsky team in OpenAPI format
(require '[net.gosha.atproto.client :as at])
;; Unauthenticated client
(def session (at/init :base-url "https://public.api.bsky.app"))
;; Authenticated client
(def session (init :username "me.bsky.social"
:app-password "SECRET"
:base-url "https://bsky.social"))
;; Bluesky endpoints and their query params can be found here:
;; https://docs.bsky.app/docs/category/http-reference
(let [resp (at/call session :app.bsky.actor.get-profile {:actor "gosha.net"})]
(select-keys (:body @resp) [:handle :displayName :createdAt :followersCount]))
;; => {:handle "gosha.net",
;; :displayName "Gosha âš¡",
;; :createdAt "2023-05-08T19:08:05.781Z",
;; :followersCount 617}
Connect to Bluesky's Jetstream service to get real-time updates of public network data. Jetstream provides a JSON-based alternative to the binary CBOR firehose, making it easier to work with post streams, likes, follows, and other events.
(require '[net.gosha.atproto.jetstream :as jetstream]
'[clojure.core.async :as async]
'[examples.jetstream-analysis :as analysis]))
;; Connect with default settings (subscribes to posts)
(def conn (jetstream/connect-jetstream (async/chan 1024)))
;; Print out a single post (with 5 second timeout)
(let [event (async/alt!!
(:events conn) ([v] v)
(async/timeout 5000) :timeout)]
(clojure.pprint/pprint event))
;; Start analyzing the stream
(def analysis (analysis/start-analysis conn))
;; Get current statistics about post rates, sizes, etc
(analysis/get-summary @(:state analysis))
;; Save sample messages for offline analysis
(analysis/collect-samples conn
{:count 10
:filename "samples/my-samples.json"})
;; Cleanup
(analysis/stop-analysis analysis)
(jetstream/disconnect conn)
Check out the examples.jetstream-analysis
namespace for a complete example of stream processing and analysis.
Help is very much welcomed! Please reach out on 🦋 @gosha.net!
MIT, see LICENSE file