@ned-ai/sdk
v1.0.0
Published
TypeScript SDK for the Ned AI API
Readme
@ned-ai/sdk
TypeScript SDK for the Ned AI API. Access your Shopify store analytics, profitability, customer segments, and marketing metrics programmatically.
Install
npm install @ned-ai/sdkQuick Start
import { NedClient } from '@ned-ai/sdk';
const ned = new NedClient({ apiKey: process.env.NED_API_KEY! });
// Get today's sales
const sales = await ned.analytics.getSalesContext({ period: 'today' });
console.log(sales.data.metrics.revenue);API Reference
Analytics
// Sales analytics with period comparison
ned.analytics.getSalesContext({ period: 'this_month', comparison: 'year_ago' })
// Daily sales breakdown
ned.analytics.getDailySales({ period: 'last_30_days' })
// Revenue forecast (Growth+ tier)
ned.analytics.getForecast(30)
// Profitability summary
ned.analytics.getProfitability({ period: 'this_month', view_type: 'summary' })
// Product-level profitability
ned.analytics.getProductProfitability({ sort_by: 'profit', limit: 10 })Customers
// Customer overview
ned.customers.getSummary()
// Customer segments by profit or activity tier
ned.customers.getSegments({ segment: 'profit_tier', limit: 10 })
// At-risk high-value customers
ned.customers.getAtRisk({ limit: 20 })Marketing
// Marketing efficiency (MER, CAC, ROAS)
ned.marketing.getMetrics({ period: 'this_month', view_type: 'summary' })
// Ad performance across platforms
ned.marketing.getAds({ period: 'last_30_days', platform: 'meta' })Period Options
today | yesterday | this_week | last_week | this_month | last_month | last_7_days | last_30_days | mtd | ytd
Error Handling
import { NedApiError, NedRateLimitError } from '@ned-ai/sdk';
try {
const sales = await ned.analytics.getSalesContext();
} catch (err) {
if (err instanceof NedRateLimitError) {
console.log(`Rate limited. Retry after ${err.retryAfter}s`);
} else if (err instanceof NedApiError) {
console.log(`API error ${err.statusCode}: ${err.message}`);
}
}Requirements
- Node.js 18+
- A Ned API key (get one at meetned.com)
License
MIT
