⚑ Stop Mocking Backends: Test Stateful REST & GraphQL APIs Live in Your Browser (Playground API v4.0)
DEV Community

⚑ 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

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.