> For the complete documentation index, see [llms.txt](https://builtwithluv.gitbook.io/mockit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://builtwithluv.gitbook.io/mockit/apis.md).

# APIs

You can modify the internal state of your server by using some of mockit's built-in APIs.

## Get state of server

<mark style="color:blue;">`GET`</mark> `http://localhost:3000/mockit/api`

Gets the internal state of your mock server.

{% tabs %}
{% tab title="200 State successfully retrieved." %}

```javascript
{
    activeFixtures, // Object containing information about active fixtures
    fixtures, // Array of all fixtures found
    latency // The time in ms to wait before sending response  
}
```

{% endtab %}
{% endtabs %}

## Modify state of server

<mark style="color:orange;">`PUT`</mark> `http://localhost:3000/mockit/api`

Makes updates to the internal state of the server

#### Headers

| Name         | Type   | Description      |
| ------------ | ------ | ---------------- |
| Content-Type | object | application/json |

#### Request Body

| Name     | Type   | Description                                                                          |
| -------- | ------ | ------------------------------------------------------------------------------------ |
| throttle | string | 3G, 4G, WiFi, Disabled                                                               |
| latency  | number | When it is set, it will set the server response time to the new latency value.       |
| id       | string | The id of a fixture. When it is set, it will set the fixture with that id as active. |

{% tabs %}
{% tab title="200 The internal state of the server." %}

```javascript
{
    activeFixtures,
    fixtures,
    latency
}
```

{% endtab %}
{% endtabs %}

## Adds a new fixture

<mark style="color:green;">`POST`</mark> `http://localhost:3000/mockit/api/new`

Creates a new fixture

#### Request Body

| Name        | Type   | Description                    |
| ----------- | ------ | ------------------------------ |
| data        | object | The response data  of the API  |
| status      | string | The status of the API          |
| method      | string | The method of the API          |
| description | string | The description of the fixture |
| id          | string | The id of the fixture          |
| url         | string | The endpoint of the API        |

{% tabs %}
{% tab title="200 The internal state of the server" %}

```javascript
{
    activeFixtures,
    fixtures,
    latency
}
```

{% endtab %}

{% tab title="400 Most likely it failed to create fixture" %}

```
Error
```

{% endtab %}
{% endtabs %}

## Server state reset

<mark style="color:orange;">`PUT`</mark> `http://localhost:3000/mockit/api/reset`

Resets server state back to when it first started

{% tabs %}
{% tab title="200 " %}

```javascript
{
    activeFixtures,
    fixtures,
    latency
}
```

{% endtab %}
{% endtabs %}
