Jupyter Notebooks Instance
Jupyter Notebooks
Plotly allows the user to upload their Jupyter Notebooks to the Plotly Server. The notebooks appear in the user's profile, and can be shared with others just like Plotly Plots.
Reference
Authorization
Any user with or without a Plotly account may view public Jupyter Notebooks. For private files, see authentication.
Actions
upload
A Jupyter Notebook may be uploaded by making a POST request to the upload endpoint with the file contents as the request body:
POST https://api.plotly.com/v2/jupyter-notebooks/upload
The following options may be passed as HTTP headers to control the upload.
-
X-File-Name: gives the filename of the Notebook being uploaded.
-
Plotly-World-Readable: controls the visibility of the created notebook. May be
true
orfalse
. Defaults tofalse
. -
Plotly-Parent: gives the parent folder id.
-
Plotly-Parent-Path: gives the path to the parent folder.
retrieve
A Single Notebook can be retrieved by a GET Request to the
jupyter-notebooks
endpoint.
Example:
// GET https://api.plotly.com/v2/jupyter-notebooks/username:123
html
The rendered HTML content of a notebook can be retrieved by a GET request to
the jupyter-notebooks
endpoint including html
.
Example:
// GET https://api.plotly.com/v2/jupyter-notebooks/username:123/html
update
To completely replace the writable meta information of an existing notebook,
you make a PUT request to the jupyter-notebooks
endpoint and include
the fid for the notebook.
Note, only the writable meta information may be updated.
This includes filename
,parent
(or parent_path
),
world_readable
, and content
.
Note that parent_path
may be specified in place of the parent
field.
Unlike parent
, the parent_path
field is not an integer id, but rather
the complete path of the parent folder from your root folder
(e.g., '/folder_nested_off_root/parent_folder/'
).
A successful PUT response will have a status code of 200 OK.
Example:
// PUT https://api.plotly.com/v2/jupyter-notebooks/bob:45 --> 200 OK
{
"parent": -1,
"world_readable": true,
"filename": "my_new_filename",
}
partial update
To partially update an existing notebook, you make a PATCH request to the
jupyter-notebooks
endpoint and include the
fid for the notebook.
Note, only the writable meta information may be updated.
This includes filename
, parent
(or parent_path
), world_readable
,
and content
.
A successful PATCH response will have a status code of 200 OK.
Example:
// PATCH https://api.plotly.com/v2/jupyter-notebooks/bob:45 --> 200 OK
{
"world_readable": true,
"filename": "my_new_filename"
}
trash
This endpoint allows for the recoverable trashing of the notebook specified in the endpoint detail.
A successful trash response will have a status code of 200 OK.
Example:
// POST https://api.plotly.com/v2/jupyter-notebooks/plotlvr:9/trash ---> 200 OK
This request is idempotent. Trashing a notebook that is already trashed will also succeed and return 200 OK.
permanent_delete
This endpoint allows for the permanent deletion of the notebook specified in the endpoint detail.
A successful deletion response will have a status code of 204 No Content.
Example:
// DELETE https://api.plotly.com/v2/jupyter-notebooks/plotlvr:9/permanent_delete ---> 204 No Content
external
Given an external ?source
url, this endpoint makes a GET request to
retrieve notebook content. Upon success of the request, the content is
parsed to enforce that the content is a valid jupyter notebook and the HTML
content is returned.
The source must include the scheme (e.g., https) and must point to a
resource that returns a jupyter notebook as its content directly; e.g.,
using /raw
for github resources.
Example:
// GET https://api.plotly.com/v2/jupyter-notebooks/external?source=https%3A%2F%2Fgist.github.com%2Fbob%2Fc2e63539ea200ae0d8ee%2Fraw
GET /v2/jupyter-notebooks/colamas:14/?format=api
https://chart-studio.plotly.com/~colamas/14.embed", "fid": "colamas:14", "filename": "scatter3d.ipynb", "filetype": "jupyter_notebook", "img_url": "", "image_urls": {}, "api_urls": { "files": "https://api.plotly.com/v2/files/colamas:14", "jupyter-notebooks": "https://api.plotly.com/v2/jupyter-notebooks/colamas:14", "parent": "https://api.plotly.com/v2/folders/home?user=colamas" }, "owner": "colamas", "parent": -1, "preview": "", "referencers": [], "references": [], "title": "3D scatterplot\n\n\nDemonstration of a basi", "views": 12, "web_url": "https://chart-studio.plotly.com/~colamas/14/_3d-scatterplot-demonstration-of-a-basi/", "world_readable": true, "date_modified": "2019-05-27T03:33:47.726Z", "stars": { "results": [], "count": 0 }, "collaborators": { "results": [], "count": 0 }, "subfolder_count": null, "refresh_interval": null, "organize_view_url": "https://chart-studio.plotly.com/~colamas/14/", "current_user_permission": "read", "is_theme": null, "is_template": null, "content": "{\"cells\": [{\"source\": [\"%matplotlib inline\"], \"outputs\": [], \"metadata\": {\"collapsed\": false}, \"cell_type\": \"code\", \"execution_count\": null}, {\"source\": [\"\\n# 3D scatterplot\\n\\n\\nDemonstration of a basic scatterplot in 3D.\\n\\n\"], \"metadata\": {}, \"cell_type\": \"markdown\"}, {\"source\": [\"from mpl_toolkits.mplot3d import Axes3D\\nimport matplotlib.pyplot as plt\\nimport numpy as np\\n\\n# Fixing random state for reproducibility\\nnp.random.seed(19680801)\\n\\n\\ndef randrange(n, vmin, vmax):\\n '''\\n Helper function to make an array of random numbers having shape (n, )\\n with each number distributed Uniform(vmin, vmax).\\n '''\\n return (vmax - vmin)*np.random.rand(n) + vmin\\n\\nfig = plt.figure()\\nax = fig.add_subplot(111, projection='3d')\\n\\nn = 100\\n\\n# For each set of style and range settings, plot n random points in the box\\n# defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].\\nfor c, m, zlow, zhigh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:\\n xs = randrange(n, 23, 32)\\n ys = randrange(n, 0, 100)\\n zs = randrange(n, zlow, zhigh)\\n ax.scatter(xs, ys, zs, c=c, marker=m)\\n\\nax.set_xlabel('X Label')\\nax.set_ylabel('Y Label')\\nax.set_zlabel('Z Label')\\n\\nplt.show()\"], \"outputs\": [], \"metadata\": {\"collapsed\": false}, \"cell_type\": \"code\", \"execution_count\": null}], \"metadata\": {\"kernelspec\": {\"name\": \"python3\", \"language\": \"python\", \"display_name\": \"Python 3\"}, \"language_info\": {\"name\": \"python\", \"version\": \"3.6.3\", \"mimetype\": \"text/x-python\", \"file_extension\": \".py\", \"pygments_lexer\": \"ipython3\", \"codemirror_mode\": {\"name\": \"ipython\", \"version\": 3}, \"nbconvert_exporter\": \"python\"}}, \"nbformat\": 4, \"nbformat_minor\": 0}" }{ "creation_time": "2019-05-27T03:33:47.726287Z", "comments": { "results": [], "count": 0 }, "parented": true, "embed_url": "