14

I've read the docs about writing the Jupyter front-end extensions, and learn the examples, and now can build the simple extension by myself.

But - where is a complete docs for Jupyter extensions JavaScript API? How to find the JavaScript API for notebook properties and methods?

Y.N
  • 4,989
  • 7
  • 34
  • 61

3 Answers3

9

This answer is outdated. Also see my answer below.

This might not be the answer you hoped for. However, it might help some readers being new to JavaScript development.

I also was looking for documentation on the Jupyter (-Notebook) client API and could not find official docs.

The JavaScript source code can be found on the GitHub repository, for example:

What also helped was to

A. Use Google Chrome development tools, set a break point in the extension and type

Jupyter 

in the console. Then you get a browsable tree structure that can be used to inspect the Jupyter object. That tree structure does not seem to contain methods.

B. Log all the properties of an object, including the methods. If you want to know about the methods of the notebook use for example

for(var property in Jupyter.notebook){ console.log(property)}

C. When typing in the console there is code completion. For example you might want to type

Jupyter.notebook.

and see the suggestions on how to complete the command:

enter image description here

Also see

Browsable tree structure in dev tools console:

enter image description here

How to list properties including methods:

enter image description here

...

enter image description here

Stefan
  • 10,010
  • 7
  • 61
  • 117
  • 1
    And here is some example code in my project that uses the jupyter notebook: https://github.com/stefaneidelloth/treezjs/blob/master/src/jupyterTerminal.js – Stefan May 10 '19 at 11:04
  • Updated links that demonstrate API usage: **JupyterNotebook**: https://github.com/stefaneidelloth/treezjs/blob/master/jupyter_notebook_extension/jupyterTerminal.js **JupyterLab**: https://github.com/stefaneidelloth/treezjs/blob/master/jupyter_lab_extension/jupyterLabTerminal.js – Stefan Jul 06 '21 at 22:40
  • I'm not able to access the `Jupyter` variable in Javascript (either in Chrome's console or using ipythons `%%javascript` tag). Any pointers how to get access to it ? Thanks! – Jan Mar 25 '23 at 08:53
  • This old answer was related to JupyterNotebook and I guess you use JupyterLab? – Stefan Mar 25 '23 at 15:12
3

For newcomers it might be confusing that there are several projects with similar names for historical reasons:

a) Jupyter
https://github.com/jupyter

b) JupyterLab
https://github.com/jupyterlab/

c) The official webpage
https://jupyter.org/
references the newer b).
However, the sub projects of a) do not include deprecation warnings.

=> If you find some documentation via search engine, you have to be careful if its related to a) or b).

Current documentation for JupyterLab extensions can be found here:

Related:

https://www.quora.com/What-is-the-difference-between-JupyterLab-and-Jupyter-Notebook-Is-there-a-use-case-for-one-over-the-other?share=1

https://github.com/jupyterlab/jupyterlab-plugin-playground

Stefan
  • 10,010
  • 7
  • 61
  • 117
2

Apparently, there are is no front-end API documentation, as there is an open GitHub issue that even references your SO question. Maybe a few +1s on the issue might change this, although I suspect that the answer (if any) will point to JupyterLab, which has a defined front-end API but has no common technical base with Jupyter Notebook front-end extensions.

Bernhard Stadler
  • 1,725
  • 14
  • 24