# Get Started with the Cookbook

Before downloading your first script, do the following actions:

* Familiarize yourself with the API Cookbook prerequisites and key concepts found in [development-prerequisites](https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/getting-started-with-api/development-prerequisites "mention") and [rest-general-concepts](https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/rest/rest-general-concepts "mention").
* Use a non-production server for script development.
* Familiarize yourself with the coding language.
* Use the GLSRestApiUtils file to assist with recipe development.
* Review [tips-and-troubleshooting](https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/cookbook/get-started-with-the-cookbook/tips-and-troubleshooting "mention").

### Script Development with a Non-Production Server

The example script recipes really come to life when you change them and see what happens. Running the scripts often requires new custom fields and master steps to be added to the system. You need unrestricted access to development and test servers (licensed as non-production servers) with Groovy (a coding language). You also need an AI node/automation worker installed so that you can experiment freely.

For more information and recommendations for deploying and copying scripts in development, test, and product environments, refer to [useful-tools](https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/application-examples/resources-and-references/useful-tools "mention").

### Script Types

#### **Groovy**

The Cookbook Recipe Examples are written in Groovy. Many of our examples use the following Groovy concepts:

* **Closures:** Groovy closures are essentially blocks of code that can be stored for later use.
* **The each method:** The each method takes a closure as an argument. It then iterates through each element in a collection, performing the closure on the element, which is (by default) stored in the 'it' variable.\
  \
  For example:

  ```
  outputNodes.each {
      GLSRestApiUtils.setUdfValue(it, 'Library Size', '25')
  }
  ```

**Python**

The Cookbook also provides a few examples written in Python, which uses the minidom module. The following script shows how the minidom module is used:

```
dom = parseString(pXML)
elementList = dom.getElementsByTagName("udf:field")
for element in elementList:
    name = element.getAttribute("name")
    if name == udfName:
        udf = api.getInnerXml(element.toxml(), "udf:field")
```

This same functionality can be obtained using any programming language capable of interacting with the Web API. For more information on the minidom module, refer to Python Minidom.

### Use GLSRestApiUtils <a href="#glsrest" id="glsrest"></a>

In addition to the Groovy file example attached to each Cookbook recipe page, most recipes require the glsapiutil.py file, which is available on our GitHub repository. The mature glsapiutil.py library is strictly for Python 2. A newer version, glsapiutil3.py, works with Python 3.

For more information on these files, see [obtain-and-use-the-rest-api-utility-classes](https://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/cookbook/get-started-with-the-cookbook/obtain-and-use-the-rest-api-utility-classes "mention").


---

# 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://help.connected.illumina.com/clarity-lims/api-and-database/api-docs/cookbook/get-started-with-the-cookbook.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.
