JSONPlaceholder API Documentation
Overview
JSONPlaceholder is a free, online API that provides fake data for testing and prototyping.
It is widely used by developers who need a quick backend to test their applications without setting up a real server.
This documentation covers the available endpoins, how to make requests, and what responses to expect.
Base URL
All API requests are made to the following base URL:
https://jsonplaceholder.typicode.com
Every endpoint in this documentation is appended to this base URL.
Authentication
JSONPlaceholder does not require authentication.
You can make requests directly without using API key or token. This makes it ideal for testing and learning purposes.
Endpoints
Get All Posts
When you are building something like a blog feed, news stream, or social media timeline, you need a list of content to display on the screen.
This endpoint is used to retrieve every available post on the API.
Endpoints:
GET/points
Full URL:
https://jsonplaceholder.typicode.com/posts
What GET means: GET is a request method that asks the server to send you data. You are not changing anything — just retrieving information.
Example response:
[{
"userId": 1,
"id': 1,
"title": "Sample post title
"body": "Sample post body content"
}]
What the response means:
userId — the ID of the user who created the post
id — the unique ID of the post
title — the title of the post
body — the main content of the post
Get a Single Post
This endpoint is used when you want to retrieve a specific post. Replace {id} with the number of the post you want — for instance, 1 for the first post.
Endpoint:
GET /posts/{id}
Full URL:
https://jsonplaceholder.typicode.com/posts/1
Example Response:
{
"userId": 1,
"id': 1,
"title": "Sample post title
"body": "Sample post body content"
}
Create a Post
This endpoint is used to create a new post. Unlike GET, POST sends data to the server.
Endpoint:
POST /posts
Full URL:
https://jsonplaceholder.typicode.com/posts
What POST means: POST is a request method that sends new data to the server to be created.
Request body: Example response:**
{
"title": "My new post",
"body": "This is the content",
"userId": 1
}
Update a Post
This endpoint is used to update an existing post.
Endpoint:
PUT /posts/{id}
Full URL:
https://jsonplaceholder.typicode.com/posts/1
What PUT means: PUT replaces an existing resource with new data you provide.
Request body:
{
"id": 1,
"title": "Updated title",
"body": "Updated content",
"userId": 1
}
Delete a Post
This is used to delete a post by its ID.
Endpoint:
DELETE /posts/{id}
Full URL:
https://jsonplaceholder.typicode.com/posts/1
What DELETE means: DELETE removes the specified resource from the server.
Example Response:
{}
An empty object confirms the post was successfully deleted.
Response Codes
Response codes tell you whether your request was successful or not.
| Code | Meaning |
|------|---------|
| 200 | OK — request was successful |
| 201 | Created — new resource was created |
| 404 | Not Found — the resource does not exist |
| 500 | Server Error — something went wrong on the server |
Example Use Case
Imagine you are creating a blog application. This is how you will use JSONPlaceholder API:
Use GET/posts to fetch all posts and display them on your homepage.
Use GET /posts/{id} to show a single post when a user clicks on it.
Use PUT /posts to let users create new posts.
Use PUT /posts/{id} to let users edit their existing posts.
Use DELETE /posts/{id} to let users delete posts they no longer need.
