The free fake REST API, since 2013
Fake data you can rely on.
JSONPlaceholder is a free online REST API that you can use whenever you need some fake data: in documentation and tutorials, in code examples, in a quick prototype, or simply to test things locally.
- 120 billion requests / month
- Free for everyone, and it stays that way. No signup, no API key.
- Since 2013
- Same routes, same responses. Code written against it a decade ago still works.
Powered by json-server ★ 75717 lowdb ★ 22584
Sponsors
JSONPlaceholder is supported by the following companies and sponsors on GitHub.
Guide
Examples use the Fetch API, but any HTTP client works.
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(response => response.json())
.then(json => console.log(json))
Response
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
fetch('https://jsonplaceholder.typicode.com/posts')
.then(response => response.json())
.then(json => console.log(json))
Response
[
{ "userId": 1, "id": 1, "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", "body": "quia et suscipit…" },
{ "userId": 1, "id": 2, "title": "qui est esse", "body": "est rerum tempore vitae…" },
// … 100 posts
]
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
body: JSON.stringify({
title: 'foo',
body: 'bar',
userId: 1,
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then(response => response.json())
.then(json => console.log(json))
Response
{
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
}
The resource is not really created on the server, but the response is faked as if.
fetch('https://jsonplaceholder.typicode.com/posts/1', {
method: 'PUT',
body: JSON.stringify({
id: 1,
title: 'foo',
body: 'bar',
userId: 1,
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then(response => response.json())
.then(json => console.log(json))
Response
{
"id": 1,
"title": "foo",
"body": "bar",
"userId": 1
}
The resource is not really updated on the server, but the response is faked as if.
fetch('https://jsonplaceholder.typicode.com/posts/1', {
method: 'PATCH',
body: JSON.stringify({
title: 'foo',
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then(response => response.json())
.then(json => console.log(json))
Response
{
"userId": 1,
"id": 1,
"title": "foo",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
The resource is not really patched on the server, but the response is faked as if.
fetch('https://jsonplaceholder.typicode.com/posts/1', {
method: 'DELETE',
})
.then(response => response.json())
.then(json => console.log(json))
Response
{}
The resource is not really deleted on the server, but the response is faked as if.
// All the posts that belong to the first user
fetch('https://jsonplaceholder.typicode.com/posts?userId=1')
.then(response => response.json())
.then(json => console.log(json))
Response
[
{ "userId": 1, "id": 1, "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", "body": "quia et suscipit…" },
{ "userId": 1, "id": 2, "title": "qui est esse", "body": "est rerum tempore vitae…" },
// … 10 posts
]
Basic filtering is supported through query parameters.
// Equivalent to /comments?postId=1
fetch('https://jsonplaceholder.typicode.com/posts/1/comments')
.then(response => response.json())
.then(json => console.log(json))
Response
[
{ "postId": 1, "id": 1, "name": "id labore ex et quam laborum", "email": "[email protected]", "body": "laudantium enim quasi…" },
{ "postId": 1, "id": 2, "name": "quo vero reiciendis velit similique earum", "email": "[email protected]", "body": "est natus enim nihil…" },
// … 5 comments
]
One level of nested route is available: /posts/1/comments, /albums/1/photos, /users/1/albums, /users/1/todos and /users/1/posts.
Resources
JSONPlaceholder comes with a set of 6 common resources.
| /posts | 100 posts |
| /comments | 500 comments |
| /albums | 100 albums |
| /photos | 5000 photos |
| /todos | 200 todos |
| /users | 10 users |
Resources have relations. For example: posts have many comments, albums have many photos. See nested routes for the full list.
Routes
All HTTP methods are supported. You can use http or https for your requests.
| GET | /posts |
| GET | /posts/1 |
| GET | /posts/1/comments |
| GET | /comments?postId=1 |
| POST | /posts |
| PUT | /posts/1 |
| PATCH | /posts/1 |
| DELETE | /posts/1 |
Need your own data?
Mockend gives you a fake API per developer, agent or feature, from a single file in your GitHub repo.