Free Demo REST API for Testing
The freetoolza Demo API is an open practice API for people learning to work with REST. It needs no account and no key, returns the same stable sample data every time, and accepts write requests without saving them, so you can experiment freely without breaking anything. Below the reference you will find six practice exercises that take you from your first request to pagination, filtering and error handling.
It follows the widely taught “posts, comments, albums, photos, todos, users” route layout used in many beginner tutorials, so most of those examples work here by changing only the base URL. Need richer, nested records and a key for practising authentication? Use the Fake API & Mock Data Generator instead.
Try it now
Loading examples…
Base URL
https://freetoolza.com/wp-json/demo/v1
Resources
| Resource | Items | Fields |
|---|---|---|
/posts | 100 | userId, id, title, body |
/comments | 500 | postId, id, name, email, body |
/albums | 100 | userId, id, title |
/photos | 5000 | albumId, id, title, url, thumbnailUrl |
/todos | 200 | userId, id, title, completed |
/users | 10 | id, name, username, email, address, phone, website, company |
Routes
| Method | Route | Result |
|---|---|---|
| GET | /posts | List all posts |
| GET | /posts/1 | One post |
| GET | /posts/1/comments | Comments of post 1 |
| GET | /albums/1/photos | Photos of album 1 |
| GET | /users/1/posts, /users/1/albums, /users/1/todos | Items belonging to user 1 |
| POST | /posts | Fake create, returns 201 with id 101 |
| PUT, PATCH | /posts/1 | Fake update, returns the changed item |
| DELETE | /posts/1 | Fake delete, returns {} |
Write requests return a realistic response but nothing is saved, so the next GET shows the original data.
Filtering, sorting and paging
| Query | Meaning |
|---|---|
?userId=1, ?postId=1, ?completed=true | Filter by any simple field |
?_limit=10&_page=2 | Paging. Total count is in the X-Total-Count header |
?_start=20&_end=30 | Slice by position |
?_sort=title&_order=desc | Sort by a field |
Examples
JavaScript
fetch("https://freetoolza.com/wp-json/demo/v1/posts/1")
.then((res) => res.json())
.then((post) => console.log(post));
Create a post (fake)
fetch("https://freetoolza.com/wp-json/demo/v1/posts", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ userId: 4, title: "Weekend reading list", body: "Three books to finish before Monday." })
}).then((res) => res.json()).then(console.log);
cURL
curl "https://freetoolza.com/wp-json/demo/v1/users/1/todos?completed=true"
Swift
let url = URL(string: "https://freetoolza.com/wp-json/demo/v1/posts?_limit=5")!
let (data, _) = try await URLSession.shared.data(from: url)
Demo API or Fake API: which should you use?
| Demo API (this page) | Fake API | |
|---|---|---|
| API key | Not needed | Free key, created in one click |
| Data shape | Small, flat records | Simple, medium or complex nested records |
| Topics | Posts, comments, albums, photos, todos, users | Users, products, orders, transactions, movies, recipes, weather, events and more |
| Write requests | Simulated (POST, PUT, PATCH, DELETE) | Read-only |
| Best for | Learning HTTP methods and following beginner tutorials | Prototyping real app screens and testing parsers and models |
How the resources connect
The six resources are linked by ID fields, which makes them good for practising related requests: a user owns posts, albums and todos (userId); a post has comments (postId); an album has photos (albumId). Real apps load data the same way, for example a profile first and then that person’s posts.
Practice exercises
Work through these in order; each adds one new idea. Run them in your browser’s developer console (press F12, then open Console). The examples use this shortcut:
const base = "https://freetoolza.com/wp-json/demo/v1";
1. Your first GET request
fetch returns a response first; call .json() to read the body.
const user = await (await fetch(`${base}/users/1`)).json();
console.log(user.name, user.email);
2. Following a relationship
Get every post by user 3, then the comments on the first of those posts.
const posts = await (await fetch(`${base}/users/3/posts`)).json();
const comments = await (await fetch(`${base}/posts/${posts[0].id}/comments`)).json();
console.log(posts.length, "posts;", comments.length, "comments on the first");
3. Filtering on the server
Ask only for user 2’s unfinished todos instead of downloading all 200 and filtering in your own code. Server-side filtering is faster and uses less data.
const todos = await (await fetch(`${base}/todos?userId=2&completed=false`)).json();
console.log(todos.map(t => t.title));
4. Pagination with a total count
Load photos ten at a time and read the total from the X-Total-Count header to show “Page 1 of N”.
const res = await fetch(`${base}/photos?_limit=10&_page=1`);
const total = Number(res.headers.get("X-Total-Count"));
const page = await res.json();
console.log(`Showing ${page.length} of ${total}; ${Math.ceil(total / 10)} pages`);
5. Sending data with POST
Send a JSON body with the Content-Type header and check the status code: 201 means “created”.
const created = await fetch(`${base}/posts`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ userId: 1, title: "My first post", body: "Hello from the Demo API" })
});
console.log(created.status, await created.json());
6. Handling errors properly
A common beginner bug is assuming every request succeeds. fetch does not throw on a 404, so check the response’s ok property yourself. (The example names the response r so it does not clash with res from exercise 4 if you run them in the same console.)
async function getPost(id) {
const r = await fetch(`${base}/posts/${id}`);
if (!r.ok) throw new Error(`Request failed with status ${r.status}`);
return r.json();
}
getPost(9999).catch(err => console.warn(err.message));
Next challenge: build a small page that lists a user’s todos with checkboxes and sends a PATCH request with {"completed": true} when one is ticked. Remember that writes are simulated, so keep the change in your page’s own state.
Python
import requests
posts = requests.get("https://freetoolza.com/wp-json/demo/v1/posts", params={"_limit": 5}).json()
for p in posts:
print(p["id"], p["title"])
FAQ
Do I need an API key?
No. This API is open. CORS is enabled, so browsers and web views can call it directly.
Is the data real?
No. All text, names and emails are generated samples and use example domains. Photos are placeholder images.
Will my POST be saved?
No. The API only simulates writes, so every user sees the same stable data.
Can I use it in production?
No. It is meant for learning, demos and testing, with no uptime guarantee.
Learn more: read our Developer Guides, articles on JSON, REST APIs and URL encoding.