home / skills / ehtbanton / claudeskillsrepo / json-api-mock-generator

json-api-mock-generator skill

/json-api-mock-generator

This skill generates realistic JSON API mock responses with nested structures, proper types, and configurable record counts for fast development.

npx playbooks add skill ehtbanton/claudeskillsrepo --skill json-api-mock-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.1 KB
---
name: json-api-mock-generator
description: Generate realistic JSON API mock response files with proper data types, nested structures, and configurable record counts. Triggers on "create mock API response", "generate JSON mock data", "fake API data for", "mock endpoint response".
---

# JSON API Mock Generator

Generate production-realistic JSON API mock response files for development, testing, and prototyping.

## Output Requirements

**File Output:** `.json` files with valid JSON structure
**Naming Convention:** `mock-{resource}-{endpoint}.json` (e.g., `mock-users-list.json`)

## When Invoked

Immediately generate a complete, valid JSON file. Ask no clarifying questions unless the domain is completely ambiguous.

## Default Behavior

If minimal context provided, generate:
- 10 records for list endpoints
- Realistic fake data (names, emails, dates, IDs)
- Proper data types (strings, numbers, booleans, arrays, nested objects)
- RESTful response wrapper structure

## JSON Structure Patterns

### List Endpoint Response
```json
{
  "data": [...],
  "meta": {
    "total": 100,
    "page": 1,
    "per_page": 10,
    "total_pages": 10
  },
  "links": {
    "self": "/api/v1/resource?page=1",
    "next": "/api/v1/resource?page=2",
    "last": "/api/v1/resource?page=10"
  }
}
```

### Single Resource Response
```json
{
  "data": {
    "id": "uuid-here",
    "type": "resource_name",
    "attributes": {...},
    "relationships": {...}
  }
}
```

### Error Response
```json
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human readable message",
    "details": [...],
    "timestamp": "ISO-8601"
  }
}
```

## Data Generation Rules

### IDs
- Use UUIDs for primary keys: `"id": "550e8400-e29b-41d4-a716-446655440000"`
- Use sequential integers only if specified: `"id": 1`

### Timestamps
- ISO 8601 format: `"2024-01-15T09:30:00Z"`
- Include `created_at`, `updated_at` for resources

### Names and Text
- Use realistic but clearly fake names: "Jane Smith", "Acme Corp"
- Vary lengths appropriately
- No lorem ipsum unless specifically for content fields

### Numbers
- Currency: integers in cents `"amount": 9999` (represents $99.99)
- Percentages: decimals `"rate": 0.15`
- Counts: integers `"quantity": 5`

### Relationships
- Use consistent IDs across related resources
- Include both ID references and nested objects where appropriate

## Domain-Specific Patterns

### E-commerce
```json
{
  "id": "prod_abc123",
  "name": "Wireless Bluetooth Headphones",
  "sku": "WBH-001-BLK",
  "price": 7999,
  "currency": "USD",
  "inventory": {
    "quantity": 150,
    "warehouse": "US-WEST-01"
  },
  "images": [
    {"url": "https://cdn.example.com/products/wbh-001-1.jpg", "alt": "Front view"}
  ]
}
```

### User/Auth
```json
{
  "id": "usr_123abc",
  "email": "[email protected]",
  "username": "janesmith",
  "profile": {
    "first_name": "Jane",
    "last_name": "Smith",
    "avatar_url": "https://cdn.example.com/avatars/123.jpg"
  },
  "roles": ["user", "admin"],
  "verified": true,
  "created_at": "2024-01-15T09:30:00Z"
}
```

### SaaS/Subscription
```json
{
  "id": "sub_xyz789",
  "customer_id": "cus_abc123",
  "plan": {
    "id": "plan_pro",
    "name": "Professional",
    "amount": 4999,
    "interval": "month"
  },
  "status": "active",
  "current_period_start": "2024-01-01T00:00:00Z",
  "current_period_end": "2024-02-01T00:00:00Z"
}
```

## Validation Checklist

Before outputting, verify:
- [ ] Valid JSON (parseable)
- [ ] Consistent data types throughout
- [ ] IDs are unique within the file
- [ ] Timestamps are valid ISO 8601
- [ ] No trailing commas
- [ ] Proper null handling (not "null" strings)
- [ ] Arrays are properly bracketed
- [ ] Nested objects are complete

## Example Invocations

**Prompt:** "Create mock API response for a blog posts endpoint"
**Output:** Complete `mock-posts-list.json` with 10 realistic blog posts including title, content, author, tags, dates, view counts.

**Prompt:** "Generate fake user data JSON for 25 users with addresses"
**Output:** Complete `mock-users-list.json` with 25 users including nested address objects.

**Prompt:** "Mock API error response for 404 not found"
**Output:** Complete `mock-error-404.json` with proper error structure.

Overview

This skill generates production-realistic JSON API mock response files for development, testing, and prototyping. It creates valid .json outputs named using the mock-{resource}-{endpoint}.json convention and produces realistic data types, nested structures, and configurable record counts. The generator defaults to sensible RESTful wrappers and 10 records for list endpoints when minimal context is provided.

How this skill works

When invoked with a trigger phrase (for example: "create mock API response", "generate JSON mock data", "fake API data for", or "mock endpoint response"), the skill immediately emits a complete JSON file with no clarifying questions unless the domain is ambiguous. It builds list, single-resource, or error responses following standard wrapper patterns, populates fields with realistic fake values (UUIDs, ISO-8601 timestamps, emails, names, amounts), and ensures consistent IDs and types across relationships.

When to use it

  • Create realistic list responses for frontend development and pagination testing
  • Generate single-resource payloads for component integration or API contract tests
  • Produce error response samples (404, 422, 500) for error handling and UI states
  • Seed automated tests with deterministic but realistic mock records
  • Prototype new endpoints quickly without backend implementation

Best practices

  • Specify resource name, endpoint, and record count when possible to get precise output
  • Use UUIDs for primary keys unless you explicitly need sequential integers
  • Include domain hints (e-commerce, user, SaaS) to receive domain-specific fields
  • Validate the generated JSON against your API schema and the provided checklist before use
  • Keep mock files under version control and update them when the API contract changes

Example use cases

  • mock-posts-list.json — 10 realistic blog posts with authors, tags, content snippets, and view counts
  • mock-users-list.json — 25 users with nested address objects, avatars, roles, and created_at timestamps
  • mock-product-list.json — e-commerce product catalog with SKUs, price in cents, inventory, and image objects
  • mock-error-404.json — standardized error payload with code, message, details array, and ISO timestamp
  • mock-subscription-single.json — SaaS subscription resource with plan object, period dates, and status

FAQ

What default record count is used for lists?

Lists default to 10 records unless you request a different count.

Are IDs UUIDs by default?

Yes — primary keys use UUIDs by default. Sequential integers are used only when explicitly requested.

Does the generator validate JSON before output?

Yes — it ensures valid JSON, consistent data types, unique IDs within the file, valid ISO-8601 timestamps, and no trailing commas.