@spuentesp_pkgs/woocommerce-sdk
v0.1.4
Published
Complete TypeScript SDK for WooCommerce REST API v3
Maintainers
Readme
@stockflow/woocommerce-sdk
Complete TypeScript SDK for the WooCommerce REST API v3.
Features
- 🎯 Complete API Coverage - All WooCommerce REST API v3 endpoints
- 📘 Full TypeScript Support - 120+ type definitions
- 🔐 OAuth 1.0a Authentication - Built-in consumer key/secret auth
- 🪝 Webhook Support - Type-safe webhook payloads
- 🔄 Bulk Operations - Support for bulk create/update/delete
- ⚡ Modern Architecture - Modular, tree-shakeable design
- 🧪 Fully Tested - 60+ tests with comprehensive coverage
- 🚀 Zero Config - Works out of the box with sensible defaults
Installation
bun add @stockflow/woocommerce-sdkQuick Start
import { WooCommerceClient } from '@stockflow/woocommerce-sdk'
const woocommerce = new WooCommerceClient({
url: 'https://your-store.com',
consumerKey: 'ck_your_consumer_key',
consumerSecret: 'cs_your_consumer_secret',
version: 'wc/v3',
})
// Fetch products
const products = await woocommerce.products.list({ per_page: 50 })
// Get orders
const orders = await woocommerce.orders.list({ status: 'processing' })
// Create customer
const customer = await woocommerce.customers.create({
email: '[email protected]',
first_name: 'John',
last_name: 'Doe',
})API Coverage
Products & Catalog
- ✅ Products (CRUD + batch operations)
- ✅ Product Variations
- ✅ Product Categories
- ✅ Product Tags
Orders & Sales
- ✅ Orders (CRUD + batch operations)
- ✅ Order Notes
- ✅ Order Refunds
Customers
- ✅ Customers (CRUD + batch operations)
- ✅ Customer Downloads
Marketing
- ✅ Coupons (CRUD + batch operations)
Webhooks
- ✅ Webhooks (CRUD + batch operations)
- ✅ Webhook Deliveries
Error Handling
import {
WooCommerceError,
WooCommerceNotFoundError,
WooCommerceValidationError,
} from '@stockflow/woocommerce-sdk'
try {
const product = await woocommerce.products.get(999)
} catch (error) {
if (error instanceof WooCommerceNotFoundError) {
console.log('Product not found')
} else if (error instanceof WooCommerceValidationError) {
console.log('Validation errors:', error.errors)
}
}Advanced Features
Auto-Pagination
// Automatically fetches all pages
const allProducts = await woocommerce.products.getAll('publish')Batch Operations
const result = await woocommerce.products.batch({
create: [
{ name: 'Product 1', type: 'simple', regular_price: '19.99' },
{ name: 'Product 2', type: 'simple', regular_price: '29.99' },
],
update: [{ id: 123, regular_price: '25.00' }],
delete: [456],
})Retry with Backoff
import { retryWithBackoff } from '@stockflow/woocommerce-sdk'
const products = await retryWithBackoff(
() => woocommerce.products.list({ per_page: 100 }),
3, // max retries
2000 // base delay in ms
)Documentation
Package Stats
- Lines of Code: 6,935
- TypeScript Files: 30
- Types/Interfaces: 120+
- API Methods: 90+
- Test Coverage: 60+ tests
- Dependencies: 2 (oauth-1.0a, crypto-js)
License
MIT
