REST API
Search Endpoint
RequestFilterValidateMedium
What you will learn
- Assert on pagination shape AND result relevance โ an empty array with correct metadata is still a failing search
- Test injection attempts in search queries (SQL, LDAP, command chars) โ rejection must happen server-side, not just client-side
- Measure query-to-result latency โ search endpoints are the #1 source of p99 regressions in e-commerce
Description
Full-text search across resources. Test query matching and highlighting.
Test Scenario
const response = await request.get('/api/v1/search?q=laptop');
// Search has its own shape: { query, totalResults, results: [...] }
const body = await response.json();
expect(body.results.length).toBeGreaterThan(0);Endpoint
/api/v1/search?q=keywordTesting Tips
- โขUse q parameter for search term
- โขCheck relevance ordering
- โขTest with special characters
// 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-search-endpoint
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/search?q=keyword
Press Enter to send