Core Concepts

Endpoints & Resources

Create and configure REST API endpoints with full CRUD operations

What is an Endpoint?

An endpoint is a specific URL path that responds to HTTP requests. In REST APIs, endpoints represent resources (like users, products, or posts) and support operations through HTTP methods.

Anatomy of an Endpoint

GET http://localhost:3000/api/users/123

Method: GET (retrieve data)

Base URL: http://localhost:3000

Path: /api/users

Resource ID: 123

HTTP Methods (CRUD Operations)

Each endpoint can support multiple HTTP methods for different operations:

GET
Read / Retrieve

Fetch data from the server (list all or get by ID)

GET /api/users

Returns all users

GET /api/users/123

Returns user with ID 123

Use case: Displaying data, search, filtering
POST
Create

Create new resources on the server

POST /api/users

Creates a new user

json
Use case: Forms, registration, adding items
PUT
Update (Full Replace)

Replace entire resource with new data

PUT /api/users/123

Updates user 123 (all fields)

json
Use case: Edit forms, profile updates
PATCH
Update (Partial)

Update only specific fields of a resource

PATCH /api/users/123

Updates only specified fields

json
Use case: Toggle settings, update single field
DELETE
Delete

Remove resources from the server

DELETE /api/users/123

Deletes user with ID 123

Use case: Remove items, cancel subscriptions

Creating Endpoints

You have multiple ways to create endpoints in Mock API Builder:

Add to Existing Project (Recommended)

Add endpoints to an existing project through the Settings dialog

Steps:

  1. Open your project page
  2. Click the "Settings" button in the top-right
  3. Go to the "General" tab
  4. Click "Add Endpoint" button
  5. Enter endpoint name (e.g., "posts", "comments")
  6. Add description (optional)
  7. Choose contract format (Manual Fields or JSON)
  8. Define your data structure
  9. Set mock data count (1-100 records)
  10. Click "Create Endpoint"

💡 Tip: This is perfect for adding missing endpoints to template projects (e.g., adding "Get Blog by ID" to the Blog API template).

Create New Project

Start fresh with a new project and add endpoints during setup

Steps:

  1. Go to "Create New Project" page
  2. Enter project name and description
  3. Set base URL (e.g., "/api")
  4. Define your first endpoint resource
  5. Configure response structure
  6. Generate mock data
Template-Based

Use pre-built templates for common use cases

Available Templates:

  • • User Management (users, profiles, auth)
  • • E-commerce (products, orders, cart)
  • • Blog/CMS (posts, authors, comments)
  • • Task Management (tasks, projects)
OpenAPI Import

Import from existing OpenAPI/Swagger specifications

Benefits:

  • • Instant endpoint creation from spec
  • • Automatically generates schemas
  • • Preserves data types and validation
  • • Imports descriptions and examples

Endpoint Configuration

Resource Name

The base path for your endpoint (plural nouns recommended):

✓ Good examples:

  • /users
  • /products
  • /blog-posts

✗ Avoid:

  • /user (use plural)
  • /getUsers (don't include verb)
  • /Users (use lowercase)

Response Structure

Define what data your endpoint returns:

Single Resource (GET by ID)
json
Collection (GET all)
json

Status Codes

Automatically handled based on the operation:

200Success (GET, PUT, PATCH)
201Created (POST)
204No Content (DELETE)
404Not Found (invalid ID)
500Server Error

URL Parameters & Query Strings

Path Parameters

Used to identify specific resources:

/api/users/:id

Example: /api/users/123 retrieves user with ID 123

Query Parameters

Used for filtering, sorting, and pagination:

Filtering:

/api/users?role=admin&status=active

Sorting:

/api/products?sort=price&order=desc

Pagination:

/api/posts?page=2&limit=20

Best Practices

✓ Use Nouns, Not Verbs

/api/users

/api/getUsers

✓ Use Plural Names

/api/products

/api/product

✓ Be Consistent

Use the same naming patterns across all endpoints

✓ Keep URLs Simple

Maximum 2-3 levels deep for readability