โšก 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.