SDK Reference
Full reference for the TypeScript and Python SDKs. Both expose the same surface, wallet management, payments, transactions, and spend policies.
TypeScript SDK
The TypeScript SDK is the primary SDK for Fixer Protocol. It targets ES2020+ and ships as both CommonJS and ESM. It has zero runtime dependencies.
Installation
npm install @fixerprotocol/sdk
# or: bun add @fixerprotocol/sdk | pnpm add @fixerprotocol/sdk
Requires Node.js ≥ 18 (for the global fetch API). Works with Bun and Deno without any polyfills.
FixerProtocol
The main client class. Exported as FixerProtocol from the package root.
import { FixerProtocol } from "@fixerprotocol/sdk";
const fixer = new FixerProtocol({
agentId: "my-agent",
apiKey: process.env.FIXER_API_KEY!,
baseUrl: "https://api.fixerprotocol.org", // optional, this is the default
});
Constructor parameters, FixerConfig
"research-agent-v2", "orchestrator-prod".
Bearer token on every request. Always load from an environment variable, never hard-code.
https://api.fixerprotocol.org. Useful for pointing at a staging environment or a self-hosted instance.
Instance properties
fixer.pay()
Route a payment to any service endpoint. The gateway detects the required protocol (x402 or MPP) from the target service's response and handles all handshake logic transparently.
const result: PayResult = await fixer.pay(options: PayOptions);
PayOptions
Authorization for services that require both payment and auth). Payment headers are injected automatically.
PayResult
200).fixer.transactions.get().privacy.mode is "full" or "confidential_amount". An encrypted note for your own records.privacy.disclosureKey was set. A ZK viewing credential openable only by the specified public key holder.Privacy example
const result = await fixer.pay({
endpoint: "https://api.service.com/resource",
method: "POST",
body: { query: "..." },
privacy: {
mode: "full", // hide amount, sender, receiver
disclosureKey: complianceOfficerPublicKey, // optional: auditor can decrypt
},
});
console.log(result.txHash); // Solana nullifier hash — no identity on-chain
console.log(result.privateNote); // encrypted note for your records
console.log(result.disclosureProof); // openable only by disclosureKey holder
fixer.wallet
Access your agent's Solana wallet. The wallet is created automatically on first use and persists across sessions via the Solana PDA associated with your agentId.
wallet.get()
Returns full wallet info including the on-chain address and USDC balance.
const wallet: WalletInfo = await fixer.wallet.get();
// {
// agentId: "my-agent",
// address: "7xKXtg2eH9sZ7pWbRqTJ3mQfJL...", // Solana PDA
// balance: { usdc: 42.50 }
// }
WalletInfo
wallet.balance()
Returns only the balance, a convenience shorthand for wallet.get() when you don't need the full wallet info.
const balance: WalletBalance = await fixer.wallet.balance();
console.log(balance.usdc); // 42.50
wallet.fund()
Programmatically top up the wallet balance.
const result: FundResult = await fixer.wallet.fund({
usdc: 100,
idempotencyKey: "top-up-2026-06-01", // optional
});
console.log(result.txHash); // Solana tx hash of the funding transaction
console.log(result.amount.usdc); // 100
console.log(result.balance.usdc); // updated balance after funding
FundOptions
fixer.transactions
transactions.list()
Retrieve a paginated list of transactions for this agent.
const result: TransactionList = await fixer.transactions.list({
limit: 50,
offset: 0,
protocol: "x402", // filter by protocol (optional)
from: "2026-05-01", // ISO 8601 date range (optional)
to: "2026-05-31",
});
ListTransactionsOptions
"2026-05-01" or "2026-05-01T00:00:00Z".from.Transaction object
transactions.get()
const tx: Transaction = await fixer.transactions.get("5xGh9...Kj3m");
console.log(tx.status); // "confirmed"
console.log(tx.solanaTxLink); // "https://explorer.solana.com/tx/5xGh9..."
fixer.policies
policies.get()
Retrieve the currently active spend policy for this agent.
const policy: SpendPolicy = await fixer.policies.get();
console.log(policy.dailyBudget?.usdc); // 100
policies.set()
Replace the agent's spend policy. All fields are optional, omit a field to leave it unconstrained.
const saved: SpendPolicy = await fixer.policies.set({
dailyBudget: { usdc: 100 },
perCallLimit: { usdc: 1.00 },
allowedDomains: ["api.dune.com", "api.browserbase.com"],
blockedDomains: ["badactor.com"],
rateLimit: { calls: 500, window: "1h" },
});
SpendPolicy fields
fixer.pay() call. Acts as a ceiling on individual payment amounts.allowedDomains.window is a duration string: "1m", "1h", "24h".
Error Handling
All SDK errors extend FixerError, which extends the built-in Error. Catch specific classes to handle different failure modes.
import {
FixerProtocol,
FixerError,
AuthenticationError,
InsufficientFundsError,
PolicyViolationError,
RateLimitError,
APIError,
} from "@fixerprotocol/sdk";
try {
const result = await fixer.pay({ endpoint: "https://api.service.com/" });
} catch (err) {
if (err instanceof AuthenticationError) {
// Invalid API key — check FIXER_API_KEY env var
console.error("Auth failed:", err.message);
} else if (err instanceof InsufficientFundsError) {
// Wallet balance too low
await topUpWallet();
} else if (err instanceof PolicyViolationError) {
// Blocked by a spend policy — log and skip
console.warn("Policy blocked:", err.message);
} else if (err instanceof RateLimitError) {
// Too many calls — back off and retry
await sleep(60_000);
} else if (err instanceof APIError) {
// Gateway returned an unexpected HTTP error
console.error(`API error ${err.statusCode}:`, err.message);
} else if (err instanceof FixerError) {
// Any other Fixer-specific error
console.error(`${err.code}:`, err.message);
} else {
// Network error, JSON parse error, etc.
throw err;
}
}
Error classes
err.code for the machine-readable error type and err.statusCode for the HTTP status.FIXER_API_KEY environment variable.err.statusCode for the HTTP status. Transient 5xx errors are safe to retry with exponential backoff.TypeScript Types
All types are exported from @fixerprotocol/sdk. Import only what you need.
import type {
FixerConfig,
PayOptions,
PayResult,
PrivacyOptions,
WalletInfo,
WalletBalance,
FundOptions,
FundResult,
Transaction,
TransactionList,
ListTransactionsOptions,
SpendPolicy,
} from "@fixerprotocol/sdk";
Python SDK
The Python SDK mirrors the TypeScript API with Pythonic naming conventions (snake_case). It requires Python 3.10+ and uses httpx for async HTTP.
Installation
pip install fixerprotocol
Quickstart
import os
import asyncio
from fixerprotocol import FixerProtocol
async def main():
fixer = FixerProtocol(
agent_id="my-research-agent",
api_key=os.environ["FIXER_API_KEY"],
)
# Make a payment
result = await fixer.pay(
endpoint="https://api.fal.ai/v1/inference",
method="POST",
body={"model": "flux-pro", "prompt": "A futuristic city skyline"},
)
print(f"Status: {result.status}")
print(f"Tx hash: {result.tx_hash}")
print(f"Amount: {result.amount_paid['usdc']} USDC")
print(f"Protocol: {result.protocol}")
# Wallet balance
balance = await fixer.wallet.balance()
print(f"Balance: {balance['usdc']} USDC")
# Spend policies
await fixer.policies.set(
daily_budget={"usdc": 50},
per_call_limit={"usdc": 0.50},
allowed_domains=["api.fal.ai", "api.dune.com"],
)
# Transaction history
result = await fixer.transactions.list(limit=10)
for tx in result["transactions"]:
print(f" {tx['tx_hash']} — {tx['amount']['usdc']} USDC")
asyncio.run(main())
Error handling (Python)
from fixerprotocol import (
FixerProtocol,
AuthenticationError,
InsufficientFundsError,
PolicyViolationError,
RateLimitError,
APIError,
)
try:
result = await fixer.pay(endpoint="https://api.service.com/")
except AuthenticationError:
print("Invalid API key")
except InsufficientFundsError:
print("Wallet balance too low")
except PolicyViolationError as e:
print(f"Blocked by policy: {e}")
except RateLimitError:
print("Rate limit hit — back off and retry")
except APIError as e:
print(f"API error {e.status_code}: {e}")
Python method reference
| Python method | TypeScript equivalent | Description |
|---|---|---|
await fixer.pay(...) | fixer.pay() | Route a payment |
await fixer.wallet.get() | fixer.wallet.get() | Wallet info + balance |
await fixer.wallet.balance() | fixer.wallet.balance() | USDC balance only |
await fixer.wallet.fund(...) | fixer.wallet.fund() | Top up wallet |
await fixer.transactions.list(...) | fixer.transactions.list() | List transactions |
await fixer.transactions.get(tx_hash) | fixer.transactions.get() | Single transaction |
await fixer.policies.get() | fixer.policies.get() | Current policy |
await fixer.policies.set(...) | fixer.policies.set() | Update policy |