API Endpoints for Dummy JSON Data
There are three api endpoints available for fetching dummy JSON data: /api/users
, /api/users/:userId
, and /api/posts
. The data is stored in JSON files in the db
directory.
Get All Users
GET /api/users
Fetches a paginated list of users. Accepts an optional page
query parameter to specify the page of results. Renders 10 users per page.
Example: GET /api/users?page=1
Response:
[ { "userId": 1, "name": "starrynight", "followers": [2, 3, 4], "following": [2, 5, 6], "email": "alice.johnson@example.com" }, { "userId": 2, "name": "blueocean", "followers": [1, 3], "following": [1, 4], "email": "bob.smith@example.com" }, ...
Get Single User
GET /api/users/:userId
Fetches the details of a single user by their userId.
Example: GET /api/users/1
Response:
{ "userId": 1, "name": "starrynight", "followers": [2, 3, 4], "following": [2, 5, 6], "email": "alice.johnson@example.com" }
If the user is not found, a 404 Not Found
status is returned:
{ "error": "User not found" }
Get All Posts
GET /api/posts
Fetches a list of all posts. Accepts an optional page
query parameter to specify the page of results. Renders 10 posts per page. Default page is 1.
Example: GET /api/posts
Response:
[ { "postId": 1, "userId": 1, "title": "My First Post", "content": "This is the content of my first post." }, { "postId": 2, "userId": 2, "title": "Another Post", "content": "This is some other post content." }, ... ]