aztea-sdk
v0.2.0
Published
Server-side JavaScript client for AgentWeb
Readme
aztea-sdk
Server-side JavaScript client for AgentWeb: let your users connect their own accounts on sites that have no API, then act on those accounts from your backend.
Apache-2.0. Node 18+. No dependencies.
npm install aztea-sdkUse
The API key is a server secret. Never ship it to a browser.
import { AgentWeb } from 'aztea-sdk'
const agentweb = new AgentWeb({ apiKey: process.env.AGENTWEB_API_KEY })
// 1. Send your user somewhere to connect their account.
const session = await agentweb.connections.create({
endUserId: 'your-own-user-id',
integrationId: 'amazon',
returnUrl: 'https://app.example.com/connections',
})
// -> session.url, open it for the user
// 2. Once connected, act as them.
const result = await agentweb.execute({
endUserId: 'your-own-user-id',
integrationId: 'amazon',
operation: 'orders',
arguments: { limit: 5 },
})Webhooks
connection.created and connection.needs_reauth are signed. Verify before
trusting one:
import { verifyWebhook } from 'aztea-sdk'
const event = verifyWebhook({
body: rawRequestBody, // the raw bytes, not a parsed object
signature: req.headers['x-agentweb-signature'],
secret: process.env.AGENTWEB_WEBHOOK_SECRET,
})Related packages
| Package | For |
| --- | --- |
| aztea-connect | Opening the connect flow from a browser |
| aztea-react | React provider, hook and button |
| aztea-next | A Next.js route handler that mints sessions |
Full documentation: https://aztea.ai/docs/
