WooCommerce REST API v3: Retrieve Products with Authentication and Pagination
Use consumer key/secret authentication to retrieve WooCommerce products via REST API v3. Paginate with per_page (max 100) and page parameters. Watch for rate limits and version compatibility.
30 Jun 2026, 01:57 UTC

Quick Answer: Get Products via WooCommerce REST API
Use your consumer key and secret to authenticate requests to /wp-json/wc/v3/products. Pass credentials via Basic Auth header or query parameters, and paginate results using per_page (max 100) and page parameters.
Authentication Setup
Generate consumer keys in WooCommerce admin under Settings → Advanced → REST API. Create a new key with appropriate permissions (read for product retrieval). Store the consumer key and secret securely—they grant full API access.
Working Configuration Example
Retrieve first 50 products using cURL:
curl -u ck_your_consumer_key:cs_your_consumer_secret \
https://yourstore.com/wp-json/wc/v3/products?per_page=50&page=1
For programmatic access in PHP:
<?php
$consumerKey = 'ck_your_key';
$consumerSecret = 'cs_your_secret';
$storeUrl = 'https://yourstore.com';
$args = [
'per_page' => 50,
'page' => 1
];
$query = http_build_query($args);
$url = "{$storeUrl}/wp-json/wc/v3/products?{$query}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "{$consumerKey}:{$consumerSecret}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
curl_close($ch);
$products = json_decode($response, true);
?>
Pagination Strategy
The API returns pagination metadata in response headers:
X-WP-Total: Total number of productsX-WP-TotalPages: Total pages available
For bulk operations, iterate through pages:
<?php
$totalPages = 0;
$page = 1;
$allProducts = [];
// First request to get total pages
$response = getProducts(1); // Your function
$headers = getResponseHeaders();
$totalPages = $headers['X-WP-TotalPages'];
// Fetch remaining pages
for ($i = 1; $i <= $totalPages; $i++) {
$products = getProducts($i);
$allProducts = array_merge($allProducts, $products);
}
?>
Rate Limiting
WooCommerce enforces a default rate limit of 15 requests per 15 seconds. Exceeding this returns HTTP 429. Implement exponential backoff:
<?php
function makeRequestWithBackoff($url, $maxRetries = 3) {
$retries = 0;
while ($retries < $maxRetries) {
$response = wp_remote_get($url);
$status = wp_remote_retrieve_response_code($response);
if ($status === 429) {
$wait = pow(2, $retries) * 1000000; // microseconds
usleep($wait);
$retries++;
} else {
return $response;
}
}
return false;
}
?>
Common Mistakes and Limits
- Per-page limit: Setting
per_page>100silently truncates to 100. Always checkX-WP-Totalheader to verify completeness. - SSL requirement: Modern WooCommerce rejects HTTP endpoints. Ensure valid SSL certificate.
- Version mismatch: WooCommerce 3.0+ uses v3; older versions require v2/v1 endpoints with different response formats.
- Credential exposure: Never commit consumer keys to version control. Use environment variables or secure vaults.
Verification Steps
- Test authentication: A valid request returns HTTP 200 with JSON product array
- Check pagination headers: Verify
X-WP-TotalandX-WP-TotalPagesare present - Validate rate limiting: Send 20 rapid requests; expect 429 after 15th
- Inspect product schema: Confirm response contains expected fields like
id,name,price,stock_status
Product Data Structure
Each product object includes:
id: Unique product identifiername: Product titleprice: Product price as stringstock_status: "instock" or "outofstock"meta_data: Array of custom fields
Limitations
- Maximum 100 items per request
- Rate limits may vary by server configuration
- Custom fields in
meta_datarequire additional processing - API v3 requires WooCommerce 3.0+
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.