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
- API Server: github.com/ckissi/jsonplaceholder-api - Clone this to run the API locally
- Documentation: github.com/ckissi/jsonplaceholder - This documentation site
Prerequisites
- Bun installed on your system
Clone and Run
# 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:
# 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:
curl https://api.jsonplaceholder.dev/
Using Local Development Server
Once you have the local server running, you can also test locally:
curl http://localhost:3000/
You'll get a response like this:
{
"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
fetch("https://api.jsonplaceholder.dev/posts")
.then((response) => response.json())
.then((posts) => console.log(posts));
fetch("http://localhost:3000/posts")
.then((response) => response.json())
.then((posts) => console.log(posts));
Get a Specific User
fetch("https://api.jsonplaceholder.dev/users/1")
.then((response) => response.json())
.then((user) => console.log(user));
fetch("http://localhost:3000/users/1")
.then((response) => response.json())
.then((user) => console.log(user));
Create a New Post
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));
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:
Resource | Count | Description |
---|---|---|
Users | 10 | User accounts with profile information |
Posts | 100 | Blog posts (10 per user) |
Comments | 500 | Post comments (5 per post) |
Albums | 100 | Photo albums (10 per user) |
Photos | 5000 | Photos (50 per album) |
Todos | 200 | Todo 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
- Download one or both collections using the links above
- Open Postman and click "Import"
- Upload the chosen JSON collection(s)
- You're set! Each collection already targets the correct base URL:
- Public API collection → https://api.jsonplaceholder.dev
- Local collection → http://localhost:3000
- 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