Examples
Bulk create offerings from a CSV
import { KadaikodiSDK } from '@kadaikodi/sdk';
import { parse } from 'csv-parse/sync';
import { readFileSync } from 'fs';
const sdk = new KadaikodiSDK();
await sdk.auth.signIn({ username: '[email protected]', password: 'secret' });
const workspaces = await sdk.auth.fetchWorkspaces();
await sdk.auth.issueWorkspaceToken(workspaces[0].id, workspaces[0].organizationId);
const records = parse(readFileSync('./offerings.csv', 'utf8'), {
columns: true,
skip_empty_lines: true,
});
for (const row of records) {
await sdk.kadaikodi.offerings.create({
name: row.name,
category: row.category,
price: parseFloat(row.price),
stock: parseInt(row.stock),
fulfillmentTypes: row.fulfillmentTypes.split(','),
});
}
Poll for order completion
async function waitForOrder(orderId: string, timeoutMs = 300000) {
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
const order = await sdk.kadaikodi.orders.get(orderId);
if (order.status === 'COMPLETED') return order;
await new Promise(r => setTimeout(r, 10000));
}
throw new Error('Order did not complete in time');
}
Webhook receiver (Node/Express)
import { createHmac } from 'crypto';
import express from 'express';
const app = express();
app.use(express.raw({ type: 'application/json' }));
app.post('/kadaikodi-webhook', (req, res) => {
const sig = req.headers['x-kadaikodi-signature'] as string;
const expected = createHmac('sha256', process.env.WEBHOOK_SECRET!)
.update(req.body.toString())
.digest('hex');
if (sig !== expected) return res.sendStatus(401);
const event = JSON.parse(req.body.toString());
console.log(`Received ${event.type} for order ${event.data.orderId}`);
res.sendStatus(200);
});
app.listen(8080);
Python: list and filter offerings
import asyncio
from kadaikodi_sdk import KadaikodiSDK
async def main():
sdk = KadaikodiSDK()
await sdk.auth.sign_in(email="[email protected]", password="secret")
offerings = await sdk.kadaikodi.offerings.list()
available = [o for o in offerings if o.get("available") and o.get("stock", 0) > 10]
for o in available:
print(f"{o['name']} — ₹{o['price']} ({o['stock']} in stock)")
await sdk.close()
asyncio.run(main())
CLI: nightly order export
#!/bin/bash
set -euo pipefail
export BURDENOFF_ENV=prod
kadaikodi auth login --client-credentials --client-id "$CLIENT_ID" --client-secret "$CLIENT_SECRET"
kadaikodi workspace set "$WORKSPACE_ID"
# Export today's orders as JSON
kadaikodi kadaikodi orders list --format json --since 24h > /backups/orders-$(date +%Y%m%d).json