Xrpc Module
XRPC transport layer for AT Protocol API calls. Provides functions for executing queries (HTTP GET) and procedures (HTTP POST) against an authenticated AtpAgent.
All public functions in this module automatically handle:
Bearer token authentication from the agent's session. Automatic session refresh on 401 ExpiredToken responses (retries once with a new access token).Rate-limit retry on 429 responses (waits for the Retry-After duration, then retries once).JSON serialization/deserialization using . Extra headers from (e.g. proxy headers).
Functions and values
| Function or value |
Description
|
Full Usage:
paginate nsid initialParams getCursor setCursor agent
Parameters:
string
-
The NSID of the XRPC query method (e.g. "app.bsky.feed.getTimeline").
initialParams : 'P
-
The initial query parameters (typically with cursor set to None).
getCursor : 'O -> string option
-
A function that extracts the next-page cursor from a response.
Return None to signal that there are no more pages.
setCursor : string option -> 'P -> 'P
-
A function that produces updated parameters with the given cursor value set.
agent : AtpAgent
-
The AtpAgent to send requests through.
Returns: IAsyncEnumerable<Result<'O, XrpcError>>
An IAsyncEnumerable that yields one Result per page.
Enumeration stops when getCursor returns None or when an error occurs.
On error, the error result is yielded as the final element.
|
Paginates through a cursor-based XRPC query, returning an Each page is fetched lazily as the caller iterates the async enumerable. The underlying query function handles rate limiting and token refresh automatically.
Example
val pages: obj
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
val output: 'a
val cursor: 'a
val p: 'a
|
Full Usage:
procedure nsid input agent
Parameters:
string
-
The NSID of the XRPC method (e.g. "com.atproto.repo.createRecord").
input : 'I
-
The input value to serialize as the JSON request body.
agent : AtpAgent
-
The AtpAgent to send the request through.
Returns: Task<Result<'O, XrpcError>>
A Task resolving to Ok with the deserialized output on success,
or Error with an XrpcError on failure.
|
Executes an XRPC procedure (HTTP POST) with a JSON request body and a JSON response body.
The request body is serialized as
Example
val input: {| collection: string; record: obj; repo: obj |}
|
Full Usage:
procedureVoid nsid input agent
Parameters:
string
-
The NSID of the XRPC method (e.g. "com.atproto.repo.deleteRecord").
input : 'I
-
The input value to serialize as the JSON request body.
agent : AtpAgent
-
The AtpAgent to send the request through.
Returns: Task<Result<unit, XrpcError>>
A Task resolving to Ok () on success,
or Error with an XrpcError on failure.
|
Executes an XRPC procedure (HTTP POST) with a JSON request body that returns no response body.
Use this for XRPC procedures that return 200 with no body (e.g. delete operations).
The request body is serialized as |
Full Usage:
query nsid parameters agent
Parameters:
string
-
The NSID of the XRPC method (e.g. "app.bsky.feed.getTimeline").
parameters : 'P
-
An F# record whose fields are serialized to query-string parameters via toQueryString.
Option fields that are None are omitted; list fields are emitted as repeated parameters.
agent : AtpAgent
-
The AtpAgent to send the request through.
Returns: Task<Result<'O, XrpcError>>
A Task resolving to Ok with the deserialized output on success,
or Error with an XrpcError on failure.
|
Executes an XRPC query (HTTP GET) with query-string parameters.
Automatically retries once on 429 (rate limit) after waiting for the
Example
type GetProfileParams =
{ Actor: string }
Multiple items
val string: value: 'T -> string -------------------- type string = System.String |
Full Usage:
queryBinary nsid parameters agent
Parameters:
string
-
The NSID of the XRPC method (e.g. "com.atproto.sync.getBlob").
parameters : 'P
-
An F# record whose fields are serialized to query-string parameters via toQueryString.
agent : AtpAgent
-
The AtpAgent to send the request through.
Returns: Task<Result<byte[], XrpcError>>
A Task resolving to Ok with the raw response bytes on success,
or Error with an XrpcError on failure.
|
Executes an XRPC query (HTTP GET) with query-string parameters that returns raw bytes
instead of JSON. Used for binary endpoints such as
Automatically retries once on 429 (rate limit) after waiting for the
|
Full Usage:
queryNoParams nsid agent
Parameters:
string
-
The NSID of the XRPC method (e.g. "app.bsky.actor.getProfile").
agent : AtpAgent
-
The AtpAgent to send the request through.
Returns: Task<Result<'O, XrpcError>>
A Task resolving to Ok with the deserialized output on success,
or Error with an XrpcError on failure.
|
Executes an XRPC query (HTTP GET) with no query-string parameters.
Automatically retries once on 429 (rate limit) after waiting for the |