Skip to main content

Notebook

View as Markdown

ObjectInfo object

The information of the object in workspace. It will be returned by list and get-status.

object_typestring

The type of the object in workspace.

  • NOTEBOOK: document that contains runnable code, visualizations, and explanatory text.
  • DIRECTORY: directory
  • LIBRARY: library
  • FILE: file
  • REPO: repository
  • DASHBOARD: Lakeview dashboard

Values: OBJECT_TYPE_UNSPECIFIED, NOTEBOOK, DIRECTORY, LIBRARY, FILE, REPO, DASHBOARD

pathstring

The absolute path of the object.

languagestring

The language of the object. This value is set only if the object type is NOTEBOOK. For Jupyter (.ipynb) notebooks, this is always PYTHON.

Values: SCALA, PYTHON, SQL, R

created_atint64

Only applicable to files. The creation UTC timestamp.

modified_atint64

Only applicable to files, the last modified UTC timestamp.

object_idint64

Unique identifier for the object.

sizeint64

Only applicable to files. The file size in bytes can be returned.

resource_idstring

A unique identifier for the object that is consistent across all Databricks APIs.

directory_infoobjectBeta

Additional metadata about the directory. Only set for objects of type DIRECTORY.

Show child attributesHide child attributes
is_git_folderbooleanBeta

Whether the directory is a Git folder, whose contents are version-controlled by a remote Git repository. How a Git folder is represented depends on whether it has Git CLI access:

  • A Git folder with Git CLI access has an object type of DIRECTORY, with this field set to true.
  • A standard Git folder, which does not have Git CLI access, has an object type of REPO and does not include this field.
  • A directory that is not Git-backed has this field set to false.

Use this field together with object_type to identify every Git folder in a workspace.

Get GA

GET /api/2.0/workspace/get-status

Gets the status of an object or a directory. If path does not exist, this call returns an error RESOURCE_DOES_NOT_EXIST.

API scopes: workspace

Parameters

pathstringquery

The absolute path of the notebook or directory.

Response

Returns the ObjectInfo object.

List GA

GET /api/2.0/workspace/list

Lists the contents of a directory, or the object if it is not a directory. If the input path does not exist, this call returns an error RESOURCE_DOES_NOT_EXIST.

API scopes: workspace

Parameters

pathstringquery

The absolute path of the notebook or directory.

notebooks_modified_afterint64query

UTC timestamp in milliseconds

Response

Returns a list of ObjectInfo objects.

Create GA

POST /api/2.0/workspace/import

Imports a workspace object (for example, a notebook or file) or the contents of an entire directory. If path already exists and overwrite is set to false, this call returns an error RESOURCE_ALREADY_EXISTS. To import a directory, you can use either the DBC format or the SOURCE format with the language field unset. To import a single file as SOURCE, you must set the language field. Zip files within directories are not supported.

API scopes: workspace

Request body

pathstring

The absolute path of the object or directory. Importing a directory is only supported for the DBC and SOURCE formats.

formatstring

This specifies the format of the file to be imported.

The value is case sensitive.

  • AUTO: The item is imported depending on an analysis of the item's extension and the header content provided in the request. If the item is imported as a notebook, then the item's extension is automatically removed.
  • SOURCE: The notebook or directory is imported as source code.
  • HTML: The notebook is imported as an HTML file.
  • JUPYTER: The notebook is imported as a Jupyter/IPython Notebook file.
  • DBC: The notebook is imported in <Databricks> archive format. Required for directories.
  • R_MARKDOWN: The notebook is imported from R Markdown format.

Default: SOURCE

Values: SOURCE, HTML, JUPYTER, DBC, R_MARKDOWN, AUTO, RAW

languagestring

The language of the object. This value is set only if the object type is NOTEBOOK.

Values: SCALA, PYTHON, SQL, R

contentstring

The base64-encoded content. This has a limit of 10 MB.

If the limit (10MB) is exceeded, exception with error code MAX_NOTEBOOK_SIZE_EXCEEDED is thrown. This parameter might be absent, and instead a posted file is used.

overwriteboolean

The flag that specifies whether to overwrite existing object. It is false by default. For DBC format, overwrite is not supported since it may contain a directory.

Default: false

Delete GA

POST /api/2.0/workspace/delete

Deletes an object or a directory (and optionally recursively deletes all objects in the directory).

  • If path does not exist, this call returns an error RESOURCE_DOES_NOT_EXIST.
  • If path is a non-empty directory and recursive is set to false, this call returns an error DIRECTORY_NOT_EMPTY.

Object deletion cannot be undone and deleting a directory recursively is not atomic.

API scopes: workspace

Request body

pathstring

The absolute path of the notebook or directory.

recursiveboolean

The flag that specifies whether to delete the object recursively. It is false by default. Please note this deleting directory is not atomic. If it fails in the middle, some of objects under this directory may be deleted and cannot be undone.

Default: false

Export GA

GET /api/2.0/workspace/export

Exports an object or the contents of an entire directory.

If path does not exist, this call returns an error RESOURCE_DOES_NOT_EXIST.

If the exported data would exceed size limit, this call returns MAX_NOTEBOOK_SIZE_EXCEEDED. Currently, this API does not support exporting a library.

API scopes: workspace

Parameters

pathstringquery

The absolute path of the object or directory. Exporting a directory is only supported for the DBC, SOURCE, and AUTO format.

formatstringquery

This specifies the format of the exported file. By default, this is SOURCE.

The value is case sensitive.

  • SOURCE: The notebook is exported as source code. Directory exports will not include non-notebook entries.
  • HTML: The notebook is exported as an HTML file.
  • JUPYTER: The notebook is exported as a Jupyter/IPython Notebook file.
  • DBC: The notebook is exported in <Databricks> archive format. Directory exports will not include non-notebook entries.
  • R_MARKDOWN: The notebook is exported to R Markdown format.
  • AUTO: The object or directory is exported depending on the objects type. Directory exports will include notebooks and workspace files.

Default: SOURCE

Values: SOURCE, HTML, JUPYTER, DBC, R_MARKDOWN, AUTO, RAW

direct_downloadbooleanquery

Flag to enable direct download. If it is true, the response is the exported file itself. Otherwise, by default, the response contains content in the form of a base64 encoded string.

Default: false

Response

contentstring

The base64-encoded content. If the limit (10MB) is exceeded, exception with error code MAX_NOTEBOOK_SIZE_EXCEEDED is thrown.

file_typestring

The file type of the exported file.

Mkdirs GA

POST /api/2.0/workspace/mkdirs

Creates the specified directory (and necessary parent directories if they do not exist). If there is an object (not a directory) at any prefix of the input path, this call returns an error RESOURCE_ALREADY_EXISTS.

Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

API scopes: workspace

Request body

pathstring

The absolute path of the directory. If the parent directories do not exist, it will also create them. If the directory already exists, this command will do nothing and succeed.