Skip to content

Getting Started

JSONPlaceholder is a fast, fake REST API built with Bun and Elysia.js. It's perfect for testing, prototyping, and learning how to consume REST APIs.

Installation

📁 Source Code Repositories

Prerequisites

  • Bun installed on your system

Clone and Run

bash
# Clone the repository
git clone https://github.com/ckissi/jsonplaceholder-api
cd jsonplaceholder-api

# Install dependencies
bun install

# Start the server
bun run start

# Or start in development mode with auto-reload
bun run dev

Using the Optimized Version

For maximum performance, use the optimized version:

bash
# Start optimized server
bun run start:opt

# Or with development watch mode
bun run dev:opt

# For maximum throughput (disables CORS for benchmarking)
DISABLE_CORS=1 bun run start:opt

First API Call

Using the Public API

You can start using JSONPlaceholder immediately without any setup:

bash
curl https://api.jsonplaceholder.dev/

Using Local Development Server

Once you have the local server running, you can also test locally:

bash
curl http://localhost:3000/

You'll get a response like this:

json
{
  "message": "🚀 JSONPlaceholder - Powered by Bun + Elysia.js",
  "version": "2.0.0",
  "resources": {
    "posts": "100 posts",
    "comments": "500 comments",
    "albums": "100 albums",
    "photos": "5000 photos",
    "todos": "200 todos",
    "users": "10 users"
  },
  "endpoints": {
    "users": "/users",
    "posts": "/posts",
    "comments": "/comments",
    "albums": "/albums",
    "photos": "/photos",
    "todos": "/todos"
  }
}

Quick Examples

Get All Posts

javascript
fetch("https://api.jsonplaceholder.dev/posts")
  .then((response) => response.json())
  .then((posts) => console.log(posts));
javascript
fetch("http://localhost:3000/posts")
  .then((response) => response.json())
  .then((posts) => console.log(posts));

Get a Specific User

javascript
fetch("https://api.jsonplaceholder.dev/users/1")
  .then((response) => response.json())
  .then((user) => console.log(user));
javascript
fetch("http://localhost:3000/users/1")
  .then((response) => response.json())
  .then((user) => console.log(user));

Create a New Post

javascript
fetch("https://api.jsonplaceholder.dev/posts", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    title: "My New Post",
    body: "This is the content of my new post",
    userId: 1,
  }),
})
  .then((response) => response.json())
  .then((newPost) => console.log(newPost));
javascript
fetch("http://localhost:3000/posts", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    title: "My New Post",
    body: "This is the content of my new post",
    userId: 1,
  }),
})
  .then((response) => response.json())
  .then((newPost) => console.log(newPost));

Available Resources

JSONPlaceholder provides 6 main resource types:

ResourceCountDescription
Users10User accounts with profile information
Posts100Blog posts (10 per user)
Comments500Post comments (5 per post)
Albums100Photo albums (10 per user)
Photos5000Photos (50 per album)
Todos200Todo items (20 per user)

HTTP Methods

All resources support full CRUD operations:

  • GET - Retrieve resource(s)
  • POST - Create new resource
  • PUT - Update entire resource
  • PATCH - Partially update resource
  • DELETE - Delete resource

Postman Collection

For easy API testing, import our comprehensive Postman collection:

🎆 Pro Tip

Two Ready-to-Use Collections! We provide separate collections for the public API (api.jsonplaceholder.dev) and local development (localhost:3000) - no configuration required!

📥 Download Collections

Download JSONPlaceholder_dev.postman_collection.json — uses https://api.jsonplaceholder.dev
Download JSONPlaceholder_local.postman_collection.json — uses http://localhost:3000

📋 Import Steps

  1. Download one or both collections using the links above
  2. Open Postman and click "Import"
  3. Upload the chosen JSON collection(s)
  4. You're set! Each collection already targets the correct base URL:
  5. Start testing all endpoints with pre-configured requests

✨ Collection Features

  • Complete CRUD operations for all resources
  • Query parameter examples (filtering, pagination)
  • Sample request bodies for POST/PUT requests
  • Organized by resource type (Users, Posts, Comments, etc.)
  • Two separate collections for different environments
  • Ready to use — no configuration needed

🔄 Switching Between Environments

You can import both collections and use whichever suits your workflow:

  • Use the Public API collection when you want zero setup and live data
  • Use the Local collection when developing locally or testing changes

Tip: You can keep both collections side-by-side in Postman for quick switching.

Other Testing Tools

You can also use other HTTP clients:

  • cURL - Command line tool (see our cURL examples)
  • Insomnia - Another GUI tool for API testing
  • HTTPie - User-friendly command line HTTP client
  • REST Client (VS Code extension) - Test APIs directly from your editor

What's Next?

  • Explore the API Reference for detailed endpoint documentation
  • Check out Examples for more code samples
  • Learn about specific resource endpoints for detailed examples

Fast Fake REST API powered by Bun + Elysia.js | Documentation site source: github.com/ckissi/jsonplaceholder