Registry / ecommerce / woocommerce-rest-ts-api

woocommerce-rest-ts-api

JSON →
library7.1.2jsnpmunverified

A modern, type-safe TypeScript library for WooCommerce REST API. Current stable version is 7.1.2 (released 2025). Provides full TypeScript support with comprehensive type definitions, supports both CommonJS and ES modules, built-in OAuth 1.0a authentication, custom error classes, and convenience methods. Compared to the official JavaScript client, it offers enhanced error handling, better response typing with WooCommerceApiResponse<T>, and tree-shaking support. Released under the MIT license.

npm install woocommerce-rest-ts-api
INSTALL
IMPORT
SIG · WOOCOMMERCE-REST-T
W
woocommerce-rest-ts-api
ecommercejavascriptv7.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WooCommerceRestApi
import WooCommerceRestApi from 'woocommerce-rest-ts-api'
const WooCommerceRestApi = require('woocommerce-rest-ts-api')
Default export. For CJS, use require('woocommerce-rest-ts-api').default.
WooRestApiOptions
import { WooRestApiOptions } from 'woocommerce-rest-ts-api'
import { WooRestApiOptions } from 'woocommerce-rest-ts-api/src/types'
Type export. Available since v7.0.0.
WooCommerceApiResponse
import { WooCommerceApiResponse } from 'woocommerce-rest-ts-api'
Type export for response wrapping. Available since v7.1.0.
WooCommerceRestApi (type)
import type WooCommerceRestApi from 'woocommerce-rest-ts-api'
import { WooCommerceRestApi } from 'woocommerce-rest-ts-api'
For type-only imports, use import type. The class is the default export.

Instantiates the WooCommerceRestApi client and fetches products using the getAsync convenience method.

import WooCommerceRestApi from 'woocommerce-rest-ts-api'; const api = new WooCommerceRestApi({ url: 'https://your-store.com', consumerKey: process.env.WC_CONSUMER_KEY ?? '', consumerSecret: process.env.WC_CONSUMER_SECRET ?? '', version: 'wc/v3', queryStringAuth: false, }); async function getProducts() { try { const response = await api.getAsync('/products'); console.log('Products:', response.data); } catch (error) { console.error('Error:', error); } } getProducts();
Debug
Known issues
deprecatedThe 'get()', 'post()', 'put()', 'delete()' methods are deprecated. Use 'getAsync()', 'postAsync()', 'putAsync()', 'deleteAsync()' instead.
fix
Replace synchronous methods with async versions. Example: api.getAsync('/products')
affects: >=6.0.0
breakingESM default import changed: Previously required .default chaining in ESM, now direct default import works.
fix
Use 'import WooCommerceRestApi from 'woocommerce-rest-ts-api'' instead of 'import { default as WooCommerceRestApi } from ...'
affects: >=7.0.0
gotchaCommonJS require must use .default: const WooCommerceRestApi = require('woocommerce-rest-ts-api').default
fix
Add .default when using require()
affects: >=7.0.0
gotchaOAuth 1.0a authentication requires both consumerKey and consumerSecret. Missing either will cause 401 errors.
fix
Ensure both credentials are provided and correct. Generate keys from WooCommerce settings > Advanced > REST API.
affects: all
deprecatedThe 'queryStringAuth' option defaults to false but some endpoints may require Basic Auth as query string. Deprecated without replacement.
fix
Set queryStringAuth: true if you need Basic Auth in query string; this option may be removed in future.
affects: >=7.0.0
breakingResponse types changed: 'data' property now wraps in WooCommerceApiResponse<T> interface. Direct typing may break.
fix
Use WooCommerceApiResponse<T> for response data types. Access response.data as before, but now typed.
affects: >=7.1.0
Errors
Common errors & fixes
Cannot find module 'woocommerce-rest-ts-api' or its corresponding type declarations.
Package not installed or TypeScript cannot resolve types.
fix
Run 'npm install woocommerce-rest-ts-api' and ensure your tsconfig has 'moduleResolution': 'node' or 'node16'.
TypeError: WooCommerceRestApi is not a constructor
Using CommonJS require without .default in ESM-first packages.
fix
Use 'const WooCommerceRestApi = require('woocommerce-rest-ts-api').default'
Property 'getAsync' does not exist on type 'WooCommerceRestApi'
Using older version (<6.0.0) that only has deprecated 'get' method.
fix
Upgrade to version 7.1.2 or use deprecated 'get' method: api.get('/products')
Request failed with status code 401
Invalid or missing API credentials, or OAuth signature mismatch.
fix
Verify consumerKey and consumerSecret from WooCommerce. Ensure URL is correct and includes protocol (https://).
Upgrade
Version history
7.1.2latest on npm
Audit
Dependencies
axiosrequiredHTTP client used to make API requests
oauth-1.0arequiredOAuth 1.0a signature generation for authentication
crypto-jsrequiredHMAC-SHA1 signing for OAuth
Agent activity
35 hits · last 30 days
node
32
OpenAI (training)
1
Resources