Skip to main content
REST API

GET Products with Filters

RequestFilterValidateMedium

What you will learn

  • Pagination boundaries matter: page=1 / last-page / past-last-page โ€” each exercises distinct code paths
  • Filter + sort composition must follow documented order of operations โ€” reversing it breaks clients silently
  • Include meta envelope (total, pageSize, totalPages) โ€” clients paginate against it, not probing for empty responses

Description

List products with query string filters: category, price range, search.

Test Scenario

const response = await request.get('/api/v1/products?category=electronics');
const body = await response.json();
body.data.forEach(p => expect(p.category).toBe('electronics'));
Endpoint/api/v1/products?category=electronics&minPrice=10

Testing Tips

  • โ€ขUse query parameters for filters
  • โ€ขCombine multiple filters
  • โ€ขTest edge cases (empty results)
// Playwright API Testing - REST
import { test, expect } from '@playwright/test';
test('REST API request', async ({ request }) => {
const response = await request.get('/api/v1/resource');
expect(response.ok()).toBeTruthy();
expect(response.status()).toBe(200);
const data = await response.json();
expect(data).toBeDefined();
});

Challenge ID: rest-get-products

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/products?category=electronics&minPrice=10

Press Enter to send