Skip to content

Data Generation

MockAPI generates realistic mock data using 140+ property types powered by Faker.js. Learn about all available types, locale support, and customization options.

How Data Generation Works

When a mock endpoint receives a request, MockAPI looks at the response's associated data model, reads each property's type, and generates a value using the appropriate generator. The result is a realistic JSON object (or array of objects) that matches your model's structure.

Data is generated fresh for each request. MockAPI doesn't store generated data. Each response contains newly generated values based on your property configurations.

Property Types

MockAPI offers a wide range of property types organized into categories. Each type generates contextually appropriate data.

Basic Types

TypeDescriptionExample Output
StringA random word or short text"lorem"
TextA longer paragraph of text"Lorem ipsum dolor sit amet..."
NumberA random integer42
DecimalA random decimal number19.99
Booleantrue or falsetrue
DateA date in ISO format"2025-03-15"
Date TimeA date and time in ISO format"2025-03-15T14:30:00.000Z"

Person

TypeDescriptionExample Output
NameA full name (first + last)"John Doe"
First NameA first name"Jane"
Last NameA last name"Smith"
EmailAn email address"john.doe@example.com"
PhoneA phone number"+1-555-123-4567"
GenderA gender string"Female"
Job TitleA job title"Senior Developer"

Location

TypeDescriptionExample Output
AddressA full street address"123 Main St"
CityA city name"San Francisco"
StateA state or region"California"
CountryA country name"United States"
Zip CodeA postal code"94105"
LatitudeA latitude coordinate37.7749
LongitudeA longitude coordinate-122.4194

Internet

TypeDescriptionExample Output
URLA URL"https://example.com/page"
DomainA domain name"example.com"
UsernameA username"john_doe42"
PasswordA password string"xK9#mPq2!"
IPAn IP address (v4 or v6)"192.168.1.1"
IPv4An IPv4 address"192.168.1.1"
IPv6An IPv6 address"2001:0db8:85a3:0000:..."
AvatarA profile avatar image URL"https://cdn.mockapi.com/..."

Finance

TypeDescriptionExample Output
AccountA bank account number"12345678"
AmountA monetary amount"249.99"
Credit CardA credit card number"4532-1234-5678-9012"
CurrencyA currency code"USD"
BitcoinA Bitcoin address"1A1zP1eP5QGefi2DMPTf..."
EthereumAn Ethereum address"0x32Be343B94f860124dC..."

Commerce

TypeDescriptionExample Output
ProductA product name"Handmade Steel Chair"
PriceA price"29.99"
DepartmentA department/category"Electronics"

Images

MockAPI provides 30+ image categories that return URLs to hosted stock images. These are served from MockAPI's CDN and are always available.

TypeDescription
AvatarProfile avatar images
BannerWide banner images
Product ImageProduct photography
FoodFood and cuisine images
NatureNature and landscape photography
CityUrban cityscape images
TechnologyTechnology-related images
BusinessBusiness and office images
FashionFashion and clothing images
ArchitectureArchitecture photography
AnimalsAnimal photography
SportsSports action images
TravelTravel destination images
AbstractAbstract art images
...and 15+ moreCategories for various image needs

All image URLs follow the pattern: https://cdn.mockapi.com/file/mockapi/{{category}}/{{filename}}

Model References

You can reference other models to create nested objects. Select another model as the property type, and MockAPI will generate a nested object (or array) using that model's properties.

Info

Nested models have a maximum depth of 5 levels to prevent circular reference issues. See Circular Reference Protection below.

Data Customization

Sequential values

Enable Sequential on a property to generate incrementing values. This is commonly used for ID fields. The sequence starts at 1 by default and increments for each item in a range response.

Sequential IDs in a range response
[
  { "id": 1, "name": "Alice" },
  { "id": 2, "name": "Bob" },
  { "id": 3, "name": "Charlie" }
]

Numeric ranges

For number and decimal types, use Range Start and Range End to constrain generated values. For example, setting range 1-100 generates numbers between 1 and 100.

Static values

Enable Static Data to always return the same value for a property. The static value is returned as-is in every response. Useful for version numbers, constant strings, or fixed configuration values.

Custom list values

Define a set of possible values and MockAPI will randomly pick one for each generated instance. Enter values as a comma-separated list.

Example: For a "status" field, enter: active, inactive, pending, suspended

Example: For a "color" field, enter: red, blue, green, yellow, purple

Regex patterns

Use regular expression patterns to generate strings that match a specific format. MockAPI uses the regex pattern to produce matching strings.

Example: [A-Z]{3}-\d{4} generates strings like ABC-1234

Character sequences

Character sequences provide a simpler alternative to regex for common patterns:

SymbolGeneratesExample PatternExample Output
#Random digit (0-9)ORD-####ORD-8472
@Random uppercase letter@@-####KM-3917
^Random lowercase letter^^##ab42
*Random alphanumeric****-****a3Kp-9mQx
$Random special characterpass$$pass!@#
%Random hex character%%:%%:%%A3:F1:B7

Locale Support

MockAPI supports data generation in multiple languages and regional formats. The locale is set at the project level and affects all generated data including names, addresses, phone numbers, and dates. You can change the locale in Settings → General.

How locales work

When you set a project's locale to "de" (German), name properties generate German names, address properties generate German addresses, and so on. MockAPI supports all major Faker.js locales including:

LocaleLanguage
enEnglish (default)
deGerman
frFrench
esSpanish
itItalian
jaJapanese
koKorean
zh_CNChinese (Simplified)
pt_BRPortuguese (Brazil)
ruRussian
arArabic
nlDutch
plPolish
svSwedish
...and many moreAll Faker.js locales are supported

Locale fallback

If a specific locale variant is not available (e.g., "en_GB"), MockAPI falls back to the base language ("en"). Both hyphenated (en-US) and underscored (en_US) formats are accepted.

Circular Reference Protection

When models reference each other (Model A contains Model B, which contains Model A), MockAPI prevents infinite recursion by limiting nesting depth to 5 levels. At the maximum depth, nested model references return null instead of generating deeper objects.

You can check for circular references when editing a model using the built-in cycle detection feature available from the model editor.

GraphQL Selection Set Filtering

When data is generated for GraphQL responses, MockAPI respects the client's selection set. Only fields explicitly requested in the query are included in the response, even if the model has additional properties. This mirrors real GraphQL server behavior and reduces response size.