Get Started
Set up the aTIProto agent to integrate payments and subscriptions into your ATProto application.
Installation
Install the agent and lexicons packages:
npm install @atiproto/agent @atiproto/lexicons
Create an Authenticated Agent
The Agent from @atiproto/agent wraps any XrpcClient and proxies requests to the atiproto tipping service. It automatically injects the atproto-proxy header so requests are routed through your PDS to our service.
With @atproto/api Agent
If you're using the official @atproto/api package, restore an OAuth session and pass the agent directly:
import { Agent as BskyAgent } from "@atproto/api";import { Agent as TipAgent } from "@atiproto/agent";// See: https://github.com/bluesky-social/atproto/tree/main/packages/oauth/oauth-client#readmeimport { OAuthClient } from "@atproto/oauth-client";const oauthClient = new OAuthClient({// ...});// Restore an authenticated sessionconst oauthSession = await oauthClient.restore("did:plc:123");const bskyAgent = new BskyAgent(oauthSession);// Create a TipAgent — automatically uses withProxy()const paymentAgent = new TipAgent(bskyAgent);// Now you can call tipping APIsconst profile = await paymentAgent.com.atiproto.recipient.profile.get();
With Any XrpcClient
You can use any XrpcClient instance. The TipAgent will wrap it and add the proxy header for routing:
import { XrpcClient } from "@atproto/xrpc";import { Agent as TipAgent } from "@atiproto/agent";// Create any XrpcClient with your PDSconst client = new XrpcClient("https://your-pds.example.com", mySchemas);// Wrap it with the TipAgentconst paymentAgent = new TipAgent(client);
How It Works
When you create a TipAgent, it sets up a proxy to did:web:atiproto.com#tips_service. Your PDS receives the request, sees the proxy header, and forwards it to our service for processing.
The agent also provides full TypeScript types for all API methods, generated from the ATProto lexicon definitions. Every call is type-checked at compile time.
// All methods are fully typedconst { data } = await paymentAgent.com.atiproto.payment.item.create({subject: "did:plc:recipient123",amount: 500, // 500 cents = $5.00currency: "USD",});// data.tipUri, data.cartUri, data.checkoutUrl are all typedconsole.log(data.checkoutUrl);
Next Steps
- Learn about the checkout flow for creating carts, payments, and subscriptions
- Set up Broker Onboarding so users can receive payments
- Browse the lexicon reference for the complete API
- Deploy on the edge with the Edge OAuth Client for Cloudflare Workers