Introducing the Official Zero-Dependency TypeScript SDK for Playground API

Explore the lightweight (<4kB), zero-dependency isomorphic TypeScript SDK for Playground API with full type safety, auto-completion, and automatic session persistence.

NK
Nilesh Kumar
Creator of Playground API
Introducing the Official Zero-Dependency TypeScript SDK for Playground API

Introducing the Official Zero-Dependency TypeScript SDK for Playground API

Building frontend prototypes with stateful APIs should be effortless. While fetch() is great, writing raw HTTP requests, manually typing payload schemas, and managing session headers across requests adds friction.

Today, we are releasing the Official TypeScript SDK for Playground API (@playground-api/client and playground-api).

It is zero-dependency, weighs under 4kB, is fully isomorphic (works in Node.js, Next.js App Router, React, Vue, Svelte, and React Native), and delivers 100% end-to-end type safety.


1. Installation

Terminal
1
npm install @playground-api/client
2
# or
3
pnpm add @playground-api/client
4
# or
5
yarn add @playground-api/client

2. Quickstart & Automatic Session Persistence

Initialize the client with zero configuration:

typescript
1
import { createPlaygroundClient } from '@playground-api/client';
2
3
const api = createPlaygroundClient({
4
// Optional: specify custom session ID or delay simulation
5
delay: 300,
6
});
7
8
// Full TypeScript auto-completion & type inferences
9
const posts = await api.posts.list({ limit: 10, sort: 'id', order: 'desc' });
10
console.log(posts[0].title);
11
12
// Create a stateful post in your sandbox
13
const newPost = await api.posts.create({
14
title: 'Shipping with TypeScript SDK',
15
body: 'Zero dependencies, full type safety.',
16
userId: 1,
17
});
18
console.log(newPost.id);

3. Supported SDK Resource Modules

The SDK provides ergonomic resource namespaces for all Playground API capabilities:

  • api.posts: list(), get(id), create(data), update(id, data), delete(id)
  • api.users: list(), get(id), posts(id), todos(id)
  • api.todos: list(), toggle(id), create(data)
  • api.auth: login({ email, password }), register(), me(), refresh()
  • api.uploads: upload(file, options), bulk(files)
  • api.analytics: track(event, props), batch(events)
  • api.webhooks: register(), list(), test()
  • api.session: reset(), export(), import()

4. Built-in Simulation Utilities

Need to test slow connections or chaotic error rates in your test suite?

typescript
1
// Enable simulation globally or per-request
2
const client = createPlaygroundClient({
3
simulate: {
4
delay: 1200, // Add 1.2s latency to all requests
5
errorRate: 0.2, // 20% random error injection
6
},
7
});

5. Live SDK Documentation & Sandbox

Explore the full API reference, download .d.ts type declarations, and run code samples in the interactive Studio:

👉 https://playground.nileslabs.com/docs/sdk


Conclusion

Accelerate your frontend prototyping with full type safety and zero bundle bloat. Install @playground-api/client today!

Tags:#typescript#javascript#webdev#react

Try Playground API in Your Own App

Stateful mock REST & GraphQL API with private sandbox overlays.