Playground API
DocsStatsBlogStudio
Documentation Tree
Technical BlogFeature Deep Dives
  • Introduction
  • Quickstart
    5 min
  • How It Works
  • Recipes & Cookbooks
  • Platform Comparisons
  • Real-World Showcase
  • Interactive Studio
    Studio
  • GraphiQL IDE
    IDE
  • Session Quotas & Activity
  • Network Chaos Simulator
  • Atomic Sandbox Reset
  • Overview & Models
    Hub
  • Users Resource
  • Posts Resource
  • Comments Resource
  • Todos Resource
  • Custom Collections
    Custom
  • Multipart File Uploads
    Upload
  • Dynamic SVG Avatars
    SVG
  • Image Thumbnails
    CDN
  • Relational Filtering
  • Full-Text Search
  • Dynamic Sorting
  • Offset Pagination
  • Cursor Pagination
    Scroll
  • CSV & Excel Export & Import
    IO
  • Custom Collections
    CRUD
  • Overview & Architecture
    Hub
  • JWT Auth Flow
  • Refresh Token Rotation
    Mutex
  • RBAC Permission Matrix
    Roles
  • Expiry Simulation
  • Clock Skew Drift
  • Password Recovery Loop
  • Dual-Mode Sandboxing
  • GraphiQL IDE
    IDE
  • Relational Queries
  • Stateful Mutations
  • Realtime Subscriptions
  • Overview & Flowcharts
    Hub
  • Hosted Checkout
    Stripe
  • Payment Intents API
  • 3DS Challenge Modal
    Modal
  • Customers Vault
  • Charges & Refunds
  • Test Cards Catalog
  • Overview & Channels
    Hub
  • Virtual Email Mailbox
    Mailtrap
  • Virtual SMS Terminal
    Phone
  • In-App Notifications
  • Message Dispatcher
  • Realtime Studio
    Studio
  • Native WebSocket (/ws)
  • Socket.io Gateway
  • Presence & Echo Bot
  • Server-Sent Events (SSE)
    SSE
  • Analytics Telemetry
  • Webhook Subscriptions
  • HMAC SHA-256 Signatures
  • Delivery Logs
  • Manual Retry Simulator
  • Network Latency Delay
  • HTTP Status Codes
  • Rate-Limit Simulator
    429
  • Flaky Network & Jitter
    Chaos
  • Session Quotas & Activity
  • JSON Snapshots
    JSON
  • Headless CI/CD Testing
    CI
  • Mobile QR Code Sync
  • System Metrics & Health
  • Atomic Sandbox Reset
  • Official TypeScript SDK
  • Multi-Language Generators
  • DevTools Extension
  • OpenAPI 3.1 Spec
    JSON
  • Postman Collection v2.1
  • Bruno Collection
  • Insomnia Workspace
  • TypeScript .d.ts
    .d.ts
  • AI Prompt Rules
    Rules
  • Context Index (llms.txt)
  • Full Schema (llms-full.txt)
  • Manifest (product.json)
  • All Feature Articles
    Blog
  • React CRUD Without Backend
    Deep Dive
  • Why Static APIs Fail
  • Mocking Stateful Auth
  • WebSockets & SSE Guide
Technical Blog
Articles

In-depth articles explaining stateful mock APIs, WebSockets, payments, and frontend resilience.

Read Articles
PreviousDynamic Sorting
NextCursor Pagination
Data & Query Engine

Offset-Based Pagination

Standard numbered page navigation using _page and _limit. Playground computes complete pagination metadata payload alongside standard RFC 5988 Link headers.

Interactive Page Navigator

Test numbered page offsets and limit sizes against live data:

Page 1
Requesting page 1 with limit of 5 records.GET /posts?_page=1&_limit=5
Method: GET

Live Request Console

GET
response.json
1
{
2
// Click "Send" above to execute this request against the live server.
3
}

Pagination Metadata & Response Headers

Playground returns calculated navigation metadata in both the JSON payload and standard HTTP response headers:

JSON Payload Object

{
  "data": [ /* page items */ ],
  "pagination": {
    "page": 2,
    "limit": 5,
    "total": 100,
    "totalPages": 20,
    "hasNextPage": true,
    "hasPrevPage": true
  }
}

HTTP Response Headers

X-Total-Count: 100
X-Page: 2
X-Limit: 5
X-Total-Pages: 20
Link: <..._page=1>; rel="first",
      <..._page=1>; rel="prev",
      <..._page=3>; rel="next",
      <..._page=20>; rel="last"

Client Integration Recipes

Production patterns for smooth pagination without screen flickers:

queries/usePaginatedPosts.ts
1
// queries/usePaginatedPosts.ts
2
import { useQuery, keepPreviousData } from '@tanstack/react-query';
3
4
interface PaginationMeta {
5
page: number;
6
limit: number;
7
total: number;
8
totalPages: number;
9
hasNextPage: boolean;
10
hasPrevPage: boolean;
11
}
12
13
interface PostsResponse {
14
data: any[];
15
pagination: PaginationMeta;
16
}
17
18
export function usePaginatedPosts(page = 1, limit = 10) {
19
return useQuery<PostsResponse>({
20
queryKey: ['posts', 'paginated', page, limit],
21
queryFn: async () => {
22
const res = await fetch(
23
https://playground.nileslabs.com/api/v1/posts?_page=${page}&_limit=${limit}`,
24
{ credentials: 'include' }
25
);
26
if (!res.ok) throw new Error('Failed to load page');
27
return res.json();
28
},
29
// keepPreviousData prevents layout flickering during page navigation
30
placeholderData: keepPreviousData
31
});
32
}
Next Query Feature

Cursor-Based Pagination (Infinite Scroll)

Related Query Feature

CSV & Excel Export & Import