> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook.md).

# Notebook

## *class* <mark style="color:purple;">Notebook</mark>

Notebooks provide a flexible, programmatic environment for analysis within a [workflow](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow.md), in Python, R, Stata, or SAS. Various methods allow you to run and stop notebooks, and to reference their source and output tables.

{% hint style="info" %}
Notebooks are created and edited on Redivis. Unlike the Python and R clients, this library doesn't run within Redivis notebooks, so it doesn't include notebook-specific functionality such as `current_notebook()` or `create_output_table()`.
{% endhint %}

## Constructors

| Method                                                                                                                                               | Description                                                                                                                                                                                                       |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**`redivis.notebook`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/redivis/redivis.notebook.md)(name\[, options])           | Return a Notebook within the [default workflow](https://docs.redivis.com/api/client-libraries/redivis-js/reference.md#environment-variables), or given its fully qualified reference (`owner.workflow.notebook`). |
| [**`Workflow.notebook`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.notebook.md)(name)                    | Return a Notebook within a specific [workflow](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow.md).                                                                                   |
| [**`Workflow.listNotebooks`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.listnotebooks.md)(\[maxResults]) | List the Notebooks of a workflow.                                                                                                                                                                                 |

## Examples

```javascript
const notebook = redivis.workflow('jane.my_workflow').notebook('my_notebook');

// Run the notebook, waiting for it to finish
await notebook.run();

const outputTable = await notebook.outputTable();
const rows = await outputTable.toRowsArray();
```

## Attributes

| Name                     | Description                                                                                                                                                                                                                         |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`**               | The notebook's name.                                                                                                                                                                                                                |
| **`workflow`**           | The [Workflow](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow.md) that the notebook belongs to.                                                                                                        |
| **`properties`**         | An object containing the [API resource representation of the notebook](https://docs.redivis.com/api/resource-definitions/notebook.md). This will only be populated after certain methods are called, particularly the `get` method. |
| **`qualifiedReference`** | The [fully qualified reference](https://docs.redivis.com/api/referencing-resources.md) to the notebook.                                                                                                                             |
| **`scopedReference`**    | The canonical reference for the notebook, without its workflow.                                                                                                                                                                     |

## Methods

| Method                                                                                                                                        | Description                                                                                                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| [**`Notebook.exists`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.exists.md)()                     | Check whether the notebook exists.                                                                                              |
| [**`Notebook.get`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.get.md)()                           | Fetch the notebook's metadata, populating `notebook.properties`.                                                                |
| [**`Notebook.outputTable`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.outputtable.md)()           | Return the notebook's output [Table](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md).              |
| [**`Notebook.referencedTables`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.referencedtables.md)() | Return every [Table](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md) that the notebook references. |
| [**`Notebook.run`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.run.md)(\[options])                 | Run the notebook.                                                                                                               |
| [**`Notebook.sourceTable`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.sourcetable.md)()           | Return the notebook's source [Table](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md).              |
| [**`Notebook.stop`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.stop.md)()                         | Stop the notebook's current run.                                                                                                |
| [**`Notebook.update`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook/notebook.update.md)(options)              | Update the notebook's name or source table.                                                                                     |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
