LedeWire SDK API Reference
    Preparing search index...

    Function createAgentClient

    • 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 TokenManager then refreshes it proactively in the background — the agent never needs to call auth.loginWithBuyerApiKey() manually.

      Only buyer-relevant namespaces are exposed. merchant, seller, and config are intentionally absent.

      Parameters

      Returns AgentClient

      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)