Free mock API service for testing and development
A modern, schema-driven alternative to JSONPlaceholder
๐ Live: https://mockly.codes
๐ Docs: https://mockly.codes/docs
๐ฎ Playground: https://mockly.codes/playground
- ๐ Schema-Driven - Add new endpoints by creating JSON schemas (zero code!)
- ๐ฏ 100+ Resources - From users to weather, stocks to movies
- ๐ 14 Categories - Resources organized into logical groups (people, commerce, content, etc.)
- ๐ก Realistic Data - Powered by gofakeit with 50+ generators
- โก Blazing Fast - Redis + in-memory cache (<1ms responses)
- ๐ Consistent Data - Fixed seed ensures reproducible results
- ๐ Free Forever - No rate limits, open source and self-hostable
- ๐ Pagination - page, limit, offset parameters
- ๐ Sorting - Sort by any field, ascending or descending
- ๐ Search - Full-text search with field targeting
- ๐ฏ Filtering - Filter by field values (exact, range, contains)
- โ๏ธ Field Selection - Return only specific fields
- โฑ๏ธ Delay Simulation - Test timeouts (max 30s)
- ๐ฒ Chaos Engineering - Random failures with flakyRate
- ๐ซ Cache Control - Bypass cache for fresh data
- ๐ข Multi-tenancy - Tenant isolation via X-Tenant-ID
- ๐ RBAC - Role-based testing via X-Role
- ๐ Idempotency - Safe retries with Idempotency-Key
- ๐ Request Tracing - Track requests with X-Request-ID
- ๐จ Modern UI - Next.js 16 + React 19 with SSR
- ๐ฎ Interactive Playground - 50/50 split-screen with tabbed navigation
- ๐ Comprehensive Docs - Live examples and code snippets
- ๐ Cache Management - Admin endpoints for stats
- ๐ค Automated Build - TypeScript types auto-generated
- ๐ CORS Enabled - Ready for frontend development
mockly/
โโโ backend/ # Go API service (chi + gofakeit)
โ โโโ cmd/ # Application entry points
โ โโโ internal/ # Handlers, middleware, schema
โ โโโ Dockerfile # Docker build config
โ โโโ fly.toml # Fly.io deployment config
โโโ frontend/ # Next.js 16 website (React 19 + TypeScript + Tailwind)
โ โโโ app/ # Pages (landing, docs, playground)
โ โโโ components/ # React components
โ โโโ lib/ # Utility functions
โโโ shared/ # Source of truth for schemas & scripts
โ โโโ schemas/ # Resource definitions (user, post, etc.)
โ โโโ scripts/ # Build scripts (generate-types.js)
โโโ package.json # Root scripts for dev workflow
1. Clone the repository:
git clone https://github.com/0xdps/api-mockly.git
cd api-mockly2. Install dependencies:
# Install root dependencies (concurrently)
npm install
# Install web dependencies
npm run web:install3. Start both API and website:
npm run devThis automatically:
- โ Generates TypeScript types from schemas
- โ Starts API server on http://localhost:8080
- โ Starts website on http://localhost:3000
Note: Types are auto-generated on every build. No manual steps needed!
Or run separately:
# API only
npm run api:dev
# Website only
npm run web:devBasic Usage:
# Get resources with pagination
curl 'http://localhost:8080/products?page=1&limit=20'
# Get single item
curl http://localhost:8080/products/42
# Get resource metadata
curl http://localhost:8080/products/metaAdvanced Queries:
# Search products
curl 'http://localhost:8080/products?q=laptop&search_fields=name,description'
# Sort products by price
curl 'http://localhost:8080/products?sort=price&order=asc&limit=10'
# Filter by category and price
curl 'http://localhost:8080/products?category=Electronics&price<1000'
# Select specific fields
curl 'http://localhost:8080/products?fields=id,name,price&limit=50'Testing with Middleware:
# Add 2-second delay
curl 'http://localhost:8080/products?delay=2000'
# Test with 50% failure rate
curl 'http://localhost:8080/products?flakyRate=0.5'
# Bypass cache for fresh data
curl 'http://localhost:8080/products?skip_cache=true'
# Multi-tenant request
curl -H "X-Tenant-ID: tenant-123" http://localhost:8080/productsProduction API:
curl 'https://api.mockly.codes/products?page=1&limit=20'๐ Full API Documentation: backend/API_DOCUMENTATION.md
Resources are organized into 14 logical categories:
| Group | Count | Resources | Description |
|---|---|---|---|
| ๐ Commerce | 14 | products, orders, payments, coupons, categories, tags, carts, wishlists, promotions, discounts, returns, refunds, shipping, inventory | E-commerce |
| ๐ผ Business | 12 | companies, organizations, jobs, meetings, invoices, subscriptions, clients, contracts, proposals, departments, vendors, reports | Business entities |
| 10 | hotels, flights, restaurants, properties, cars, tours, attractions, bookings, destinations, travelguides | Travel & hospitality | |
| ๐ฅ People | 10 | users, contacts, students, players, employees, customers, profiles, authors, instructors, mentors | User profiles and people |
| ๐ฌ Media | 10 | movies, books, albums, videos, images, songs, playlists, photos, audios, streams | Entertainment media |
| ๐ฌ Social | 9 | comments, reviews, messages, notifications, testimonials, likes, shares, followers, mentions | Social interactions |
| ๐ Content | 8 | articles, posts, news, podcasts, blogs, tutorials, guides, documents | Written content |
| โ Productivity | 6 | todos, notes, projects, tasks, tickets, events | Task management |
| ๐ Location | 6 | countries, cities, weather, states, regions, coordinates | Geographic data |
| ๐ฐ Finance | 6 | currencies, stocks, crypto, transactions, accounts, budgets | Financial data |
| ๐ Reference | 3 | faqs, quotes, languages | Reference data |
| ๐ Food | 3 | recipes, ingredients, dishes | Food & cooking |
| โฝ Sports | 2 | matches, teams | Sports data |
| ๐ Education | 1 | courses | Educational content |
Group Endpoints:
GET /{group} # Group info (metadata only)
GET /{group}/{resource} # Collection via group path
GET /{group}/{resource}/:id # Single item via group pathDirect Resource Endpoints:
GET /{resource}?count=N # Collection (max 100)
GET /{resource}/:id # Single item
GET /{resource}/meta # Resource metadataExamples:
# Browse by category
curl https://api.mockly.codes/people
# Returns: {"group": "people", "resources": ["users", "contacts", ...], "count": 4}
# Get data via category path
curl 'https://api.mockly.codes/people/users?count=5'
# Or access directly (backwards compatible)
curl 'https://api.mockly.codes/users?count=5'Production API: https://api.mockly.codes
1. Create a schema in shared/schemas/:
Note: TypeScript types are automatically generated from schemas during build. No manual steps required!
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Order",
"type": "object",
"x-resource": {
"name": "orders",
"singular": "order",
"description": "E-commerce orders",
"group": "commerce",
"routes": {
"path": "/orders",
"methods": ["GET"],
"aliases": ["/purchases"]
}
},
"properties": {
"id": {
"type": "integer",
"x-generator": "random_int",
"x-generator-params": { "min": 1, "max": 10000 }
},
"total": {
"type": "number",
"x-generator": "random_int",
"x-generator-params": { "min": 10, "max": 500 }
},
"status": {
"type": "string",
"x-generator": "word"
}
}
}2. Restart the API server:
cd backend && make dev
# or: go run cmd/server/main.goThat's it! Your new endpoint is live at /orders ๐
The build process automatically:
- โ Syncs schemas to backend
- โ Generates TypeScript types for frontend
- โ Loads new routes in API server
See BUILD_PROCESS.md for details.
Define custom paths, aliases, and methods in schemas:
{
"x-resource": {
"name": "todos",
"routes": {
"path": "/todos",
"aliases": ["/tasks", "/todo-items"],
"methods": ["GET", "POST"]
}
}
}This creates:
- โ
GET /todos - โ
GET /tasks(alias) - โ
GET /todo-items(alias)
We support over 200 generators via gofakeit. Popular ones:
Personal: name, first_name, email, username, password, avatar
Address: address, city, country, zip_code, latitude, longitude
Company: company, job, catch_phrase, company_name, job_title
Internet: url, domain_name, ipv4, uuid, mac_address, image_url
Dates: date, date_time, past_date, future_date, time_zone
Text: word, sentence, paragraph, text, quote_text
Numbers: random_int, random_digit, random_number, float32
Weather: weather_temperature, weather_description, weather_humidity
Finance: currency_code, exchange_rate, stock_symbol, crypto_name
Geography: country_name, city_name, language_name, capital_city
Media: movie_title, book_title, album_title, video_title
Travel: flight_number, hotel_name, restaurant_name, recipe_name
Business: invoice_number, order_id, payment_status, ticket_id
Other: phone_number, boolean, user_agent, car_model
See all generators in backend/internal/schema/loader.go
The backend uses an in-memory cache with warmup on startup for blazing fast responses:
๐ฅ Starting cache warmup (seed: 42, items per resource: 100)...
โ
Cache warmup completed in 2.5s
๐ Resources: 100, Total items: 10,000- <1ms response times - Pre-generated data served from memory
- Consistent data - Same ID always returns same object (perfect for testing)
- Reproducible - Fixed seed (42) ensures same data across restarts
- Low CPU usage - Generate once, serve thousands of times
Configure via environment variables:
# Number of items to cache per resource (default: 100)
CACHE_ITEMS_PER_RESOURCE=100
# Random seed for reproducible data (default: 42)
CACHE_SEED=42# View cache statistics
GET /admin/cache/stats
# Refresh cache (regenerate all data)
POST /admin/cache/refreshGet fresh data without using cache (useful for testing/demos):
# Via query parameter
GET /users?nocache=true
GET /products?fresh=true
# Via header
curl -H "X-No-Cache: true" http://localhost:8080/users
curl -H "Cache-Control: no-cache" http://localhost:8080/productsAll responses include X-Cache header:
X-Cache: HIT- Served from cacheX-Cache: BYPASS- Cache bypassedX-Cache: MISS- Cache miss
๐ Full cache documentation: backend/CACHE.md
๐ Cache bypass guide: backend/CACHE_BYPASS.md
Backend (Fly.io):
cd backend
make deploy # Auto-syncs schemas and deploysFrontend (Vercel):
cd frontend
vercel --prod # Auto-generates types and deploysThe deployment process automatically includes all schemas:
- โ
Backend: Schemas copied from
shared/during Docker build - โ
Frontend: Types auto-generated via
prebuildhook - โ No manual steps required!
See DEPLOYMENT.md for complete deployment guide.
- API: https://api.mockly.codes
- Website: https://mockly.codes
- Docs: https://mockly.codes/docs
- Playground: https://mockly.codes/playground
- Language: Go 1.23+
- Router: chi v5 (lightweight, idiomatic)
- Data Generation: gofakeit/v7
- CORS: go-chi/cors
- Deployment: Fly.io
- Framework: Next.js 16 (App Router with SSR)
- Language: TypeScript
- UI Library: React 19
- Styling: Tailwind CSS
- HTTP Client: pingpong-fetch (universal, fast, type-safe)
- Rendering: Server-Side with ISR (5-minute cache)
- Deployment: Vercel
- API Integration: https://api.mockly.codes
Comprehensive API Reference: backend/API_DOCUMENTATION.md
- ๐ Complete endpoint reference
- ๐ All query parameters (pagination, sorting, search, filtering)
- ๐ ๏ธ All 11 middleware features documented
- ๐ป Code examples (JavaScript, Python, cURL)
- ๐ Response formats and error handling
- โจ Best practices and advanced usage
Online Documentation: Visit https://mockly.codes/docs for:
- Quick start guide (4 languages)
- Interactive schema explorer
- Live "Try It" buttons
- Real-time API status
Visit https://mockly.codes/playground to:
- ๐ฎ Test all API features
- ๐ Pagination, sorting, search controls
- ๐ ๏ธ Middleware testing (delay, flaky, cache)
- ๐ Request/response inspection
- ๐ Copy code examples
- 5 utility tools: Echo, Status, Delay, Middleware, Chaos
Contributions welcome! The easiest way to contribute is to add new resource schemas:
- Create
shared/schemas/your-resource.json - Test locally with
npm run dev(types auto-generate!) - Submit a PR
See CONTRIBUTING.md for detailed guidelines.
- backend/API_DOCUMENTATION.md - Comprehensive API reference
- DEPLOYMENT.md - Deployment guide
- CONTRIBUTING.md - Contribution guidelines
- CHANGELOG.md - Version history
- backend/README.md - Backend setup
- frontend/README.md - Frontend setup
MIT License - see LICENSE
Built with:
- gofakeit - Fake data generation
- chi - Lightweight Go router
- Next.js 16 - React framework with SSR
- React 19 - UI library
Made with โค๏ธ by Devendra Pratap