API Documentation
Get started with Rest Faker in minutes. Create your data model, generate your API, and start making requests.
Create your own data structures with custom fields and types
Get a working REST API endpoint immediately after creation
Define belongsTo, hasMany, and hasOne relations between your data models
Sort by any field in ascending or descending order
Set up a new project (e.g., "Blog") with a descriptive name
Use our Route Creator to define fields like "title", "description", "slug", etc.
Select data types (lorem, words, paragraphs) and customize fake data generation
Instantly receive a working REST API endpoint with your custom data
// Basic GET request
fetch('https://api.restfaker.dev/api/schema/posts', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));All API requests require authentication using your API token in the headers.
Include your API token in the headers using apiToken keyword:
apiToken: your_api_token_hereYour API token is generated when you create a project. You can find it in your project dashboard after completing the Route Creator setup.
When you enable the Mock Auth toggle in your project settings, Rest Faker automatically provides a complete authentication system with signup, signin, and profile management endpoints.
Sign up new users with email validation
JWT-based authentication system
View user profiles
POST /api/schema/signupRegister a new user account. Automatically generates a JWT token upon successful registration.
// Sign up a new user
fetch('https://api.restfaker.dev/api/schema/signup', {
method: 'POST',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'securePassword123',
firstName: 'John',
lastName: 'Doe'
})
})
.then(response => response.json())
.then(data => console.log(data));{
"success": true,
"message": "User created successfully",
"data": {
"id": "uuid-string",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"projectId": "uuid-string",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z",
}
}POST /api/schema/signinAuthenticate an existing user and receive a JWT token for accessing protected routes.
// Sign in an existing user
fetch('https://api.restfaker.dev/api/schema/signin', {
method: 'POST',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'securePassword123'
})
})
.then(response => response.json())
.then(data => {
// Store the auth token for future requests
const authToken = data.token;
console.log(data);
});{
"success": true,
"message": "Login successful",
"token": "jwt-token-string"
}GET /api/schema/profileView user profile information. Requires authentication token in the Authorization header.
// Get user profile (requires auth token)
fetch('https://api.restfaker.dev/api/schema/profile', {
headers: {
'apiToken': 'your_api_token_here',
'Authorization': 'Bearer jwt-token-here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));{
"success": true,
"data": {
"id": "uuid-string",
"email": "user@example.com",
"projectId": "uuid-string",
"firstName": "John",
"lastName": "Doe",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z",
}
}Toggle the "Mock Auth" switch in your project settings to activate the authentication system.
Use the signup endpoint to create test users with fake email addresses.
Store JWT tokens and include them in headers for protected API calls.
Your custom endpoints are generated based on your route configuration. Rest Faker provides full CRUD operations for every route you create.
https://api.restfaker.devWhere {route} is the name you defined in the Route Creator (e.g., "posts", "users", "products").
GET /api/schema/{route}List all records (paginated)GET /api/schema/{route}/:idGet a single recordPOST /api/schema/{route}Create a new recordPATCH /api/schema/{route}/:idUpdate an existing recordDELETE /api/schema/{route}/:idDelete a recordEvery record automatically includes the following system fields, regardless of your schema definition:
idUUID v4 - unique identifier for each recordcreatedAtISO 8601 datetime - set when the record is createdupdatedAtISO 8601 datetime - updated on every modificationuserIdUUID - added only when Mock Auth is enabled and route is protected// Get a single post by ID
fetch('https://api.restfaker.dev/api/schema/posts/d9c03940-8451-4c3e-944f-6ddfd23390f6', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));
// Response:
// {
// "id": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
// "title": "Lorem ipsum dolor sit amet",
// "description": "Consectetur adipiscing elit...",
// "createdAt": "2025-01-15T10:30:00Z",
// "updatedAt": "2025-01-15T10:30:00Z"
// }// Create a new post
// NOTE: the request body must be wrapped in a "data" key
fetch('https://api.restfaker.dev/api/schema/posts', {
method: 'POST',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: {
title: 'My New Post',
description: 'This is the post content.',
slug: 'my-new-post'
}
})
})
.then(response => response.json())
.then(data => console.log(data));
// Response:
// {
// "id": "a1b2c3d4-...",
// "title": "My New Post",
// "description": "This is the post content.",
// "slug": "my-new-post",
// "createdAt": "2025-01-15T12:00:00Z",
// "updatedAt": "2025-01-15T12:00:00Z"
// }// Update an existing post
fetch('https://api.restfaker.dev/api/schema/posts/d9c03940-8451-4c3e-944f-6ddfd23390f6', {
method: 'PATCH',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'Updated Post Title'
})
})
.then(response => response.json())
.then(data => console.log(data));
// Response:
// {
// "id": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
// "title": "Updated Post Title",
// "description": "Original description...",
// "slug": "lorem-ipsum-dolor-sit-amet",
// "createdAt": "2025-01-15T10:30:00Z",
// "updatedAt": "2025-01-15T14:00:00Z"
// }// Delete a post
fetch('https://api.restfaker.dev/api/schema/posts/d9c03940-8451-4c3e-944f-6ddfd23390f6', {
method: 'DELETE',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));
// Response:
// {
// "success": true,
// "message": "Record deleted successfully"
// }The list endpoint (GET /api/schema/{route}) supports the following query parameters:
page - Page number (default: 1)perPage - Items per page (default: 10, max: 100)sort - Field name to sort byorder - Sort direction (asc, desc)format - Response format. Pass xml to receive XML instead of JSON. Requires a paid plan.// Request XML instead of JSON
fetch('https://api.restfaker.dev/api/schema/posts?format=xml', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.text())
.then(xml => console.log(xml));
// XML Response:
// <?xml version="1.0" encoding="UTF-8"?>
// <response>
// <data>
// <item>
// <id>d9c03940-8451-4c3e-944f-6ddfd23390f6</id>
// <title>Lorem ipsum dolor sit amet</title>
// <createdAt>2025-01-15T10:30:00Z</createdAt>
// </item>
// </data>
// <meta>
// <total>50</total>
// <page>1</page>
// <perPage>10</perPage>
// <pages>5</pages>
// </meta>
// </response>postsRest Faker supports defining relationships between your data models. Relations determine how records from different routes are linked and how nested data is returned in API responses.
A record belongs to another record. Adds a foreign key field (e.g., postId) to the child model.
A record has many related records. Returns a nested array of related items in the response.
A record has exactly one related record. Returns a nested object in the response.
Use belongsTo when a record references a parent record. For example, a Comment belongs to a Post. This adds a foreign key field to the child record.
// A "comments" route configured with belongsTo "posts"
// Each comment record will include a postId field
// GET /api/schema/comments
{
"data": [
{
"id": "c1a2b3c4-...",
"body": "Great article!",
"postId": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
"createdAt": "2025-01-15T11:00:00Z",
"updatedAt": "2025-01-15T11:00:00Z"
}
],
"meta": { "total": 25, "page": 1, "perPage": 10, "pages": 3 }
}Use hasMany when a record owns multiple related records. For example, a Post has many Comments. The related records are returned as a nested array.
// A "posts" route configured with hasMany "comments"
// Each post record will include a nested comments array
// GET /api/schema/posts/d9c03940-8451-4c3e-944f-6ddfd23390f6
{
"id": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
"title": "Lorem ipsum dolor sit amet",
"description": "Consectetur adipiscing elit...",
"comments": [
{
"id": "c1a2b3c4-...",
"body": "Great article!",
"postId": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
"createdAt": "2025-01-15T11:00:00Z",
"updatedAt": "2025-01-15T11:00:00Z"
},
{
"id": "e5f6a7b8-...",
"body": "Thanks for sharing.",
"postId": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
"createdAt": "2025-01-15T12:00:00Z",
"updatedAt": "2025-01-15T12:00:00Z"
}
],
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z"
}Use hasOne when a record has exactly one related record. For example, a User has one Profile. The related record is returned as a nested object.
// A "users" route configured with hasOne "profile"
// Each user record will include a nested profile object
// GET /api/schema/users/a1b2c3d4-...
{
"id": "a1b2c3d4-...",
"firstName": "John",
"lastName": "Doe",
"profile": {
"id": "p1q2r3s4-...",
"bio": "Software developer and writer",
"avatar": "https://example.com/avatar.jpg",
"userId": "a1b2c3d4-...",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z"
},
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z"
}Relations are configured in the Route Creator when defining your data model. Select the relation type and the target route to establish the link. The foreign key fields and nested data are handled automatically by Rest Faker.
The Scenario Engine lets you simulate real-world API conditions on a per-route basis. Configure latency, error injection, and rate limiting to test how your frontend handles adverse conditions.
Add configurable delay to responses with min/max milliseconds to simulate slow networks.
Return errors at a configurable rate (0-100%) with custom status codes and messages.
Limit the number of requests allowed per time window to simulate API throttling.
When latency is configured for a route, each request is delayed by a random duration between the min and max values. This is useful for testing loading states and timeouts.
minMinimum delay in millisecondsmaxMaximum delay in milliseconds// With latency configured (min: 500ms, max: 2000ms),
// each request is delayed by a random amount in that range.
// Request behaves normally but takes 500-2000ms to respond:
fetch('https://api.restfaker.dev/api/schema/posts', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data)); // Response arrives after delayWhen error injection is configured, a percentage of requests will return the specified error status code and message instead of the normal response.
ratePercentage of requests that return errors (0-100)statusCodeHTTP status code to return (e.g., 500, 503, 429)messageCustom error message included in the response body// With error injection configured (rate: 50%, statusCode: 500,
// message: "Internal Server Error"), ~50% of requests will fail:
// Successful response (50% of requests):
{
"data": [...],
"meta": { "total": 50, "page": 1, "perPage": 10, "pages": 5 }
}
// Error response (50% of requests):
// HTTP 500
{
"error": "Internal Server Error"
}When rate limiting is configured, requests that exceed the allowed threshold within the time window are rejected with a 429 status code.
maxRequestsMaximum number of requests allowed per windowwindowMsTime window duration in milliseconds// With rate limiting configured (maxRequests: 10, windowMs: 60000),
// after 10 requests within 60 seconds you'll receive:
// HTTP 429
{
"error": "Too Many Requests",
"message": "Rate limit exceeded. Try again later."
}Scenarios are configured per-route in your project dashboard. You can enable multiple scenario types on the same route. For example, you can combine latency simulation with error injection to test how your app handles slow, unreliable APIs.
Rest Faker provides tools to speed up integration — import existing API specs, download ready-to-use Postman collections, and get TypeScript types for your schemas.
Import an existing OpenAPI 3.x or Swagger 2.x spec to auto-create a project with all routes already configured.
Download a pre-configured Postman collection for your entire project — all routes, auth headers, and example requests included.
Download a .ts file with TypeScript interfaces generated from your schemas. Paste directly into your frontend project.
If you already have an OpenAPI specification, you can import it directly to generate a complete Rest Faker project without manually defining each route.
From your project list, click the Import OpenAPI button.
Paste the spec text directly, or upload a .json, .yaml, or .yml file.
Rest Faker parses the spec and shows every detected route with its mapped fields. Deselect any routes you don't need.
Give the project a name and click Import. A new project is created with all selected routes ready to use.
format: email) and common field names (e.g. firstName, price, avatar) to the appropriate Faker.js generators. Fields that cannot be mapped are flagged as unmapped in the preview.Export your entire project as a Postman collection (.json). The collection includes every route with pre-filled headers, example request bodies, and the correct API token, so you can start testing immediately after import.
apiToken header.json file into Postman via File → Import.Generate a .ts file containing TypeScript interfaces for every schema in your project. Drop it into your frontend codebase for instant type safety.
// Example generated types file (types.ts)
export interface Post {
id: string;
title: string;
description: string;
slug: string;
createdAt: string;
updatedAt: string;
}
export interface Comment {
id: string;
body: string;
postId: string; // added because of belongsTo relation
createdAt: string;
updatedAt: string;
}
export interface ApiResponse<T> {
data: T[];
meta: {
total: number;
page: number;
perPage: number;
pages: number;
};
}my-blog-types.ts).Practical examples showing how to use your generated API endpoints.
// Pagination example
fetch('https://api.restfaker.dev/api/schema/posts?page=2&perPage=10', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));// Sorting by fields
fetch('https://api.restfaker.dev/api/schema/posts?sort=createdAt&order=desc', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));# cURL example
curl -X GET "https://api.restfaker.dev/api/schema/posts" \
-H "apiToken: your_api_token_here" \
-H "Content-Type: application/json"{
"data": [
{
"id": "d9c03940-8451-4c3e-944f-6ddfd23390f6",
"title": "Lorem ipsum dolor sit amet",
"description": "Consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"slug": "lorem-ipsum-dolor-sit-amet",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z"
}
],
"meta": {
"total": 50,
"page": 1,
"perPage": 10,
"pages": 5
}
}Combining multiple query parameters:
// Advanced sorting and pagination
fetch('https://api.restfaker.dev/api/schema/posts?page=2&perPage=5&sort=createdAt&order=desc', {
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
console.log(`Found ${data.meta.total} posts`);
console.log(`Showing page ${data.meta.page} of ${data.meta.pages}`);
data.data.forEach(post => {
console.log(`- ${post.title}`);
});
});