> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mock API Usage

> Enables using Mock API in the Apinizer Platform. You can simulate the behavior of a real API, return different responses based on conditions, and create APIs for testing and development purposes without coding.

Mock API enables simulating the behavior of a real API. When you make an HTTP call to a method you created without any software development, a previously specified response is returned.

This content explains, in order, creating a blank Mock API, returning responses based on conditions from methods, and creating, deploying, and testing the API as an API Proxy.

<Note>
  Thanks to conditions added to the response, Apinizer enables **receiving different responses based on conditions** depending on header, body, or parameter values of the request.
</Note>

## 1. Creating Mock API

An API is to be created to manage employee records.

Since method and response information for the API will be created through the interface instead of an API definition document, **Blank** is selected as the **type**.

By default, the feature to create methods for the API's CRUD operations is enabled.

Fill in the Mock API name and description fields, then click the **Save and Next** button.

**The image below shows Mock API settings:**

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/01-mock-api-settings.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=0e4717f11445728f9099740ec7f7aea4" alt="Mock API Settings" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/01-mock-api-settings.png" />

When Mock API is created, API and method information appears on the left, and the definition information of the selected method appears on the right.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/02-mock-api-created.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=6f8836b1b297d92d51be76927a46ad3f" alt="Mock API Created" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/02-mock-api-created.png" />

## 2. Returning Different Responses Based on Conditions

When a request is sent to the relevant method by default (without defining any condition), it is intended to return a successful status code and the list of all employees as a response.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/03-default-response.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=6f539eb20d7c67d802795f3e158f9ddd" alt="Default Response Settings" width="600" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/03-default-response.png" />

The following condition is created to return only this employee's information when the value of the **username** header is **dwight**.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/04-conditional-response.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=93ba2afd91ead32cb744980dc1c97d4b" alt="Conditional Response Settings" width="600" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/04-conditional-response.png" />

## 3. Viewing API Definition Documents

Click the **Show Specs** link to access the API definition files for Employee Mock API.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/05-show-specs.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=fd8a0a0fa6522f90f7ba63399efbd99f" alt="Show Specs" width="1000" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/05-show-specs.png" />

**The image below shows the Spec Information dialog:**

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/06-spec-info.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=d7638b5b6ccb2e124237353e06a27788" alt="Spec Information" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/06-spec-info.png" />

## 4. Creating API Proxy

You can instantly create an API Proxy by clicking the **Create API Proxy** button from the Mock API screen.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/07-create-api-proxy.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=fdfacb1497a0d74df8bbf15816b7a034" alt="Create API Proxy" width="1000" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/07-create-api-proxy.png" />

When creating the API Proxy, fill in the input fields shown in the image below and click the **Save** button.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/08-api-proxy-creation-form.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=0f7fde1332b8156b7d740fb0767b2cb5" alt="API Proxy Creation Form" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/08-api-proxy-creation-form.png" />

### 4.1 Deploying the API Proxy

Employee API Proxy can be quickly deployed to a defined environment and made available for client consumption.

This operation can be managed through the dialog opened by the **Deploy** button on the API Proxy screen.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/09-deploy-dialog.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=e5eb50230aedecf5f7328a32bc5b56d0" alt="Deploy Dialog" width="1000" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/09-deploy-dialog.png" />

This operation can also be managed from the Mock API screen via the **Manage API Proxies** link.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/10-manage-api-proxies.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=ac2953d0d41eff72624935580123090a" alt="Manage API Proxies" width="1000" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/10-manage-api-proxies.png" />

## 5. Testing

When sent without adding the parameters expected by the relevant method as a condition, the following response body listing all employees is returned.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/11-test-result-default.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=e0529df9cd52dfee98791f50e5dbe762" alt="Default Response Test Result" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/11-test-result-default.png" />

When the parameters expected by the relevant method as a condition are added to the request and executed, the following customized response is returned.

<img src="https://mintcdn.com/apinizer/MXUcToqbAreZkG5b/images/tutorials/api-olusturucu-senaryolari/mock-api/12-test-result-conditional.png?fit=max&auto=format&n=MXUcToqbAreZkG5b&q=85&s=d2f6e7f83e2b6929e479cb028ee95096" alt="Conditional Response Test Result" width="800" data-path="images/tutorials/api-olusturucu-senaryolari/mock-api/12-test-result-conditional.png" />
