# 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;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://olab4.gitbook.io/help/advanced-topics/script-objects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
