> For the complete documentation index, see [llms.txt](https://olab4.gitbook.io/help/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olab4.gitbook.io/help/advanced-topics/script-objects.md).

# Script Objects

{% hint style="warning" %}
This whole section needs to be done
{% endhint %}

Rather than recreate the Rules and parser that we had in OLab3, we have instead decided to create an API that can be accessed via Javascript. This opens up a whole range of possibilities. It also means that authors are no longer limited by the simplistic parsing engine but can take greater advantage of what Javascript offers.&#x20;

Scripts can be standalone but have much more utility when they can interface with other objects within the OLab4 core, via the REST API. &#x20;

### Script API

{% hint style="warning" %}
List here the objects that can be manipulated
{% endhint %}

## Get Cakes

<mark style="color:blue;">`GET`</mark> `https://api.cakes.com/v1/cakes/:id`

This endpoint allows you to get free cakes.

#### Path Parameters

| Name | Type   | Description                                |
| ---- | ------ | ------------------------------------------ |
| id   | string | ID of the cake to get, for free of course. |

#### Query Parameters

| Name   | Type    | Description                                                           |
| ------ | ------- | --------------------------------------------------------------------- |
| recipe | string  | The API will do its best to find a cake matching the provided recipe. |
| gluten | boolean | Whether the cake should be gluten-free or not.                        |

#### Headers

| Name           | Type   | Description                                                    |
| -------------- | ------ | -------------------------------------------------------------- |
| Authentication | string | Authentication token to track down who is emptying our stocks. |

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

```javascript
{
    "name": "Cake's name",
    "recipe": "Cake's recipe name",
    "cake": "Binary cake"
}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```javascript
{
    "message": "Ain't no cake like that."
}
```

{% endtab %}
{% endtabs %}

### Script Examples

{% hint style="warning" %}
insert some examples, well commented, showing how&#x20;
{% endhint %}

### Scripts as Scoped Objects

As noted in the section on Object, Scripts can also be Scoped Objects. They can have the same scope levels e.g. global, server, map and node-level. See [#scopeforobjects](https://olab4.gitbook.io/help/basic-topics/objects#scope_for_objects) for more details on this.&#x20;
