β‘ Stop Mocking Backends: Test Stateful REST & GraphQL APIs Live in Your Browser (Playground API v4.0)
When building frontend applications, testing mobile apps, or writing automated QA suites, developers constantly face a frustrating dilemma: - Traditional mock APIs (like JSONPlaceholder) are easy to use, but they instantly discard your POST ,PUT , andDELETE requests. The moment you refresh your React/Vue app, your newly created items disappear into thin air. - Spinning up your own backend (Express/Nest/Prisma) takes time, requires database migrations, environment variables, and maintenance just to test a prototype or write UI tests. Thatβs why I built Playground API-a free, open-source mock REST & GraphQL API service with zero-login per-session state persistence. Your mutations persist across requests for your session identity while global seed datasets remain read-only for other visitors. Following our previous releases (which introduced GraphQL Gateway, Fake JWT Auth, and Dynamic Custom Collections), today Iβm thrilled to announce Playground API v4.0! β‘ v4.0 transforms Playground API into a world-class interactive developer platform and testing playground, featuring a brand-new Next.js 15 App Router portal, an in-browser live Try-It runner, 10-language code snippet generators, an active "On this page" TOC navigation, and native LLM / AI agent endpoints! π π Whatβs New in Playground API v4.0? βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β PLAYGROUND API v4.0 β β β β [ Next.js 15 Portal ] βββΊ [ Live Try-It Studio ] βββΊ [ AI Agent Ready ] β β β’ React 19 + Tailwind v4 β’ Latency Simulation β’ /llms.txt spec β β β’ Glassmorphic Design β’ Status Code Injection β’ /llms-full.txt β β β’ 3-Column Navigation β’ Response Inspector (ms) β’ TypeScript SDK β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β‘ 1. Brand New Modern Frontend Portal (Next.js 15 + React 19) The frontend has been completely rebuilt from the ground up as a standalone Next.js 15 App Router web application (playground_api_fe ) styled with Tailwind CSS v4 and React 19: - π¨ Glassmorphic Design System: Polished dark and light themes with harmonious palettes, custom slim scrollbars, and fluid micro-animations. - π Symmetric 3-Column Documentation Layout: - Left: Collapsible nested sidebar grouping Overview, Sandbox, REST Collections, GraphQL Schemas, and Client Downloads. - Center: Interactive documentation with live sample responses, parameter tables, and request builders. - Right: Sticky "On this page" Table of Contents with active ScrollSpy tracking. - β‘ Blazing Fast Static Generation (SSG): 26+ documentation pages pre-rendered for instant page loads and optimal SEO. π§ͺ 2. In-Browser Live "Try-It" Runner on Every Endpoint You no longer need to open a separate HTTP client or terminal just to see what an endpoint returns! Every documentation card now includes an integrated Try-It Runner (TryItRunner.tsx ): - ποΈ Interactive Parameters: Fill in path parameters ( :id ,:userId ) and query parameters (limit ,page ,q ,_sort ,_order ) directly in the UI. - π Payload Editor: Pre-filled JSON payload templates for POST ,PUT , andPATCH requests with syntax highlighting and formatting. - β±οΈ Middleware Simulation Controls: - X-Simulate-Delay : Test UI loading spinners (0ms, 500ms, 1500ms, 3000ms, 5000ms). - X-Simulate-Status : Test UI error toasts with simulated HTTP status codes (200 OK, 400 Bad Request, 401 Unauthorized, 404 Not Found, 500 Server Error). - - π Real-Time Response Inspector: - Exact HTTP status badge (e.g. 200 OK ,201 Created ,500 Internal Server Error ). - Execution latency in milliseconds (e.g. β‘ 24 ms ). - Response headers viewer. - Copyable formatted JSON or dynamic SVG preview. - Exact HTTP status badge (e.g. π» 3. Multi-Language Code Generators (10+ Languages) Need to quickly integrate an endpoint into your preferred language or framework? Every endpoint card provides copy-and-paste code snippets in: | Language / Tool | Client Library | Snippet Format | |---|---|---| | π cURL | Shell CLI | curl -X GET "https://playground-api-xi.vercel.app/api/v1/posts?limit=5" | | π¨ JavaScript | Native Fetch | await fetch('https://playground-api-xi.vercel.app/api/v1/posts') | | π¦ JavaScript | Axios | await axios.get('https://playground-api-xi.vercel.app/api/v1/posts') | | π· TypeScript | Strongly Typed Fetch | const res = await fetch (...) | | π Python | Requests | requests.get('https://playground-api-xi.vercel.app/api/v1/posts') | | πΉ Go | net/http | http.Get("https://playground-api-xi.vercel.app/api/v1/posts") | | π Swift | URLSession | URLSession.shared.dataTask(with: url) | | π± Kotlin | OkHttpClient | client.newCall(request).execute() | | π¦ Rust | reqwest | reqwest::get("https://playground-api-xi.vercel.app/...").await | | π PHP | cURL / file_get_contents | curl_exec($ch) | π§ 4. "On This Page" Table of Contents Navigation Navigating long documentation pages (like /docs/posts or /docs/graphql/posts ) is now effortless: - π Sticky Right-Hand Sidebar: Symmetrically matches the left navigation sidebar. - π― Automatic DOM Heading Discovery: Scans for operations, schemas, and parameter tables on route change. - π Active ScrollSpy: Dynamically highlights your current reading position with high-contrast active styling ( text-accent-primary font-bold ). - π Smooth Anchor Navigation: Clicking any link smoothly scrolls to the target anchor with proper navbar offset ( scroll-mt-20 ) and updates the URL hash cleanly. π 5. Session Sandbox Quota & Activity Dashboard (/docs/stats ) Gain complete transparency into your anonymous session sandbox: - π Live Session UUID & HMAC Signed Token: 1-click copy for pg_identity cookies orX-Playground-Identity headers. - π Mutation Summary Counters: Live counts of created, updated, and deleted records in your sandbox. - π Per-Resource Quota Progress Bars: Visual indicators tracking your quota (up to 30 sandbox records per collection). - π 10-Day Retention Indicator: Shows exact creation timestamp and last-seen activity timestamp. - ποΈ 1-Click Sandbox Reset: Wipe your session overlay instantly via DELETE /session/reset to restore a clean slate. π€ 6. AI Agent & LLM Endpoints (/llms.txt & /llms-full.txt ) With AI coding assistants (like Claude, Cursor, Antigravity, ChatGPT, and GitHub Copilot) becoming standard development tools, Playground API now provides native LLM text specifications: - π /llms.txt : Compact, structured summary of all available REST endpoints, GraphQL gateway rules, authentication endpoints, and middleware simulation headers. - π /llms-full.txt : Comprehensive, full-length API documentation specification designed for AI context injection. Your AI assistants can now read the spec directly and generate fully functional, accurate frontend components interacting with Playground API! π¦ 7. Complete Multi-Format Workspace Downloads Take Playground API anywhere in 1 click: - π OpenAPI 3.0 Specification ( /downloads/openapi.json ): Import into Swagger UI, Redoc, or Stoplight. - π Postman Collection v2.1 ( /downloads/postman.json ): Pre-configured environment variables and sample requests. - πΆ Bruno Collection ( /downloads/bruno.json ): Git-friendly, offline-first collection. - π£ Insomnia Workspace ( /downloads/insomnia.json ): Instant workspace export. - π TypeScript Type Declarations ( /downloads/playground-api.d.ts //types/ts ): Full TypeScript interfaces forUser ,Post ,Comment ,Todo ,AuthPayload , and response wrappers. π οΈ Quick Practical Demo: Testing Network Delay & Errors in Next.js / React Hereβs how you can use Playground API v4.0 to test a full CRUD component with loading skeletons and error toasts: import React, { useState, useEffect } from 'react'; interface Post { id: string | number; title: string; body: string; user_id: number; } const API_URL = 'https://playground-api-xi.vercel.app/api/v1'; export default function PostTester() { const [posts, setPosts] = useState ([]); const [loading, setLoading] = useState(false); const [error, setError] = useState (null); // 1. Fetch posts with simulated 1200ms latency to test loading UI const loadPosts = async () => { setLoading(true); setError(null); try { const res = await fetch(${API_URL}/posts?limit=3, { headers: { 'X-Simulate-Delay': '1200' }, // β±οΈ Artificial delay credentials: 'include', // πͺ Preserves sandbox session }); if (!res.ok) throw new Error(HTTP Error: ${res.status}); const json = await res.json(); setPosts(json.data); } catch (err: any) { setError(err.message); } finally { setLoading(false); } }; // 2. Create a persistent post in your personal session sandbox const createPost = async () => { const res = await fetch(${API_URL}/posts, { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ title: 'Persistent Sandboxed Article v4', body: 'This post persists across page refreshes for your session identity!', user_id: 1, }), }); const newPost = await res.json(); setPosts((prev) => [newPost, ...prev]); }; useEffect(() => { loadPosts(); }, []); return ( π Playground API v4 Testing Rig β Create Sandboxed Post π Refresh (with 1.2s Delay) {loading && β³ Loading posts from virtual overlay... } {error && β οΈ {error} } {posts.map((post) => ( {post.title} {post.body} ))} ); } π Complete Feature Matrix (v1 β v4) | Feature | v1.0 | v2.0 | v3.0 | π v4.0 Modern Ecosystem | |---|---|---|---|---| | Per-Session Virtual Sandbox | β
| β
| β
| β
| REST Collections (users , posts , comments , todos ) | β
| β
| β
| β
| Network Delay & Error Simulation (_delay , _status ) | β | β
| β
| β
| | OpenAPI / Postman / Bruno Downloads | β | β
| β
| β
| GraphQL Sandbox Gateway (/graphql ) | β | β | β
| β
| Fake JWT Auth (/auth/login , /auth/register ) | β | β | β
| β
| Dynamic Custom Collections (/custom/* ) | β | β | β
| β
| Dynamic SVG Avatars (/public/avatars/* ) | β | β | β
| β
| TypeScript Type Declarations (.d.ts ) | β | β | β
| β
| | Next.js 15 App Router Portal | β | β | β | β
| | Interactive Live Try-It Runner | β | β | β | β
| | Multi-Language Code Generators (10 Lang
Comments
No comments yet. Start the discussion.