Query Filtering & Relations
Playground API provides full JSONPlaceholder parity with query parameters for pagination, multi-field sorting, full-text search, and relational sub-resources.
Pagination, Sorting & Full-Text Search
All collection endpoints support standard query parameters:
| Parameter | Default | Description |
|---|---|---|
| _page | 1 | Page number (1-indexed) |
| _limit | 10 | Number of items per page (max 30) |
| _sort | id | Field name to sort by (e.g. title, createdAt) |
| _order | asc | Sort direction (asc or desc) |
| q | - | Full-text search keyword across titles and bodies |
1
// 1. Pagination with limit and page
2
fetch('https://playground-api-xi.vercel.app/api/v1/posts?_page=1&_limit=10')
3
4
// 2. Sorting by title descending
5
fetch('https://playground-api-xi.vercel.app/api/v1/posts?_sort=title&_order=desc')
6
7
// 3. Full-text search across title and body
8
fetch('https://playground-api-xi.vercel.app/api/v1/posts?q=javascript')
Relational Sub-Resource Endpoints
Navigate nested relationships naturally using intuitive nested REST paths:
1
// 1. Fetch all posts written by user ID 1
2
fetch('https://playground-api-xi.vercel.app/api/v1/users/1/posts')
3
4
// 2. Fetch all comments under post ID 1
5
fetch('https://playground-api-xi.vercel.app/api/v1/posts/1/comments')
6
7
// 3. Fetch all todos assigned to user ID 1
8
fetch('https://playground-api-xi.vercel.app/api/v1/users/1/todos')
9
10
// 4. Alternatively, use query parameter filtering
11
fetch('https://playground-api-xi.vercel.app/api/v1/posts?user_id=1')