Back to Developer

SDKs

Official TypeScript/JavaScript SDKs for building on WhaleTools. Zero dependencies, fully typed, tree-shakeable.

Quick Install

# API Client (REST)
npm install @neowhale/api-client

# Storefront SDK (React hooks)
npm install @neowhale/storefront

# Telemetry SDK (observability)
npm install @neowhale/telemetry

# All packages
npm install @neowhale/api-client @neowhale/storefront @neowhale/telemetry

@neowhale/api-client

npm

Typed REST client — zero dependencies, full API coverage

$ npm install @neowhale/api-client
import { WhaleClient } from '@neowhale/api-client';

const whale = new WhaleClient({
  apiKey: 'wk_live_...',
  storeId: 'your-store-id',
});

// List products
const products = await whale.products.list('store-id');

// Create an order
const order = await whale.orders.create('store-id', {
  customer_id: '...',
  line_items: [{ product_id: '...', quantity: 1 }],
});

// Chat with AI agent
// (SSE streaming — use the REST API directly)

@neowhale/storefront

npm

React hooks for headless commerce — cart, auth, products, analytics

$ npm install @neowhale/storefront
import { WhaleProvider, useProducts, useCart } from '@neowhale/storefront';

function App() {
  return (
    <WhaleProvider storeId="your-store-id" apiKey="wk_live_...">
      <Shop />
    </WhaleProvider>
  );
}

function Shop() {
  const { products, loading } = useProducts();
  const { cart, addItem } = useCart();

  return (
    <div>
      {products.map(p => (
        <button key={p.id} onClick={() => addItem(p.id, 1)}>
          {p.name} — ${p.price}
        </button>
      ))}
      <p>Cart: {cart.item_count} items</p>
    </div>
  );
}

@neowhale/telemetry

npm

Observability SDK — errors, events, Web Vitals, AI call tracing

$ npm install @neowhale/telemetry
import { WhaleTelemetry } from '@neowhale/telemetry';

const telemetry = new WhaleTelemetry({
  storeId: 'your-store-id',
  apiKey: 'wk_live_...',
  environment: 'production',
});

// Auto-captures unhandled errors
// Manual error capture
telemetry.captureError(new Error('Something went wrong'));

// Custom events
telemetry.trackEvent('checkout_completed', {
  order_id: '...',
  total: 49.99,
});

// AI call tracing
telemetry.traceAICall({
  model: 'claude-sonnet-4-6',
  input_tokens: 150,
  output_tokens: 320,
  duration_ms: 1200,
});

API Client Resources

The API client provides typed methods across 31 namespaces covering 200+ REST resources. Every method returns typed responses with full IntelliSense support.

NamespaceMethodsDescription
productslist, get, create, update, deleteCatalog management
orderslist, get, create, updateOrder management
customerslist, get, create, updateCRM
inventorylist, get, adjust, transferStock levels
locationslist, get, create, update, deleteStore locations
analyticssales, dailySales, weeklySales, traffic, funnel, attribution, inventory, customers, productsBusiness analytics
categorieslist, get, create, update, deleteProduct categories
agentslist, get, create, update, delete, conversations, messages, usageAI agents
webhookslist, get, create, update, delete, deliveries, testEvent subscriptions
generateimage, voice, text, video, removeBackgroundAI content generation
loyaltylist, get, create, update, rewards.list, transactions.listLoyalty programs
couponslist, get, create, update, deleteCoupon codes
dealslist, get, create, update, deleteDiscounts and deals
emailTemplateslist, get, create, update, deleteEmail templates
supplierslist, get, create, update, deleteSupplier management
purchaseOrderslist, get, create, updatePurchase orders
invoiceslist, get, create, updateInvoicing
segmentslist, get, create, update, deleteCustomer segments
reviewslist, get, create, update, deleteProduct reviews
metaAdscampaigns, adSets, ads, audiences, leadsMeta/Facebook Ads
googleAdscampaigns, adGroups, ads, keywords, audiencesGoogle Ads
fulfillmentlist, get, create, updateStatus, addTrackingOrder fulfillment
taxlist, get, create, update, delete, calculateTax rates
affiliateslist, get, create, update, conversions, payoutsAffiliate program
qrCodeslist, get, create, update, scans, analyticsQR codes
pipelinestages, createStage, listDeals, getDeal, createDeal, updateDeal, moveDeal, summarySales pipeline
wholesalelistPricing, setPricing, deletePricing, listApplications, reviewApplication, listCustomersWholesale B2B
embeddingscreate, search, index, delete, statsVector embeddings
enrichmentenrich, listProfiles, getProfileCustomer enrichment
teamMemberslist, get, create, update, deleteTeam management
teamInviteslist, create, deleteTeam invitations

Error Handling

import { WhaleClient, WhaleApiError } from '@neowhale/api-client';

const whale = new WhaleClient({ apiKey: 'wk_live_...' });

try {
  const product = await whale.products.get('store-id', 'product-id');
} catch (err) {
  if (err instanceof WhaleApiError) {
    console.log(err.status);     // 404
    console.log(err.type);       // "not_found_error"
    console.log(err.message);    // "Product not found"
    console.log(err.requestId);  // "req_abc123"
  }
}