Documentation
Everything you need to use Mockly — built-in resources, user templates, query parameters, and middleware.
Overview
No Setup
100+ endpoints ready instantly — no account, no config.
CORS Enabled
Works directly from browsers and frontend apps.
Realistic Data
Powered by 50+ data generators for authentic-looking data.
Free Forever
No rate limits, no plans, no credit card required.
https://api.mockly.codesAll endpoints listed in this reference are relative to this base.
Quick Start
No account needed. Copy, paste, run.
# Get 10 products
curl "https://api.mockly.codes/products?limit=10"
# Search users
curl "https://api.mockly.codes/users?q=john&limit=5"
# Sort products by price (descending)
curl "https://api.mockly.codes/products?sort=price&order=desc"
# Filter by field + paginate
curl "https://api.mockly.codes/products?category=Electronics&limit=20&page=2"
# Select specific fields only
curl "https://api.mockly.codes/products?fields=id,name,price&limit=50"Endpoints
| Pattern | Description |
|---|---|
GET /{resource} | Paginated list of items — supports all query parameters |
GET /{resource}/{id} | Single item by numeric ID (1–100) |
GET /{resource}/meta | JSON Schema definition for the resource |
GET /t/{templateId} | User template endpoint — requires API key header |
GET /v1/{slug} | Featured template shorthand (same as /{resource}) |
GET / | API info: version, available resources, categories |
Replace {resource} with any resource slug, e.g. products, users, orders. See the full resource list below.
Authentication
All 100+ built-in resources are completely public. No header required.
curl "https://api.mockly.codes/products"Custom templates require an API key in the Authorization header.
curl -H "Authorization: Bearer mk_your_key" \
"https://api.mockly.codes/t/{templateId}"mk_ are personal; mak_ keys work for public templates.Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | int 1–100 | 10 | Number of items to return per page |
page | int | 1 | Page number (1-based) |
offset | int | — | Manual offset; overrides page if set |
sort | string | — | Field name to sort results by |
order | string | asc | Sort direction: asc or desc |
q | string | — | Full-text search query across all fields |
search_fields | string | — | Comma-separated fields to restrict search to |
fields | string | — | Comma-separated fields to include in response |
{field}=value | string | — | Filter by exact or operator-qualified value |
delay | int (ms) | — | Simulate network latency (max 30,000 ms) |
flakyRate | float 0–1 | — | Probability of returning a 503 error |
skip_cache | bool | false | Bypass the response cache for fresh data |
locale | string | — | BCP-47 locale tag — generates locale-aware names, cities, phones (e.g. en-IN, ja-JP, de-DE) |
# Combine multiple parameters
curl "https://api.mockly.codes/products?\
q=laptop&search_fields=name,description&\
sort=price&order=asc&\
page=1&limit=20&\
fields=id,name,price,rating"Filtering
Filter results by appending operators to field names: ?{field}{operator}={value}
| Operator | Meaning | Example |
|---|---|---|
= | Equals (default) | ?category=Electronics |
!= | Not equals | ?status!=inactive |
> | Greater than | ?price>100 |
>= | Greater than or equal | ?rating>=4 |
< | Less than | ?price<500 |
<= | Less than or equal | ?stock<=10 |
~contains | Contains substring | ?name~contains=pro |
~startsWith | Starts with | ?slug~startsWith=us |
~endsWith | Ends with | ?email~endsWith=.com |
# Price range + in-stock filter
curl "https://api.mockly.codes/products?price>=100&price<=500&in_stock=true"
# Name contains + sorted
curl "https://api.mockly.codes/products?name~contains=pro&sort=price&order=asc"Search
Use ?q= for full-text search. By default all string fields are searched. Narrow it with search_fields.
# Search all fields
curl "https://api.mockly.codes/products?q=laptop"
# Search specific fields only
curl "https://api.mockly.codes/products?q=laptop&search_fields=name,description"
# Combine with pagination and sort
curl "https://api.mockly.codes/products?q=phone&sort=price&order=asc&page=1&limit=10"search_fields is recommended for better performance on large schemas.Middleware & Headers
Mockly includes built-in middleware for testing resilience, multi-tenancy, and access control.
?delay=msSimulate slow network responses. Max 30,000 ms.
curl "https://api.mockly.codes/products?delay=2000" # 2 second delay?flakyRate=0.0–1.0Randomly returns 503 errors at the given probability. Test your retry logic.
curl "https://api.mockly.codes/products?flakyRate=0.3" # 30% chance of failure?locale=BCP-47Generate locale-specific names, cities, phone numbers, and postal codes. Bypasses cache automatically. Supported: en-IN, ja-JP, de-DE, fr-FR, zh-CN, pt-BR, es-ES, ko-KR, ar-SA, en-GB.
curl "https://api.mockly.codes/users?locale=en-IN&limit=5" # Indian users
curl "https://api.mockly.codes/employees?locale=ja-JP&limit=10" # Japanese employees| Header | Description |
|---|---|
X-Tenant-ID | Isolate data by tenant — same tenant always gets same data |
X-Role | Simulate RBAC: admin, user, guest, or any custom role |
Idempotency-Key | Make POST/PUT/PATCH idempotent — response cached 24h |
X-Request-ID | Custom trace ID echoed back in response headers |
# Multi-tenant + role simulation
curl -H "X-Tenant-ID: tenant-a" -H "X-Role: admin" \
"https://api.mockly.codes/products?limit=5"
# Idempotent POST
curl -X POST -H "Idempotency-Key: order-123" \
-H "Content-Type: application/json" \
-d '{"product": "laptop"}' \
"https://api.mockly.codes/orders"Response Format
Collection (GET /{resource})
{
"data": [
{ "id": 1, "name": "Laptop", "price": 999.99 },
{ "id": 2, "name": "Phone", "price": 499.99 }
],
"pagination": {
"page": 1,
"limit": 10,
"total": 100,
"total_pages": 10
}
}Single item (GET /{resource}/42)
{
"id": 42,
"name": "Laptop",
"price": 999.99,
"category": "Electronics",
"in_stock": true,
"rating": 4.5
}Response Headers
| Header | Value | Description |
|---|---|---|
X-Cache | HIT / MISS / BYPASS | Cache status for the response |
X-Total-Count | integer | Total number of items available (collection endpoints) |
X-Request-ID | string | Request trace ID (echoed or generated) |
Code Examples
JavaScript / TypeScript
// Fetch with pagination
const res = await fetch('https://api.mockly.codes/products?page=1&limit=20&sort=price&order=asc')
const { data, pagination } = await res.json()
console.log(`Got ${data.length} of ${pagination.total} items`)
// Search
const search = await fetch(`https://api.mockly.codes/products?q=${encodeURIComponent('laptop')}&limit=10`)
const results = await search.json()
// User template (API key)
const tmpl = await fetch('https://api.mockly.codes/t/your-template-id', {
headers: { Authorization: 'Bearer mk_your_key' }
})
const { data: items } = await tmpl.json()Python
import requests
# Paginated + sorted
r = requests.get('https://api.mockly.codes/products', params={
'page': 1, 'limit': 20, 'sort': 'price', 'order': 'asc'
})
data = r.json()
print(f"Total: {data['pagination']['total']}")
# Search specific fields
r = requests.get('https://api.mockly.codes/products', params={
'q': 'laptop', 'search_fields': 'name,description', 'limit': 5
})
# User template
r = requests.get('https://api.mockly.codes/t/your-template-id',
headers={'Authorization': 'Bearer mk_your_key'}
)Go
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET",
"https://api.mockly.codes/products?limit=10&sort=price&order=desc", nil)
// For user templates, add auth header:
// req.Header.Set("Authorization", "Bearer mk_your_key")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]any
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}All Resources
100 resources across 14 categories. All accessible at GET https://api.mockly.codes/{resource}.
🛒 commerce
💼 business
🍔 food
🎓 education
Click any resource to open its interactive documentation.
Limits & CORS
What Mockly cannot do
- —Data is not persisted — POST/PUT/PATCH/DELETE requests are accepted but state is never modified
- —Cannot JOIN or query across multiple resources in one request
- —No GraphQL, WebSockets, or streaming endpoints
- —Generated data is deterministic per cache key — bypass with ?skip_cache=true for different data
Use with AI
Mockly provides machine-readable documentation specifically for LLM-based tools (GitHub Copilot, ChatGPT, Claude, Cursor, etc.).
Concise structured reference — paste this URL into any AI tool to give it full context on Mockly.
mockly.codes/llms.txtComplete API reference including all examples — best for deep code generation tasks.
mockly.codes/llms-full.txtExample AI prompts
React hook
Using the Mockly API (https://api.mockly.codes), write a React hook that fetches paginated products with search and sorting. Use https://www.mockly.codes/llms.txt for the full API reference.
Python data loader
Using the Mockly API (base URL: https://api.mockly.codes), write a Python function that loads all users across pages and returns a pandas DataFrame. No auth needed.
Testing harness
Write a Jest test suite that uses the Mockly API (https://api.mockly.codes/products) to verify pagination, sorting, and filtering work correctly in a frontend component.