MockAPI Documentation
Welcome to the MockAPI Documentation. This guide will help you understand how to effectively use our platform to mock APIs with custom JSON responses, leveraging the power of fake data and schema generation. Whether you're developing a new application or testing an existing one, our tool will help you create realistic API responses quickly and easily.
Main Concept
The main concept behind our platform is to provide a flexible and easy-to-use environment where you can define and organize your mock APIs. The core features include:
Concept | Description |
---|---|
Projects | Organize your mock APIs into separate projects for easy management. |
Collections | Group related endpoints together within a project. |
Endpoints | Define specific API routes with custom JSON responses. |
Fakers | Generate dynamic and realistic data using a variety of built-in functions. |
By using our platform, you can simulate complex API interactions and test your application’s behavior in different scenarios.
Hitting Endpoints
Once you've created your projects, collections, and endpoints, you're ready to interact with your mock APIs. This section will guide you through the process of hitting these endpoints and testing your JSON responses.
Each project is assigned a unique Base URL. This Base URL is the root of all your endpoints within the project. To access any endpoint, you will append the endpoint path to the Base URL.
For example, if your Base URL is https://mockapi.cc/api/81a77465-c194-4b3d-915b-3ec96bb0da14
and you've defined an endpoint with the path /users, you would access it by making a request to: https://mockapi.cc/api/81a77465-c194-4b3d-915b-3ec96bb0da14/users
Important
When you make a request to any of the endpoints, you must pass the X-Access-Token
header with the correct token of your project. You can obtain the access token from the project page.
Fake Schema
The Fake Schema is a powerful feature that allows you to define the structure of your JSON responses. You can create schemas that include static data, dynamic data using fakers, and even repeating items to simulate arrays of objects.
Repeating Items
In many cases, your API responses will need to include arrays of items (e.g., a list of users or products). Our platform allows you to easily define repeating items within your JSON schema. Postfix the JSON attribute with |repeat(n)
to define how many times this attribute should be repeated.
{
"name|repeat(2)": "John Doe"
}
This will produce the following result:
{
"name": ["John Doe", "John Doe"]
}
Or you may use the repeat attribute at the root level of your JSON.
{
"repeat(3)": {
"name": "John Doe"
}
}
Which will produce the following result:
[{ "name": "John Doe" }, { "name": "John Doe" }, { "name": "John Doe" }]
Fakers
Fakers are at the heart of our platform's ability to generate realistic and varied data. We support a wide range of faker functions that can be used within your JSON schema.
Predefined fakers must be surrounded by bracekets {}
to be used. Some of them accepts additional options which can be passed as {faker_name:option1,option2}
, for example {numberBetween:min,max}
For example, you can use the following schema to generate data using the predefined fakers:
{
"name": "{name}",
"emails|repeat(2)": "{email}",
"salary": "{numberBetween:10000,20000}"
}
Which will produce the following output:
{
"name": "Glenna Kuvalis",
"emails": ["[email protected]", "[email protected]"],
"salary": 15174
}
Below are the list of available fakers in the platform. Under the hood, we are utilizing PHP Faker library to generate fake data. You may refer to their docs for more detailed information.
Person
Faker Syntax | Parameters | Description |
---|---|---|
{title:gender} | gender (optional) | Generates a random name. If gender is provided, it specifies the gender. Possible values: male, female. If omitted, a random gender is chosen. |
{suffix} | Generates a random suffix commonly used in names. | |
{name:gender} | gender (optional) | Generates a random name. If gender is provided, it specifies the gender of the name. |
{firstName:gender} | gender (optional) | Generates a random first name. If gender is provided, it specifies the gender of the name. |
{lastName} | Generates a random last name. |
Address
Faker Syntax | Parameters | Description |
---|---|---|
{cityPrefix} | Generates a random city prefix, e.g., "New", "San". | |
{secondaryAddress} | Generates a random secondary address line, e.g., "Apt 5B", "Suite 300". | |
{state} | Generates a random state name, e.g., "California", "Texas". | |
{stateAbbr} | Generates a random state abbreviation, e.g., "CA", "TX". | |
{citySuffix} | Generates a random city suffix, e.g., "town", "ville". | |
{streetSuffix} | Generates a random street suffix, e.g., "St", "Ave". | |
{buildingNumber} | Generates a random building number, e.g., "123", "4567". | |
{city} | Generates a random city name, e.g., "Los Angeles", "Houston". | |
{streetName} | Generates a random street name, e.g., "Main St", "Elm St". | |
{streetAddress} | Generates a random street address, combining street name and building number, e.g., "123 Main St". | |
{postcode} | Generates a random postcode, e.g., "90210", "10001". | |
{address} | Generates a random full address, including street address, city, and postcode. | |
{country} | Generates a random country name, e.g., "United States", "Canada". | |
{latitude:min,max} | min , max (optional) | Generates a random latitude between min and max . Default range is -90 to 90 if omitted. |
{longitude:min,max} | min , max (optional) | Generates a random longitude between min and max . Default range is -180 to 180 if omitted. |
Phone
Faker Syntax | Parameters | Description |
---|---|---|
{phoneNumber} | None | Generates a random phone number, e.g., "+1-555-123-4567". |
{phoneNumberWithExtension} | None | Generates a random phone number with an extension, e.g., "+1-555-123-4567 x123". |
{tollFreePhoneNumber} | None | Generates a random toll-free phone number, e.g., "800-555-1234". |
{e164PhoneNumber} | None | Generates a phone number in E.164 format, e.g., "+15551234567". |
Company
Faker Syntax | Parameters | Description |
---|---|---|
{catchPhrase} | None | Generates a random catchphrase or slogan, e.g., "Innovate and dominate." |
{bs} | None | Generates a random business jargon phrase, e.g., "leverage agile methodologies." |
{company} | None | Generates a random company name, e.g., "Tech Innovations Inc." |
{companySuffix} | None | Generates a random company suffix, e.g., "Ltd", "LLC", "Inc" |
{jobTitle} | None | Generates a random job title, e.g., "Software Engineer", "Marketing Manager" |
Number
Faker Syntax | Parameters | Description |
---|---|---|
{randomDigit} | None | Generates a random single digit between 0 and 9, e.g., 7 |
{randomDigitNot:exception} | exception (optional) | Generates a random digit excluding the specified exception, e.g., 3 , excluding 7 |
{randomDigitNotNull} | None | Generates a random single digit from 1 to 9, excluding 0, e.g., 5 |
{randomNumber:nbDigits,strict} | nbDigits , strict (optional) | Generates a random integer, containing between 0 and nbDigits amount of digits. When the strict parameter is true it will only return integers with nbDigits amount of digits |
{randomFloat:nbMaxDecimals,min,max} | nbMaxDecimals , min , max (optional) | Generates a random floating-point number with up to nbMaxDecimals decimal places, between min and max . e.g., 12.345 . |
{numberBetween:min,max} | min , max (optional) | Generates a random number between min and max , by default an integer is generated between 0 and 2,147,483,647 |
Strings, Text, and Pragraphs
Faker Syntax | Parameters | Description |
---|---|---|
{randomLetter} | None | Generates a random character from the alphabet. |
{numerify:str} | str (optional) | Replaces # characters in str with random digits, e.g., "Order ###" becomes "Order 456" . |
{lexify:str} | str (optional) | Replaces ? characters in str with random letters, e.g., "Product ???" becomes "Product xyz" . |
{bothify:str} | str (optional) | Replaces # with random digits and ? with random letters in str , e.g., "Order #???" becomes "Order 45ab" . |
{asciify:str} | str (optional) | Generate a string where \* characters are replaced with a random character from the ASCII table. By default, \*\*\*\* is used as input. |
{regexify:str} | str (optional) | Generate a random string based on a regex. By default, an empty string is used as input. e.g., [A-Z]{5}[0-4]{3}} becomes CQVIU411 |
{word} | None | Generates a random word, e.g., "innovation" . |
{sentence:words} | words (optional) | Generates a random sentence with the specified number of words, e.g., "5" words becomes "This is a random sentence example" . |
{sentences:count} | count (optional) | Generates a random number of sentences, where count specifies the number of sentences |
{paragraph:sentences} | sentences (optional) | Generates a random paragraph with the specified number of sentences |
{paragraphs:count} | count (optional) | Generates a random number of paragraphs, where count specifies the number of paragraphs |
{text:chars} | chars (optional) | Generates a random string with the specified number of characters |
Date and Time
Faker Syntax | Parameters | Description |
---|---|---|
{unixTime} | None | Generates a random Unix timestamp, e.g., 1618923645 . |
{dateTime:max,timezone} | max (optional), timezone (optional) | Generates a random date and time. max specifies the maximum range of years. e.g., "YYYY-MM-DD" for "2024-08-12" , and timezone specifies the time zone. e.g., "2024-08-12 14:35:00" |
{iso8601:max} | max (optional) | Generates a random ISO 8601 date-time string. max specifies the maximum range of years. e.g., "YYYY-MM-DD" for "2024-08-12" |
{date:format:max} | format (optional), max (optional) | Generates a random date in the specified format. max specifies the maximum range of years. e.g., "YYYY-MM-DD" for "2024-08-12" . |
{time:format,max} | format (optional), max (optional) | Generates a random time in the specified format. max specifies the maximum range of years. e.g., "HH:mm:ss" for "14:35:00" . |
{dateTimeBetween:startDate,endDate,timezone} | startDate , endDate , timezone (optional) | Generates a random date and time between startDate and endDate . timezone specifies the time zone |
{dateTimeInInterval:date,interval,timezone} | date , interval , timezone (optional) | Generates a random date and time within a specified interval from date . interval specifies the length of the interval, e.g., "2024-08-12T00:00:00" , "+1 week" . |
{dateTimeThisCentury:max,timezone} | max (optional), timezone (optional) | Generates a random date and time within the current century. max specifies the maximum range of years, e.g., +8 years |
{dateTimeThisDecade:max,timezone} | max (optional), timezone (optional) | Generates a random date and time within the current decade. max specifies the maximum range of years, e.g., +8 years |
{dateTimeThisYear:max,timezone} | max (optional), timezone (optional) | Generates a random date and time within the current year. max specifies the maximum range of years, e.g., +1 months . |
{dateTimeThisMonth:max,timezone} | max (optional), timezone (optional) | Generates a random date and time within the current month. max specifies the maximum range of years, e.g., +2 days . |
{amPm:max} | max (optional) | Generates a random AM/PM indicator, e.g., "am" , "pm" . |
{dayOfMonth:max} | max (optional) | Generates a random day of the month, e.g., "15" . |
{dayOfWeek:max} | max (optional) | Generate a random DateTime , with a given upper bound, and return the day of week string value. By default, the upper bound is set to now |
{month:max} | max (optional) | Generate a random DateTime , with a given upper bound, and return the month's number string value. By default, the upper bound is set to now . |
{monthName:max} | max (optional) | Generate a random DateTime , with a given upper bound, and return the month's name string value. By default, the upper bound is set to now . |
{year:max} | max (optional) | Generates a random year, with a given upper bound, and return the year's string value. By default, the upper bound is set to now . |
{century} | None | Generates a random century, e.g., "21st century" . |
{timezone:countryCode} | countryCode (optional) | Generates a random timezone based on the countryCode , e.g., "US" for "America/New_York" . |
Internet
Faker Syntax | Parameters | Description |
---|---|---|
{email} | None | Generates a random email address, e.g., "[email protected]" . |
{safeEmail} | None | Generates a random, safe email address that is unlikely to be used by spammers, e.g., "[email protected]" . |
{freeEmail} | None | Generates a random email address from a common free email provider, e.g., "[email protected]" . |
{companyEmail} | None | Generates a random email address associated with a company, e.g., "[email protected]" . |
{freeEmailDomain} | None | Generates a random domain from a common free email provider, e.g., "gmail.com" . |
{safeEmailDomain} | None | Generates a random, safe email domain that is less likely to be used by spammers, e.g., "example.com" . |
{userName} | None | Generates a random username, e.g., "john_doe" . |
{password:minLength,maxLength} | minLength , maxLength (required) | Generates a random password with a length between minLength and maxLength , e.g., "a1B2c3D4" . |
{domainWord} | None | Generates a random word suitable for use in a domain name, e.g., "example" . |
{tld} | None | Generates a random top-level domain (TLD), e.g., "com" , "org" . |
{url} | None | Generates a random URL, e.g., "https://www.example.com" . |
{slug:nbWords,variableNbWords} | nbWords , variableNbWords (optional) | Generates a random slug with nbWords words, by default it is 6. Optionally, a second parameter can be supplied. When false, only slugs with the given amount of words will be generated |
{ipv4} | None | Generates a random IPv4 address, e.g., "192.168.0.1" . |
{localIpv4} | None | Generates a random local IPv4 address, e.g., "10.0.0.1" . |
{ipv6} | None | Generates a random IPv6 address, e.g., "2001:0db8:85a3:0000:0000:8a2e:0370:7334" . |
{macAddress} | None | Generates a random MAC address, e.g., "00:1A:2B:3C:4D:5E" . |
User Agents
Faker Syntax | Parameters | Description |
---|---|---|
{userAgent} | None | Generates a random user agent string, e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" . |
{chrome} | None | Generates a random user agent string for Chrome, e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" . |
{firefox} | None | Generates a random user agent string for Firefox, e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0" . |
{safari} | None | Generates a random user agent string for Safari, e.g., "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:14.1) Gecko/20100101 Firefox/92.0" . |
{opera} | None | Generates a random user agent string for Opera, e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 OPR/77.0.4054.146" . |
{internetExplorer} | None | Generates a random user agent string for Internet Explorer, e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Trident/7.0; AS; rv:11.0) like Gecko" |
{msedge} | None | Generates a random user agent string for Microsoft Edge, e.g., "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.48" |
Payment
Faker Syntax | Parameters | Description |
---|---|---|
{creditCardNumber:type,formatted,seperator} | type (optional), formatted (optional), seperator (optional) | Generates a random credit card number. type specifies the card type (e.g., Visa , MasterCard ). formatted indicates if the number should be formatted (e.g., "1234-5678-9012-3456" ). seperator specifies the character used to separate groups of digits (e.g., - ). |
{creditCardExpirationDate:valid} | valid (optional) | Generates a random credit card expiration date. If valid is set to true, only valid expiration dates are generated. |
{creditCardExpirationDateString:valid,expirationDateFormat} | valid (optional), expirationDateFormat (optional) | Generates a random credit card expiration date with the specified expirationDateFormat . If valid is set to true, only valid expiration dates are generated. |
{creditCardDetails:valid} | valid (optional) | Generates a random credit card details object, including the number, expiration date, and card type, e.g., { "number": "4111111111111111", "expiry": "08/2025", "type": "Visa" } . |
{iban:countryCode} | countryCode (required) | Generates a random IBAN for the specified countryCode , e.g., "DE89370400440532013000" for Germany. |
{swiftBicNumber} | None | Generates a random SWIFT/BIC number, e.g., "DEUTDEFF" for Deutsche Bank. |
Color
Faker Syntax | Parameters | Description |
---|---|---|
{hexColor} | None | Generates a random hexadecimal color code, e.g., "#A3C1AD" . |
{safeHexColor} | None | Generates a random hexadecimal color code from a safe set of colors, e.g., "#FF5733" . |
{rgbColorAsArray} | None | Generates a random RGB color as an array, e.g., [255, 87, 51] . |
{rgbColor} | None | Generates a random RGB color as a string, e.g., "rgb(255, 87, 51)" . |
{rgbCssColor} | None | Generates a random RGB color in CSS format, e.g., "rgb(255, 87, 51)" . |
{rgbaCssColor} | None | Generates a random RGBA color in CSS format, with alpha transparency, e.g., "rgba(255, 87, 51, 0.8)" . |
{safeColorName} | None | Generates a random color name from a predefined set of safe color names, e.g., "SkyBlue" . |
{colorName} | None | Generates a random color name, e.g., "Crimson" . |
{hslColor} | None | Generates a random HSL color as a string, e.g., "hsl(120, 50%, 50%)" . |
{hslColorAsArray} | None | Generates a random HSL color as an array, e.g., [120, 50%, 50%] . |
File
Faker Syntax | Parameters | Description |
---|---|---|
{mimeType} | None | Generates a random MIME type, e.g., "image/jpeg" , "application/json" . |
{fileExtension} | None | Generates a random file extension, e.g., ".jpg" , ".json" . |
UUID
Faker Syntax | Parameters | Description |
---|---|---|
{uuid} | None | Generates a random UUID (Universally Unique Identifier), e.g., "123e4567-e89b-12d3-a456-426614174000" . |
Barcode
Faker Syntax | Parameters | Description |
---|---|---|
{ean13} | None | Generates a random 13-digit EAN (European Article Number), e.g., "1234567890123" . |
{ean8} | None | Generates a random 8-digit EAN (European Article Number), e.g., "12345678" . |
{isbn10} | None | Generates a random 10-digit ISBN (International Standard Book Number), e.g., "0471958697" . |
{isbn13} | None | Generates a random 13-digit ISBN (International Standard Book Number), e.g., "978-0471958697" . |
Miscellaneous
Faker Syntax | Parameters | Description |
---|---|---|
{boolean} | None | Generates a random boolean value, e.g., true or false . |
{md5} | None | Generates a random MD5 hash, e.g., "d41d8cd98f00b204e9800998ecf8427e" . |
{sha1} | None | Generates a random SHA-1 hash, e.g., "5baa61e4c9b93f3f0682250b6cf8331b8f6d1d5f" . |
{sha256} | None | Generates a random SHA-256 hash, e.g., "9c56dd593006ed3212b59e6b4a1d1d37a2c4d8cce06f0947a1d9d7b3d1690c9b" . |
{locale} | None | Generates a random locale code, e.g., "en_US" , "fr_FR" . |
{countryCode} | None | Generates a random country code, e.g., "US" , "FR" . |
{countryISOAlpha3} | None | Generates a random 3-letter ISO country code, e.g., "USA" , "FRA" . |
{languageCode} | None | Generates a random language code, e.g., "en" , "fr" . |
{currencyCode} | None | Generates a random currency code, e.g., "USD" , "EUR" . |
{emoji} | None | Generates a random emoji, e.g., "😊" , "🚀" . |
HTML
Faker Syntax | Parameters | Description |
---|---|---|
{randomHtml:maxDepth,maxWidth} | maxDepth (optional), maxWidth (optional) | Generates random HTML content. maxDepth controls the maximum depth of nested HTML elements, and maxWidth controls the maximum width of content within the HTML elements, e.g., <div><p>Sample text</p></div> . |
Version
Faker Syntax | Parameters | Description |
---|---|---|
{semver} | None | Generates a random semantic versioning string, e.g., "1.0.0" , "2.1.3" . |