XrpcClient

class XrpcClient(baseUrl: String, val httpClient: HttpClient, val json: Json = DefaultJson, val authProvider: AuthProvider = NoAuth)

Ktor-backed XRPC client. Wraps a caller-supplied HttpClient so consumers control the engine, timeouts, retries, and logging. Generated XRPC bindings call query for GET /xrpc/<nsid> and procedure for POST /xrpc/<nsid>.

Auth is attached via a pluggable AuthProvider, never as a field on request DTOs. Override per-call with the auth parameter.

Parameters

baseUrl

Root URL of the PDS / AppView, e.g. https://bsky.social. No trailing /xrpc — the client appends it.

Constructors

Link copied to clipboard
constructor(baseUrl: String, httpClient: HttpClient, json: Json = DefaultJson, authProvider: AuthProvider = NoAuth)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
val httpClient: HttpClient
Link copied to clipboard
val json: Json

Functions

Link copied to clipboard
suspend fun <P, R> procedure(nsid: String, params: P, paramsSerializer: KSerializer<P>, responseSerializer: KSerializer<R>, errorMapper: XrpcErrorMapper = DefaultXrpcErrorMapper, auth: AuthProvider? = null, proxy: String? = null): R

Overload for procedures with no input body (e.g. deleteSession).

suspend fun <P, R> procedure(nsid: String, params: P, paramsSerializer: KSerializer<P>, input: ByteArray, inputContentType: ContentType, responseSerializer: KSerializer<R>, errorMapper: XrpcErrorMapper = DefaultXrpcErrorMapper, auth: AuthProvider? = null, proxy: String? = null): R

Overload for procedures whose lexicon declares a non-JSON input.encoding (e.g. image/jpeg, video/mp4, or the wildcard &#42;/&#42; used by com.atproto.repo.uploadBlob). The bytes are posted verbatim with the supplied inputContentType. Auth, DPoP, 401 retry, and error mapping behave identically to the JSON-body overload.

suspend fun <P, I, R> procedure(nsid: String, params: P, paramsSerializer: KSerializer<P>, input: I, inputSerializer: KSerializer<I>, responseSerializer: KSerializer<R>, encoding: String = ContentType.Application.Json.toString(), errorMapper: XrpcErrorMapper = DefaultXrpcErrorMapper, auth: AuthProvider? = null, proxy: String? = null): R
Link copied to clipboard
suspend fun <P, R> query(nsid: String, params: P, paramsSerializer: KSerializer<P>, responseSerializer: KSerializer<R>, errorMapper: XrpcErrorMapper = DefaultXrpcErrorMapper, auth: AuthProvider? = null, proxy: String? = null): R