Skip to main content

README.md

# atproto_client

> **Alpha.** Pre-1.0 and evolving alongside
> [at-record](https://tangled.org/@mokkenstorm.dev/at-record); expect breaking
> changes between 0.x releases.

A small, transport-agnostic [atproto](https://atproto.com/) client for Gleam.
No app or lexicon knowledge: XRPC, identity resolution, OAuth discovery, blobs,
and generic repo CRUD. Modules live under the `atproto/` namespace.

## Transport injection

The client carries a `send` function instead of a hardcoded HTTP backend, so it
compiles on both erlang and javascript and you choose the backend:

```gleam
import atproto/xrpc
import gleam/httpc
import gleam/result
import gleam/string

let client =
  xrpc.Client(send: fn(req) {
    httpc.send(req) |> result.map_error(string.inspect)
  })
```

## Modules

| Module             | What it does                                                                |
| ------------------ | --------------------------------------------------------------------------- |
| `atproto/xrpc`     | `Client`, `XrpcError`, `get`/`post_json`, `parse`.                          |
| `atproto/identity` | `resolve_pds` (handle/DID -> PDS) via Slingshot `resolveMiniDoc`.           |
| `atproto/auth`     | `create_session` (`com.atproto.server.createSession`).                      |
| `atproto/repo`     | `list_records`/`create_record`/`delete_record`, generic over a row decoder. |
| `atproto/uri`      | at-uri helpers (`rkey`).                                                    |

## Development

```sh
gleam test
```