jsonplaceholder
jsonplaceholder copied to clipboard
RTL fake REST/GraphQL API for testing and prototyping.

jsonplaceholder
RTL fake REST/GraphQL API for testing and prototyping.
Resources
How to
Here's an example to get a list of fake users:
fetch("https://jsonplaceholder.ir/users")
.then(response => response.json())
.then(json => console.log(json)); // returns an array of users
Single resource
You can get single resource for any data group by id
property, for example, /users/1
.
Filtering
Any kind of filtering is doable using query string like /posts?userId=2
or /todos?completed=true
.
Nested resources
One level of nested route is available only for /posts
and /users
data groups, for instance /posts/4/comments
or /users/1/todos
.
Methods
CRUD
operations are available for all data groups, that means you can use POST
, GET
, PUT
, DELETE
or other http methods to create, read, update or delete resources, which will be faked as if.
// updating a resource
fetch("https://jsonplaceholder.ir/posts/6", {
method: "PUT",
body: JSON.stringify({ title: "foo", body: "bar", userId: 4 }),
})
.then(response => response.json())
.then(json => console.log(json));
GraphQL
All of the resources are available also with GraphQL, Try out GraphQL Playground for more details.