@tageery/sdk
v1.0.0
Published
Official SDK for Tageery Developer API
Maintainers
Readme
tageery-sdk
Official TypeScript/JavaScript SDK for Tageery Developer API.
Installation
npm install tageery-sdk
# or
pnpm add tageery-sdk
# or
yarn add tageery-sdkUsage
Using API Key (Developer API)
import { PlatformClient } from 'tageery-sdk';
const client = new PlatformClient({
apiKey: process.env.PLATFORM_API_KEY!,
baseURL: 'https://api.yourplatform.com', // optional
});
// List your apps
const { apps } = await client.apps.list();
// Create a new app
const { app } = await client.apps.create({
name: 'My App',
description: 'A great app',
category: 'marketing',
});Using OAuth Access Token (Store API)
import { PlatformClient } from 'tageery-sdk';
const client = new PlatformClient({
accessToken: process.env.PLATFORM_ACCESS_TOKEN!,
baseURL: 'https://api.yourplatform.com',
});
// List products for a store
const { products } = await client.products.list('store_123', {
limit: 50,
status: 'active',
});
// Create a product
const { product } = await client.products.create('store_123', {
name: 'New Product',
basePrice: 29.99,
status: 'active',
});
// List orders
const { orders } = await client.orders.list('store_123', {
status: 'pending',
});Webhook Handling
import { WebhookHandler } from 'tageery-sdk/webhooks';
import express from 'express';
const app = express();
const handler = new WebhookHandler(process.env.WEBHOOK_SECRET!);
app.post('/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
const signature = req.headers['x-platform-signature'] as string;
const body = req.body.toString();
if (!handler.verify(signature, body)) {
return res.status(401).send('Invalid signature');
}
const event = handler.parse(body);
// Handle event
switch (event.event) {
case 'order.created':
console.log('New order:', event.data);
break;
case 'product.updated':
console.log('Product updated:', event.data);
break;
}
res.status(200).send('OK');
});API Reference
Products
client.products.list(storeId, params?)- List productsclient.products.get(storeId, productId)- Get productclient.products.create(storeId, product)- Create productclient.products.update(storeId, productId, updates)- Update productclient.products.delete(storeId, productId)- Delete product
Orders
client.orders.list(storeId, params?)- List ordersclient.orders.get(storeId, orderId)- Get orderclient.orders.update(storeId, orderId, updates)- Update order
Apps
client.apps.list(params?)- List your appsclient.apps.get(appId)- Get appclient.apps.create(app)- Create appclient.apps.update(appId, updates)- Update appclient.apps.publish(appId)- Publish app for review
Webhooks
client.webhooks.list(appId?)- List webhooksclient.webhooks.create(webhook)- Create webhookclient.webhooks.get(webhookId)- Get webhookclient.webhooks.update(webhookId, updates)- Update webhookclient.webhooks.delete(webhookId)- Delete webhook
License
MIT
