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=10Testing Tips
- โขUse query parameters for filters
- โขCombine multiple filters
- โขTest edge cases (empty results)
// Playwright API Testing - RESTimport { 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