Registry / aws / databricksapi

databricksapi

JSON →
library1.1.8pypypi✓ verified 81d ago

The `databricksapi` library provides a Python wrapper for the Databricks REST API, simplifying interactions with Databricks workspaces, clusters, jobs, and more. It leverages the `requests` module for HTTP communication. Currently at version 1.1.8, its release cadence is moderate, with updates typically addressing new Databricks API features or bug fixes.

pip install databricksapi
INSTALL
IMPORT
SIG · DATABRICKSAPI
D
databricksapi
awspythonv1.1.8
Install
2.5s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.915 runs
installs and imports cleanly · install 2.5s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DatabricksAPI
import databricksapi
from databricksapi import DatabricksAPI

Initializes the DatabricksAPI client using environment variables for host and token, then demonstrates fetching a list of clusters. Ensure `DATABRICKS_HOST` includes the `https://` prefix and `DATABRICKS_TOKEN` has sufficient permissions (e.g., 'clusters/list') to perform the requested API calls.

import os from databricks_api import DatabricksAPI databricks_host = os.environ.get('DATABRICKS_HOST', 'https://your-databricks-host.cloud.databricks.com') # e.g., 'https://dbc-xxxx.cloud.databricks.com' databricks_token = os.environ.get('DATABRICKS_TOKEN', 'dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') if not databricks_host or 'your-databricks-host' in databricks_host: print("Error: Please set DATABRICKS_HOST environment variable or replace placeholder in code.") elif not databricks_token or 'dapi' not in databricks_token: print("Error: Please set DATABRICKS_TOKEN environment variable or replace placeholder in code.") else: try: # Initialize the Databricks API client databricks = DatabricksAPI(host=databricks_host, token=databricks_token) # Example: List active clusters # Requires 'clusters/list' permission on the token clusters_response = databricks.clusters.list_all_clusters() clusters = clusters_response.get('clusters', []) print(f"Found {len(clusters)} clusters.") if clusters: print(f"First cluster name: {clusters[0]['cluster_name']}") # Example: List jobs (uncomment to run, requires 'jobs/list' permission) # jobs_response = databricks.jobs.list_jobs() # jobs = jobs_response.get('jobs', []) # print(f"Found {len(jobs)} jobs.") except Exception as e: print(f"An error occurred: {e}") if hasattr(e, 'response') and hasattr(e.response, 'json'): print(f"API Error Details: {e.response.json()}")
Debug
Known issues
gotchaAuthentication failures are common. Ensure your `host` parameter includes the `https://` prefix (e.g., `https://dbc-xxxx.cloud.databricks.com`) and your `token` has the necessary permissions for the specific API calls you're making. Different API endpoints require different token scopes.
fix
Verify `DATABRICKS_HOST` format and `DATABRICKS_TOKEN` permissions in your Databricks workspace. It is highly recommended to use environment variables for credentials.
affects: All versions
gotchaThe library's internal structure mirrors Databricks API groups (e.g., `databricks.clusters`, `databricks.jobs`). While generally stable, breaking changes in the underlying Databricks API or internal refactoring in `databricksapi` could lead to `AttributeError` if an API endpoint path changes.
fix
Always refer to the latest `databricksapi` GitHub README or examples for current API object structures and method names (e.g., `clusters.list_all_clusters()` instead of a hypothetical `clusters.get_all_clusters()`).
affects: All versions, potential for minor version changes
gotchaError responses from the Databricks API are wrapped in `requests.exceptions.HTTPError`. These errors typically contain detailed JSON messages in their response content. Generic `try-except` blocks might obscure specific API errors.
fix
Catch `requests.exceptions.HTTPError` specifically and parse `e.response.json()` for detailed error information (e.g., invalid parameters, resource not found) to understand API-specific failures.
affects: All versions
Upgrade
Version history
1.1.8latest on PyPI · released Apr 3, 2020
Audit
Dependencies
requestsrequiredUsed for making HTTP requests to the Databricks API.
Agent activity
25 hits · last 30 days
node
24
OpenAI (training)
1
Resources
databricksapi — pip install databricksapi · libregistry