
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
jsonplaceholder-api-client
Advanced tools
A lightweight, TypeScript-first SDK that wraps the JSONPlaceholder fake REST API, offering clean, predictable CRUD helpers for learning, prototyping, and testing.
This package is a TypeScript-first wrapper around the JSONPlaceholder fake REST API. It provides clean, predictable helper functions for working with common resources such as posts, comments, albums, photos, todos, and users, covering the full CRUD surface (GET, POST, PUT, PATCH, DELETE).
🌱 The goal of this library is not to replace JSONPlaceholder itself, but to offer a Developer-Friendly SDK with consistent response shapes, sensible defaults, and strong TypeScript typing — making it useful for learning, prototyping, demos, and testing frontend or SDK patterns.
npm install --save jsonplaceholder-api-client
/* node modules */
import { getAllPosts } from 'jsonplaceholder-api-client';
/* fn */
async function quickStart() {
const response = await getAllPosts();
console.log(response);
}
/* call */
await quickStart();
/* Sample Response Schema
{
code: "api-ok",
message: "No error encountered",
payload: ...
}
*/
GET, POST, PUT, PATCH and DELETE.JSONPlaceholder is a free, public fake REST API that provides realistic but non-persistent data for common resources such as posts, comments, users, albums, photos, and todos. This is widely used by developers to practice working with REST APIs.
JSONPlaceholder is an excellent fake REST API, but using it directly often means repeating the same boilerplate: manual fetch calls, ad-hoc response handling, loose typing, and inconsistent patterns across resources.
This package exists to solve that by providing:
📁 Resource Name: Albums
import { getAllAlbums } from 'jsonplaceholder-api-client';
const response = await getAllAlbums();
/* Returns an array of album objects */
import { getAlbumById } from 'jsonplaceholder-api-client';
const response = await getAlbumById({ id: number });
/* If the album does not exist, album is returned as null */
import { createNewAlbum } from 'jsonplaceholder-api-client';
const response = await createNewAlbum({
title: string,
userId: number,
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateAlbum } from 'jsonplaceholder-api-client';
const response = await updateAlbum({
id: number,
data: { id: number, title: string, userId: number },
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateAlbumPartial } from "jsonplaceholder-api-client";
const response = await updateAlbumPartial({
id: number,
data: { title?: string, userId?: number }
});
/* Need to give atleast 1 of the data fields. */
/* Changes are not persisted (JSONPlaceholder behavior). */
import { deleteAlbum } from 'jsonplaceholder-api-client';
const response = await deleteAlbum({ id: number });
/* Mock delete endpoint. Changes are not persisted (JSONPlaceholder behavior). */
📁 Resource Name: Comments
import { getAllComments } from 'jsonplaceholder-api-client';
const response = await getAllComments();
/* Returns an array of comment objects */
import { getCommentById } from 'jsonplaceholder-api-client';
const response = await getCommentById({ id: number });
/* If the comment does not exist, comment is returned as null */
import { createNewComment } from 'jsonplaceholder-api-client';
const response = await createNewComment({
postId: number,
name: string,
email: string,
body: string,
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateComment } from 'jsonplaceholder-api-client';
const response = await updateComment({
id: number,
data: {
id: number,
postId: number,
name: string,
email: string,
body: string,
},
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateCommentPartial } from "jsonplaceholder-api-client";
const response = await updateCommentPartial({
id: number,
data: {postId?: number, name?: string, email?: string, body?: string}
});
/* Need to give atleast 1 of the data fields. */
/* Changes are not persisted (JSONPlaceholder behavior). */
import { deleteComment } from 'jsonplaceholder-api-client';
const response = await deleteComment({ id: number });
/* Mock delete endpoint. Changes are not persisted (JSONPlaceholder behavior). */
📁 Resource Name: Photos
import { getAllPhotos } from 'jsonplaceholder-api-client';
const response = await getAllPhotos();
/* Returns an array of photo objects */
import { getPhotoById } from 'jsonplaceholder-api-client';
const response = await getPhotoById({ id: number });
/* If the photo does not exist, photo is returned as null */
import { createNewPhoto } from 'jsonplaceholder-api-client';
const response = await createNewPhoto({
albumId: number,
title: string,
url: string,
thumbnailUrl: string,
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updatePhoto } from 'jsonplaceholder-api-client';
const response = await updatePhoto({
id: number,
data: {
id: number,
albumId: number,
title: string,
url: string,
thumbnailUrl: string,
},
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updatePhotoPartial } from "jsonplaceholder-api-client";
const response = await updatePhotoPartial({
id: number,
data: { albumId?: number, title?: string, url?: string, thumbnailUrl?: string }
});
/* Need to give atleast 1 of the data fields. */
/* Changes are not persisted (JSONPlaceholder behavior). */
import { deletePhoto } from 'jsonplaceholder-api-client';
const response = await deletePhoto({ id: number });
/* Mock delete endpoint. Changes are not persisted (JSONPlaceholder behavior). */
📁 Resource Name: Posts
import { getAllPosts } from 'jsonplaceholder-api-client';
const response = await getAllPosts();
/* Returns an array of post objects */
import { getPostById } from 'jsonplaceholder-api-client';
const response = await getPostById({ id: number });
/* If the post does not exist, post is returned as null */
import { createNewPost } from 'jsonplaceholder-api-client';
const response = await createNewPost({
userId: number,
title: string,
body: string,
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updatePost } from 'jsonplaceholder-api-client';
const response = await updatePost({
id: number,
data: { id: number, userId: number, title: string, body: string },
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updatePostPartial } from "jsonplaceholder-api-client";
const response = await updatePostPartial({
id: number,
data: { userId?: number, title?: string, body?: string }
});
/* Need to give atleast 1 of the data fields. */
/* Changes are not persisted (JSONPlaceholder behavior). */
import { deletePost } from 'jsonplaceholder-api-client';
const response = await deletePost({ id: number });
/* Mock delete endpoint. Changes are not persisted (JSONPlaceholder behavior). */
📁 Resource Name: Todos
import { getAllTodos } from 'jsonplaceholder-api-client';
const response = await getAllTodos();
/* Returns an array of todo objects */
import { getTodoById } from 'jsonplaceholder-api-client';
const response = await getTodoById({ id: number });
/* If the todo does not exist, todo is returned as null */
import { createNewTodo } from 'jsonplaceholder-api-client';
const response = await createNewTodo({
userId: number,
title: string,
completed: boolean,
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateTodo } from 'jsonplaceholder-api-client';
const response = await updateTodo({
id: number,
data: { id: number, userId: number, title: string, completed: boolean },
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateTodoPartial } from "jsonplaceholder-api-client";
const response = await updateTodoPartial({
id: number,
data: { userId?: number, title?: string, completed?: boolean }
});
/* Need to give atleast 1 of the data fields. */
/* Changes are not persisted (JSONPlaceholder behavior). */
import { deleteTodo } from 'jsonplaceholder-api-client';
const response = await deleteTodo({ id: number });
/* Mock delete endpoint. Changes are not persisted (JSONPlaceholder behavior). */
📁 Resource Name: Users
import { getAllUsers } from 'jsonplaceholder-api-client';
const response = await getAllUsers();
/* Returns an array of user objects */
import { getUserById } from 'jsonplaceholder-api-client';
const response = await getUserById({ id: number });
/* If the user does not exist, user is returned as null */
import { createNewUser } from 'jsonplaceholder-api-client';
const response = await createNewUser({
name: string,
username: string,
email: string,
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateUser } from "jsonplaceholder-api-client";
const response = await updateUser({
id: number,
data: {
id: number
name: string
username: string
email: string
address: {
street: string
suite: string
city: string
zipcode: string
geo: {
lat: string
lng: string
}
}
phone: string
website: string
company: {
name: string
catchPhrase: string
bs: string
}
}
});
/* All required fields. Changes not persisted (JSONPlaceholder behavior) */
import { updateUserPartial } from "jsonplaceholder-api-client";
const response = await updateUserPartial({
id: number,
data: {
name?: string
username?: string
email?: string
address?: {
street?: string
suite?: string
city?: string
zipcode?: string
geo?: {
lat?: string
lng?: string
}
}
phone?: string
website?: string
company?: {
name?: string
catchPhrase?: string
bs?: string
}
}
});
/* Need to give atleast 1 of the data fields. */
/* Changes are not persisted (JSONPlaceholder behavior). */
import { deleteUser } from 'jsonplaceholder-api-client';
const response = await deleteUser({ id: number });
/* Mock delete endpoint. Changes are not persisted (JSONPlaceholder behavior). */
PASS src/todos/test/update-todo.test.ts
PASS src/users/test/update-user.test.ts
PASS src/users/test/get-all-users.test.ts
PASS src/users/test/get-user-by-id.test.ts
PASS src/users/test/update-user-partial.test.ts
PASS src/users/test/create-new-user.test.ts
PASS src/users/test/delete-user.test.ts
PASS src/albums/test/update-album-partial.test.ts
PASS src/photos/test/delete-photo.test.ts
PASS src/comments/test/create-new-comment.test.ts
PASS src/posts/test/update-post.test.ts
PASS src/albums/test/get-album-by-id.test.ts
PASS src/comments/test/update-comment-partial.test.ts
PASS src/posts/test/get-post-by-id.test.ts
PASS src/photos/test/update-photo.test.ts
PASS src/comments/test/get-comment-by-id.test.ts
PASS src/posts/test/update-post-partial.test.ts
PASS src/photos/test/update-photo-partial.test.ts
PASS src/photos/test/get-photo-by-id.test.ts
PASS src/comments/test/delete-comment.test.ts
PASS src/photos/test/get-all-photos.test.ts
PASS src/photos/test/create-new-photo.test.ts
PASS src/shared/test/index.test.ts
PASS src/albums/test/delete-album.test.ts
PASS src/comments/test/update-comment.test.ts
PASS src/albums/test/update-album.test.ts
PASS src/posts/test/get-all-posts.test.ts
PASS src/posts/test/create-new-post.test.ts
PASS src/posts/test/delete-post.test.ts
PASS src/comments/test/get-all-comments.test.ts
PASS src/albums/test/get-all-albums.test.ts
PASS src/albums/test/create-new-album.test.ts
PASS src/todos/test/create-new-todo.test.ts
PASS src/todos/test/update-todo-partial.test.ts
PASS src/todos/test/get-all-todos.test.ts
PASS src/todos/test/delete-todo.test.ts
PASS src/todos/test/get-todo-by-id.test.ts
If you would like to see a detailed report of the unit tests created and their respective file coverage, visit this test-coverage link.
Contributions, suggestions, and improvements are welcome.
Feel free to open issues or pull requests.
Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.
FAQs
A lightweight, TypeScript-first SDK that wraps the JSONPlaceholder fake REST API, offering clean, predictable CRUD helpers for learning, prototyping, and testing.
The npm package jsonplaceholder-api-client receives a total of 2 weekly downloads. As such, jsonplaceholder-api-client popularity was classified as not popular.
We found that jsonplaceholder-api-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.