@araute/sdk
v0.1.0
Published
Bun and Node.js SDK for the Araute public API.
Downloads
16
Readme
@araute/sdk
Create and manage Araute payments from TypeScript, Bun, or Node.js.
The SDK gives you typed resource clients, camelCase request and response fields, and consistent handling for pagination, retries, cancellation, and API errors.
Install
npm install @araute/sdk
# or: pnpm add @araute/sdk
# or: bun add @araute/sdkStart here
Keep your secret key in an environment variable:
import { Araute } from "@araute/sdk";
const araute = new Araute({
apiKey: process.env.ARAUTE_API_KEY!,
});
const checkout = await araute.checkouts.create({
amount: 1990, // amounts are in centavos
methods: ["PIX", "CARD"],
successUrl: "https://example.com/checkout/success",
});
console.log(checkout.url);The default API URL is https://api.araute.com/v1. You can override it, provide a custom fetch, or add a user-agent suffix:
const araute = new Araute({
apiKey: process.env.ARAUTE_API_KEY!,
baseUrl: "https://api.example.com/v1",
userAgent: "my-store/1.0.0",
});Resources
All methods return promises. Most resources support create, list, and get; customers, products, and subscriptions also support updates where defined.
const customer = await araute.customers.create({
name: "Ada Lovelace",
email: "[email protected]",
});
const product = await araute.products.create({ name: "Pro plan" });
const price = await araute.prices.create({
product: product.id,
unitAmount: 1990,
recurring: { interval: "MONTH", intervalCount: 1 },
});
const subscription = await araute.subscriptions.create({
customer: customer.id,
items: [{ price: price.id }],
});
const payment = await araute.payments.create({
amount: 1990,
methods: ["PIX"],
});Available namespaces:
customers— create, list, retrieve, and update customersproducts— create, list, retrieve, and update productsprices— create, list, and retrieve pricescheckouts— create, list, retrieve, and expire checkout sessionspayments— create, list, retrieve, confirm, and cancel payment intentssubscriptions— create, list, retrieve, update, pause, resume, cancel, and preview or apply changesinvoices— create, list, retrieve, add items, finalize, pay, void, and mark uncollectiblerefunds— create, list, and retrieve refunds
Errors
API problem responses throw ArauteError:
import { ArauteError } from "@araute/sdk";
try {
await araute.refunds.create({ charge: "ch_123", amount: 500 });
} catch (error) {
if (error instanceof ArauteError) {
console.log(error.code, error.status, error.detail, error.traceId);
}
}ArauteError also exposes field-level errors, param, amountRefundable, and retryAfter when the API provides them. Unexpected non-problem responses throw ArauteTransportError.
Development
bun install
bun run check
bun test
bun run buildThe package is released under the MIT license.
