Mock REST API
Create a Mock REST API Online
Create hosted REST endpoints with your own JSON responses. Use GET, POST, PUT, PATCH or DELETE and connect your frontend to a working API before the production backend is ready.
No backend server or local mock server required.
Working example
Give your frontend a real REST endpoint now
Suppose your application needs a /products endpoint, but the backend team has not built it yet. Create the route in Forge API and return the JSON structure your frontend expects.
/products200 OKhttps://apis.getforgeapi.com/YOUR_PROJECT_KEY/products
[
{
"id": 1,
"name": "Wireless Headphones",
"price": 79.99,
"inStock": true
},
{
"id": 2,
"name": "Mechanical Keyboard",
"price": 109.99,
"inStock": true
}
]Use the endpoint
Call your mock REST API like a normal backend
Forge API gives you a hosted HTTPS URL, so your application uses a normal HTTP request rather than importing hard-coded test data into the frontend.
const API_BASE_URL =
"https://apis.getforgeapi.com/YOUR_PROJECT_KEY";
const response = await fetch(`${API_BASE_URL}/products`);
if (!response.ok) {
throw new Error(`API request failed: ${response.status}`);
}
const products = await response.json();curl https://apis.getforgeapi.com/YOUR_PROJECT_KEY/productsREST methods
Mock the routes your application expects
Create resource-style routes using the HTTP methods planned for your production REST API.
| Method | Example route | Frontend scenario |
|---|---|---|
| GET | /products | Load a list of products |
| POST | /products | Test a create-product form |
| PUT | /products/1 | Test replacing a resource |
| PATCH | /products/1 | Test a partial update |
| DELETE | /products/1 | Test deletion and confirmation UI |
Test real UI states
Test more than the happy path
A useful mock API should help you build the states users see when requests are slow or unsuccessful, not just return perfect data every time.
Custom JSON responses
Return the exact objects, arrays and nested fields your interface expects.
HTTP status codes
Build frontend behaviour for successful and unsuccessful requests.
Response delays
Keep loading states visible long enough to design and test them properly.
Response headers
Model additional HTTP response behaviour required by your integration.
/products- Status
- 500
- Delay
- 1500ms
{
"error": "Unable to load products"
}Build the UI before the failure happens
Use predictable responses to design loading indicators, error messages, retry buttons and empty states before connecting to production services.
Move to production later
Keep your API base URL in one place
Your frontend should depend on the API contract, not the temporary backend implementation. Keep the base URL centralized and use the same endpoint paths throughout the application.
const API_BASE_URL =
"https://apis.getforgeapi.com/YOUR_PROJECT_KEY";fetch(`${API_BASE_URL}/products`);
fetch(`${API_BASE_URL}/users`);
fetch(`${API_BASE_URL}/orders`);When the real REST API is ready, change the base URL:
const API_BASE_URL =
"https://api.example.com";Your components can stay unchanged
If the production API uses the same routes and response shapes, switching from Forge API can be as simple as replacing the base URL.
Framework tutorials
Use your mock REST API in your frontend
Follow a framework-specific guide showing how to keep your API URL centralized and switch to the production backend later.
React
Connect React to a hosted mock API using a reusable request helper.
Read tutorial →Next.js
Use Forge API from Next.js with configurable environment variables.
Read tutorial →React Native
Use a hosted API from simulators, emulators and physical devices.
Read tutorial →Vue
Connect Vue to a hosted mock REST API while your backend is being built.
Read tutorial →Angular
Use Angular HttpClient with a reusable mock API service.
Read tutorial →Frequently asked questions
Mock REST API questions
What is a mock REST API?
A mock REST API provides HTTP endpoints that imitate the routes and responses of a production REST API. It lets frontend and mobile development continue before the real backend is available.
How do I create a mock REST API without a backend?
Create the routes your application expects, choose the HTTP methods, define the JSON responses and use the generated Forge API URLs from your frontend.
Which REST API methods can I use?
Forge API supports GET, POST, PUT, PATCH and DELETE endpoints.
Can I use a mock REST API with React or Next.js?
Yes. Forge API endpoints are standard hosted HTTPS URLs and can be called from React, Next.js, React Native, Vue, Angular and other applications.
Can I test error and loading states?
Yes. Controlled responses let you test different frontend states, including unsuccessful responses and delayed responses.
What happens when my real backend is ready?
If the production backend uses the same routes and response shapes, you can replace the Forge API base URL with the production API URL without rewriting your components.
Build your frontend before the backend is ready
Create REST endpoints with your own routes and JSON responses and connect your application to a hosted API URL.