Navigation

Generate a Mock API from JSON

Learn how to turn any JSON payload into a live, shareable REST endpoint for prototyping and testing.

Last updated:

Frontend developers often need to prototype against an API that doesn't exist yet. DataLensia's Mock API Generator lets you create a live endpoint in seconds โ€” no server, no deployment, no sign-up.

๐Ÿšฉ The Scenario

You're building a dashboard and the backend team hasn't shipped the /api/users endpoint yet. You have a sample response:

[
  {"id": 1, "name": "Alice", "role": "admin", "lastLogin": "2025-01-15"},
  {"id": 2, "name": "Bob", "role": "editor", "lastLogin": "2025-01-14"}
]

๐Ÿ› ๏ธ Step-by-Step

  1. Open the Mock API Tool.
  2. Paste your JSON into the editor or upload a file.
  3. Configure the endpoint:
    • Status Code: 200 OK (or any other code for testing error handling).
    • HTTP Method: GET (restrict to specific methods if needed).
    • Delay: Add 500ms of artificial latency to simulate real network conditions.
    • Content-Type: Defaults to application/json.
  4. Click Generate Link.
  5. Copy the generated URL and use it in your frontend code:
const response = await fetch("https://datalensia.com/api/mock/m1.eJy...");
const users = await response.json();

๐ŸŽฒ Dynamic Values with Faker.js

Make your mock responses dynamic! Use placeholders that generate new data on every request:

{
  "id": "{{faker.string.uuid()}}",
  "name": "{{faker.person.fullName()}}",
  "email": "{{faker.internet.email()}}",
  "createdAt": "{{faker.date.recent()}}"
}

Every time the endpoint is called, fresh data is generated using Faker.js.

๐Ÿ”— Path-Based Sub-Resources

The Mock API supports nested paths. If you generate a mock at https://datalensia.com/api/mock/<data>, you can also access:

  • https://datalensia.com/api/mock/<data>/users โ€” returns the users key from your JSON.
  • https://datalensia.com/api/mock/<data>/users/0 โ€” returns the first user.

๐Ÿงช Simulation Panel

The Mock API tool includes a built-in Simulation tab where you can:

  • Send test requests to your endpoint.
  • See the exact response headers, body, and timing.
  • Verify that your status codes and delays work as expected.

๐Ÿ“„ Auto-Generated Documentation

The Docs tab automatically generates API documentation for your mock endpoint, including:

  • Endpoint URL.
  • Expected response format.
  • TypeScript type definitions for the response.

๐Ÿš€ Try it now

Create your first mock endpoint in the Mock API Generator.