๐Ÿ€ ATproto library for gleam
atproto library gleam
35

Configure Feed

Select the types of activity you want to include in your feed.

possum: use GetPlcData endpoint instead

kacaii.dev (Jun 29, 2026, 10:42 PM -0300) e121ef2d 343f1b84

+11 -20
+1 -1
README.md
··· 39 39 // including their handle and their service endpoint, where their Personal 40 40 // Data Server (PDS) is located. 41 41 request.new() 42 - |> possum.resolve_did_document(did) 42 + |> possum.get_plc_data(did) 43 43 44 44 // You also query your identifier by sending a request directly to your PDS. 45 45 request.new()
+4 -4
src/possum.gleam
··· 56 56 /// Documentation: [xrpc/com.atproto.server](https://endpoints.bsky.app/#bluesky-app/tag/comatprotoserver) 57 57 const com_atproto_server = "xrpc/com.atproto.server" 58 58 59 - /// Resolves a DID Document from the plc.directory, 59 + /// Get current PLC Data for the indicated DID, 60 60 /// this returns information about a Decentralized Identifier (DID), 61 61 /// including their handle and service endpoint. 62 62 /// ··· 70 70 /// 71 71 /// let request = 72 72 /// request.new() 73 - /// |> possum.resolve_did_document(did) 73 + /// |> possum.get_plc_data(did) 74 74 /// ``` 75 75 /// 76 76 /// Documentation: [AT Protocol DIDs](https://atproto.com/specs/did) 77 - pub fn resolve_did_document( 77 + pub fn get_plc_data( 78 78 request: request.Request(_), 79 79 did: String, 80 80 ) -> request.Request(_) { ··· 83 83 request 84 84 |> request.set_method(http.Get) 85 85 |> request.set_host("plc.directory") 86 - |> request.set_path(path) 86 + |> request.set_path(path <> "/data") 87 87 } 88 88 89 89 /// Resolves a handle to a DID using a HTTPS `/.well-known/` URL path,
+6 -15
test/possum_test.gleam
··· 2 2 import gleam/http/request 3 3 import gleam/httpc 4 4 import gleam/json 5 - import gleam/list 6 5 import gleeunit 7 6 import global_value 8 7 import possum ··· 14 13 const slingshot = "slingshot.microcosm.blue" 15 14 16 15 const plc_directory = "plc.directory" 17 - 18 - fn did_document_decoder() -> decode.Decoder(List(String)) { 19 - let service_endpoint = { 20 - use value <- decode.field("serviceEndpoint", decode.string) 21 - decode.success(value) 22 - } 23 - 24 - use endpoint <- decode.field("service", decode.list(service_endpoint)) 25 - decode.success(endpoint) 26 - } 27 16 28 17 pub type Context { 29 18 Context(handle: String, did: String, pds: String) ··· 45 34 let assert Ok(pds_response) = 46 35 request.new() 47 36 |> request.set_host(plc_directory) 48 - |> possum.resolve_did_document(did) 37 + |> possum.get_plc_data(did) 49 38 |> httpc.send 50 39 51 - let assert Ok(services) = 40 + let decoder = 41 + decode.at(["services", "atproto_pds", "endpoint"], decode.string) 42 + 43 + let assert Ok(pds) = 52 44 pds_response.body 53 - |> json.parse(did_document_decoder()) 45 + |> json.parse(decoder) 54 46 55 - let assert Ok(pds) = list.first(services) 56 47 Context(handle:, did:, pds:) 57 48 }) 58 49 }