Registry / crm-productivity / looker-sdk

looker-sdk

JSON →
library26.12.0pypypi✓ verified 25d ago

The `looker-sdk` is the official Python SDK for interacting with the Looker REST API. It provides a convenient, programmatic way to manage Looker instances, run queries, extract data, and automate workflows. Maintained by Google/Looker, it currently supports API 4.0 and requires Python 3.6+. It's actively developed with regular updates to support new Looker features and API versions.

pip install looker-sdk
INSTALL
IMPORT
SIG · LOOKER-SDK
L
looker-sdk
crm-productivitypythonv26.12.0
Install
2.6s avg
Import
1701ms
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.12.0 · 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.95 runs
installs and imports cleanly · install 0.0s · import 1.802s · 25.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 1.600s · 26MB
24MB installed
● package 24MB
Code
Verified usage

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

looker_sdk
import looker_sdk
init40
sdk = looker_sdk.init40()
sdk = looker_sdk.init31()
API 3.1 and 3.0 were removed in Looker v23.18+. Always use init40() for current Looker instances.
models
from looker_sdk import models
Provides access to Looker API models for creating or updating resources, e.g., models.WriteUser(). Alternatively, model-specific imports like from looker_sdk.models40 import WriteUser are also common.

This quickstart demonstrates how to initialize the Looker SDK using environment variables (recommended for security) and make a basic API call to retrieve information about the current user. It highlights the use of `init40()` for API 4.0, which is the current stable version. Ensure you replace placeholder environment variables with your actual Looker instance details and API credentials.

import os import looker_sdk # --- Configuration using Environment Variables --- # Set these environment variables before running: # LOOKERSDK_BASE_URL: Your Looker instance URL (e.g., https://your.looker.com or https://your.looker.cloud.google.com) # Note: AWS-hosted instances may require ':19999' port (e.g., https://your.looker.com:19999), while GCP-hosted instances usually omit it. # LOOKERSDK_API_VERSION: Should be '4.0' # LOOKERSDK_VERIFY_SSL: 'true' or 'false' # LOOKERSDK_CLIENT_ID: Your API3 Client ID # LOOKERSDK_CLIENT_SECRET: Your API3 Client Secret # LOOKERSDK_TIMEOUT: (Optional) Request timeout in seconds, default is 120. # Example of setting environment variables (replace with your actual values): os.environ['LOOKERSDK_BASE_URL'] = os.environ.get('LOOKERSDK_BASE_URL', 'https://your.looker.com') os.environ['LOOKERSDK_API_VERSION'] = os.environ.get('LOOKERSDK_API_VERSION', '4.0') os.environ['LOOKERSDK_VERIFY_SSL'] = os.environ.get('LOOKERSDK_VERIFY_SSL', 'true') os.environ['LOOKERSDK_CLIENT_ID'] = os.environ.get('LOOKERSDK_CLIENT_ID', 'YOUR_CLIENT_ID') os.environ['LOOKERSDK_CLIENT_SECRET'] = os.environ.get('LOOKERSDK_CLIENT_SECRET', 'YOUR_CLIENT_SECRET') # Initialize the SDK for API 4.0 try: sdk = looker_sdk.init40() print("Looker SDK 4.0 initialized successfully.") # Make a simple API call to get the current user me = sdk.me() print(f"Hello, {me.first_name} {me.last_name} ({me.email})!") # Example of creating a user (requires appropriate permissions) # from looker_sdk import models # new_user_data = models.WriteUser(first_name="Test", last_name="User", email="test.user@example.com") # new_user = sdk.create_user(body=new_user_data) # print(f"Created new user: {new_user.first_name}") except Exception as e: print(f"Error initializing SDK or making API call: {e}") print("Please ensure environment variables (LOOKERSDK_BASE_URL, LOOKERSDK_API_VERSION, CLIENT_ID, CLIENT_SECRET) are correctly set.")
Debug
Known issues
breakingAPI 3.x (3.0 and 3.1) has been completely removed in Looker v23.18 (August 2023). Any applications or scripts using `looker_sdk.init31()` or directly calling 3.x API endpoints will fail.
fix
Migrate your code to use Looker API 4.0 and initialize the SDK with `looker_sdk.init40()`. Update any API endpoint calls to their 4.0 equivalents.
affects: < 23.18
breakingBeginning with Looker 26.18 (expected October 2026), credentials for API login will *exclusively* be accepted in the HTTP request body. Passing credentials via URL query parameters will no longer be supported.
fix
Upgrade your `looker-sdk` to version 26.4 or later as soon as possible. Modify any custom scripts or applications that manually pass credentials in URL query parameters to pass them in the HTTP request body.
affects: >= 26.18
gotchaStoring API credentials directly in a `looker.ini` file or environment variables without proper security measures is a risk. For production environments, consider more secure storage solutions.
fix
While `looker.ini` or environment variables are convenient for development, ensure `looker.ini` is never committed to source control (e.g., add to `.gitignore`). For production, implement a secure configuration retrieval method (e.g., using a secrets manager) by subclassing `api_settings.ApiSettings` and overriding `read_config` or using secure environment variable management.
affects: All versions
gotchaThe base URL for your Looker instance can vary, especially between AWS and Google Cloud Platform (GCP) hosted instances, potentially requiring a port number.
fix
For AWS-hosted Looker, the `LOOKERSDK_BASE_URL` might require `:19999` (e.g., `https://your.looker.com:19999`). For GCP instances (e.g., `your.cloud.looker.com`), the port is typically omitted. Verify the correct base URL for your specific Looker instance.
affects: All versions
deprecatedThe `lookerapi` Python package (installed via `pip install lookerapi-deprecated`) is an unofficial, unsupported SDK that was fully removed by the end of 2020. It will not receive updates and may not work with newer Python versions or Looker API changes.
fix
Migrate to the official `looker-sdk` package (`pip install looker-sdk`) for all new and existing projects.
affects: <= 2020 (end-of-life)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'looker-sdk'
The `looker-sdk` Python package is not installed in your current environment or your environment's Python path is not correctly configured.
fix
Install the Looker SDK using pip: `pip install looker-sdk`
ModuleNotFoundError: No module named 'looker_sdk.rtl'
This usually indicates an issue with the `looker-sdk` installation, where the `rtl` (runtime library) submodule cannot be found, possibly due to an incomplete installation or a specific version conflict.
fix
Try uninstalling and reinstalling the package: `pip uninstall looker-sdk && pip install looker-sdk`.
SDKError: Looker Not Found (404)
This error typically occurs when the requested resource (e.g., dashboard, Look, user) does not exist, the API endpoint URL is incorrect (e.g., wrong port or base URL), or the authenticated user lacks the necessary permissions to access that resource.
fix
Verify the API endpoint URL in your `looker.ini` or SDK configuration, ensure the resource ID/path is correct, and confirm that the API credentials have the required permissions for the requested operation. Also, ensure you are using the correct API version (e.g., `init40()` for API 4.0).
Unauthorized (401)
Authentication failed because of invalid or expired API credentials (client ID/secret), the API key lacking sufficient permissions, or the authentication token not being passed correctly in the HTTP request.
fix
Check your `looker.ini` file or environment variables (`LOOKERSDK_CLIENT_ID`, `LOOKERSDK_CLIENT_SECRET`, `LOOKERSDK_BASE_URL`) to ensure your API credentials are correct and unexpired. Verify that the associated Looker user has the necessary roles and permissions.
ImportError: cannot import name 'client' from 'looker_sdk'
In newer versions of the `looker-sdk`, the `client` module is not directly exposed for import. The SDK client is initialized directly via functions like `looker_sdk.init40()`.
fix
Remove the explicit import of `client`. Initialize the SDK client directly, for example: `sdk = looker_sdk.init40()`.
Upgrade
Version history
26.12.0latest on PyPI · released Jul 13, 2026
Audit
Dependencies
requestsrequiredUsed for HTTP transport layer.
cattrsrequiredUsed for structuring/unstructuring data, version restrictions may apply for older Python versions. Automatically installed with looker-sdk.
Agent activity
40 hits · last 30 days
node
34
OpenAI (training)
1
Resources
looker-sdk — pip install looker-sdk · libregistry