API Reference

Complete API documentation for integrating MockaMocha into your development workflow

Base URL
https://app.mockamocha.com
Version
v1

Authentication

All API requests require authentication using Bearer tokens. Include your API key in the Authorization header.

Authorization: Bearer YOUR_ACCESS_TOKEN
Getting API Keys

API keys are available in your MockaMocha dashboard under Settings → API Keys. Keep your keys secure and never share them in client-side code.

POST/api/auth/login

Authenticate User

Authenticate with email and password to get access token

Request Body

{
  "email": "user@example.com",
  "password": "your_password"
}

Response

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer",
  "expires_in": 3600,
  "user": {
    "id": "user_123",
    "email": "user@example.com",
    "name": "John Doe"
  }
}
GET/api/collections

List Collections

Retrieve all API collections in your workspace

Response

{
  "collections": [
    {
      "id": "coll_abc123",
      "name": "E-commerce API",
      "description": "Mock endpoints for online store",
      "endpoints_count": 12,
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-16T14:22:00Z"
    }
  ],
  "total": 3,
  "page": 1,
  "per_page": 20
}
POST/api/collections/{collection_id}/import

Import API Specification

Import OpenAPI specification to create mock endpoints

Response

{
  "import_id": "imp_xyz789",
  "status": "processing",
  "endpoints_created": 15,
  "message": "Import started successfully",
  "collection_id": "coll_abc123"
}
GET/api/endpoints

List Mock Endpoints

Get all mock endpoints with filtering and pagination

Response

{
  "endpoints": [
    {
      "id": "ep_def456",
      "method": "GET",
      "path": "/api/users",
      "name": "Get Users",
      "collection_id": "coll_abc123",
      "response_rules_count": 2,
      "requests_count": 1247,
      "last_request_at": "2024-01-16T09:15:00Z",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "total": 25,
  "page": 1,
  "per_page": 20
}
POST/api/endpoints/{endpoint_id}/generate-data

Generate Mock Data

AI-powered generation of realistic mock data based on endpoint schema

Request Body

{
  "count": 50,
  "schema_type": "json",
  "custom_fields": {
    "user_type": [
      "premium",
      "basic",
      "trial"
    ]
  }
}

Response

{
  "generation_id": "gen_123abc",
  "status": "completed",
  "records_generated": 50,
  "data_preview": [
    {
      "id": 1,
      "name": "John Doe",
      "email": "john.doe@example.com",
      "user_type": "premium",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}
GET/api/analytics/requests

Request Analytics

Get detailed analytics about mock endpoint usage and performance

Response

{
  "total_requests": 15420,
  "unique_endpoints": 45,
  "time_period": "30d",
  "requests_by_day": [
    {
      "date": "2024-01-15",
      "count": 342
    }
  ],
  "top_endpoints": [
    {
      "endpoint_id": "ep_def456",
      "path": "/api/users",
      "method": "GET",
      "requests_count": 1247,
      "avg_response_time": 145
    }
  ]
}

Response Formats

Success Response

Status codes: 200-299

{
  "data": "// Requested data",
  "meta": {
    "request_id": "req_abc123",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}

Error Response

Status codes: 400-599

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request format",
    "details": [
      "Field \"name\" is required"
    ]
  },
  "meta": {
    "request_id": "req_abc123",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}

SDKs & Integration Tools

JavaScript SDK

Node.js and browser support

Python SDK

Native Python integration

CLI Tool

Command-line interface

Ready to Integrate MockaMocha?

Get API access and start building intelligent mock APIs today