import { createAgentClient } from '@ledewire/node'
const agent = createAgentClient({
key: process.env.LEDEWIRE_BUYER_KEY,
secret: process.env.LEDEWIRE_BUYER_SECRET,
})
// Authenticate once, then use the wallet and purchasing APIs freely
await agent.auth.loginWithBuyerApiKey({
key: process.env.LEDEWIRE_BUYER_KEY,
secret: process.env.LEDEWIRE_BUYER_SECRET,
})
const balance = await agent.wallet.balance()
const purchase = await agent.purchases.create({
content_id: 'abc123',
price_cents: 150,
})
const content = await agent.content.getWithAccess(purchase.content_id)
Creates a LedeWire client optimised for autonomous agents.
The client authenticates automatically using a buyer API key + secret. On the first API call the agent exchanges its credentials for a JWT; the
TokenManagerthen refreshes it proactively in the background — the agent never needs to callauth.loginWithBuyerApiKey()manually.Only buyer-relevant namespaces are exposed.
merchant,seller, andconfigare intentionally absent.