Skip to content

Import & Export

Import API definitions from OpenAPI, GraphQL SDL, Postman collections, or JSON. Export your mock API documentation in multiple formats.

Overview

MockAPI's import system lets you quickly bootstrap your mock API from existing API definitions. Instead of manually creating models and endpoints one by one, import them from a file and have MockAPI automatically create the corresponding resources.

The export feature lets you download your project's models, endpoints, and schemas for backup, migration, or sharing.

Import Process

The import wizard guides you through a multi-step process:

  1. 1

    Select format

    Choose the file format you're importing: OpenAPI/Swagger, GraphQL, Postman, or JSON. Open the Import page to get started.

  2. 2

    Upload file

    Drag and drop your file or click to browse. The parser analyzes the file and extracts models and endpoints.

  3. 3

    Preview & select

    Review the extracted resources. Use checkboxes to select which models and endpoints to import. You can search and filter the list.

  4. 4

    Import

    Click "Import" to create the selected resources. Progress is tracked in real-time with status indicators for each item.

Info

MockAPI resolves dependencies automatically: models are created before endpoints that reference them. This ensures all relationships are properly established.

OpenAPI / Swagger

Import from Swagger 2 or OpenAPI 3 specifications in JSON or YAML format.

What gets imported

OpenAPI ComponentMockAPI Resource
Schemas / DefinitionsData Models with typed properties
Paths + OperationsREST Endpoints with HTTP method configurations
Response schemasModel associations on endpoint responses
Path parametersTemplate endpoints (e.g., /users/{id})

Example OpenAPI file

openapi.yaml
openapi: "3.0.0"
info:
  title: My API
  version: "1.0"
paths:
  /users:
    get:
      summary: List users
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/User"
  /users/{id}:
    get:
      summary: Get user by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/User"
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        email:
          type: string
          format: email

Type mapping

MockAPI reads the OpenAPI type first. A property name can then refine it: a string named email returns email addresses and a number named price returns prices, but a boolean named isValid stays a boolean. A $ref to another model created earlier in the same import comes before both. Without a matching name:

OpenAPI TypeOpenAPI FormatMockAPI Type
string(none)String
stringemailEmail
stringuri / urlURL
stringdateDate
stringdate-timeDate Time
integer(none)Number
number(none)Number
numberfloat / doubleFloat
boolean(none)Boolean
object(none)Object, returned as {}
object$refModel reference
array(items: $ref)Model reference, 10 items
array(with items)The item type, 5 items
array(no items)Array, returned empty

Postman Collections

Import from Postman Collection v2.0+ format (JSON). MockAPI extracts endpoints with their HTTP methods and URL paths.

What gets imported

Postman ComponentMockAPI Resource
RequestsREST Endpoints with method configurations
Request URLsEndpoint paths
Request methodsHTTP method configurations
FoldersUsed for organizing during preview

How to export from Postman

In Postman, right-click your collection and select "Export". Choose Collection v2.1 format and save the JSON file. Then upload it to MockAPI's import wizard.

GraphQL SDL

Import GraphQL Schema Definition Language (SDL) files to create GraphQL schemas in MockAPI.

What gets imported

GraphQL ComponentMockAPI Resource
Type definitionsGraphQL Schema with SDL
Object typesCan be used to create Data Models
Query/Mutation typesUsed to identify available operations

Example GraphQL SDL

schema.graphql
type User {
  id: ID!
  name: String!
  email: String!
  posts: [Post!]!
}

type Post {
  id: ID!
  title: String!
  body: String!
  author: User!
}

type Query {
  users: [User!]!
  user(id: ID!): User
  posts: [Post!]!
}

JSON Import

Import plain JSON files to infer data models from the structure. MockAPI analyzes the JSON and creates models based on the field names and value types it finds.

How it works

MockAPI examines the JSON structure and automatically infers property types. For example, a field containing an email-like string is assigned the "Email" type, while a numeric field becomes "Number".

Example JSON
[
  {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com",
    "age": 30,
    "active": true,
    "createdAt": "2025-01-15T10:30:00Z"
  }
]

From this JSON, MockAPI creates a model with properties: id (Number), name (Name), email (Email), age (Number), active (Boolean), createdAt (Date Time).

Export

Export your project's resources for backup, sharing, or migration. Navigate to the Export page from the sidebar to download your project data.

The export includes all models, REST endpoints, and GraphQL schemas in your current project.

Import Tips

  • Review before importing: Always preview the extracted resources and deselect any you don't need.
  • Check property types after import: Automatic type detection is good but not perfect. Review imported models and adjust property types as needed.
  • Mind your plan limits: Imports count against your plan's model and endpoint limits. Check your remaining capacity before importing large files. See Plans & Billing for limit details.
  • Use selective import: You don't have to import everything. Use checkboxes to selectively import only the models and endpoints you need.