# REST API for executing cells in a notebook

**URL:** <https://discourse.jupyter.org/t/rest-api-for-executing-cells-in-a-notebook/21346>\
**Category:** JupyterLab\
**Tags:** jupyterlab, how-to, help-wanted\
**Created:** [September 10, 2023, 1:12pm UTC](https://discourse.jupyter.org/t/rest-api-for-executing-cells-in-a-notebook/21346 "2023-09-10T13:12:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [September 11, 2023, 1:13pm UTC](https://discourse.jupyter.org/t/rest-api-for-executing-cells-in-a-notebook/21346/4 "2023-09-11T13:13:44Z")

</div>

At the protocol level, a kernel doesn’t know anything about a notebook document. The exceptions:

- the kernel process is started with the `cwd` of the folder holding the notebook
- _some_ clients provide the `cellId` in the metadata of _some_ requests, and _some_ kernels do something with it
- but as metadata, this is not propagated back on replies from the kernel

So without a full client in the loop, your custom client would need to:

- parse the document itself
- find all the code cells
- punch them into the kernel
- remember which cell goes with which message id
- put them into the correct place
- write back to the contents manager

_With_ a standard client in the loop, this becomes… a lot more complicated, as the state of the truth of the document can become out-of-sync.

There has been discussion on `jupyter_server` of some this… perhaps the [Thursday call](https://discourse.jupyter.org/t/jupyter-community-calendar/2485) would be a space to raise more of these concerns and questions.

---

_[View the full topic](https://discourse.jupyter.org/t/rest-api-for-executing-cells-in-a-notebook/21346)._
