Possum#
馃悁 ATproto library for gleam.
Helps you build HTTP requests that interact with your Personal Data Server. The user is responsible for sending the request and decode the response.
Example#
gleam add gleam_http
possum = { git = "https://tangled.org/kacaii.dev/possum", ref = "commit-hash" }
import gleam/http/request
import possum
pub fn main() -> Nil {
// Querying your did
request.new()
|> request.set_host("bsky.social")
|> possum.resolve_handle("tangled.org")
// Acquiring a JWT token
// App Passwords can be generated in you Bluesky settings.
request.new()
|> request.set_host("bsky.social")
|> possum.create_session(
"kacaii.dev",
"bsky-app-password",
option.None,
option.None
)
// Including your authorization Header
request.new()
|> request.set_host("bsky.social")
|> possum.authorized("my-access-token")
// Refreshing an authorized Session
request.new()
|> request.set_host("bsky.social")
|> possum.refresh_session("refresh-token")
// Reading public data from a repository.
// No authorization needed.
request.new()
|> request.set_host("bsky.social")
|> possum.list_records(
repository: "kacaii.dev",
collection: "site.standard.document",
limit: option.Some(3),
cursor: option.None,
reverse: option.None,
)
}