Links between IPython notebooks

From http://python.6.n6.nabble.com/where-is-the-code-to-generate-IPython-Notebook-URL-for-a-new-ipynb-file-td4996991.html:

You can access a json version of all the notebooks from url: $host/notebooks

Here is a snippet that worked for me:

    import urllib2
    import json
    data = urllib2.urlopen("http://127.0.0.1:8888/notebooks")
    json_data=data.read()
    list_o_dicts=json.loads(json_data)
    for d in list_o_dicts:
        if d['name'] == 'test':
            print d['notebook_id']

Modify this according to your need.

** on further reading, I just realized OP was also seeking new notebook creation, keeping my answer anyway as way to work with linking existing notebooks.

One way to try for OP's goal is to run a script which will create a new notebook.ipynb file into the ipython folder where ipython notebook was started from. That .ipynb file can be templated from a new ipython notebook created from dashboard, with the name and id of the notebook replaced with whatever you are trying to link from your existing notebook. I have not tried this, but should work since dropping a .ipynb extension file into ipython folder does show it up in the dashboard.


Since IPython 2 you may use exactly the syntax you first tried:

Link to [Notebook 2](notebook2.ipynb)

It is now possible to do this with Ipython 1.0+ at least.

Just do: localhost:8888/My Notebook.ipynb

Here is the documentation for this feature. https://github.com/ipython/ipython/pull/3058

Tags:

Python

Ipython