Skip to main content

Looker API 3.1

Project description

The Looker SDK for Python provides a convenient way to communicate with the Looker API available on your Looker server. The library requires python3.6+ and is annotated using the typing module.

The SDK uses a plug-in architecture (also known as dependency injection) for initializing that supports run-time specific transports (currently only RequestsTransport) and different approaches for managing API authentication (AuthSession and OAuthSession). The methods and models are generated from the Looker API spec by a new code generator developed at Looker.

Please [report any issues](https://github.com/looker-open-source/sdk-codegen/issues) encountered, and indicate the SDK language in the report.

Basic Usage

import looker_sdk

# For this to work you must either have set environment variables or created a looker.ini as described below in "Configuring the SDK"
sdk = looker_sdk.init40()  # or init31() for the older v3.1 API
my_user = sdk.me()

# output can be treated like a dictionary
print(my_user["first_name"])
# or a model instance (User in this case)
print(my_user.first_name)

# input methods can take either model instances like WriteUser
sdk.create_user(
    body=looker_sdk.models.WriteUser(first_name="Jane", last_name="Doe")
)
# or plain dictionaries
sdk.create_user(body={"first_name": "Jane", "last_name": "Doe"})

Full tutorial

Go from installation all the way to creating a functional micro-application in this 20-30 minute interactive tutorial.

This tutorial is hosted in Google Colaboratory, an interactive online notebook. You can follow along right in the notebook by clicking the button below.

https://colab.research.google.com/assets/colab-badge.svg

Sample project setup

Install python 3.8. We highly recommend using pyenv to install different versions of python. Mac users should use homebrew to install pyenv:

brew install pyenv

Follow the remaining steps 3 - 5 of https://github.com/pyenv/pyenv#basic-github-checkout otherwise your python3.8 installation may break.

Now you’re ready to install python 3.8:

pyenv install 3.8.2

We’ll use pipenv (fantastic virtualenv manager) to manage project dependencies.

brew install pipenv

Create a project directory

mkdir looker-sdk-example

Set python3.8 as the base interpreter for this directory

cd looker-sdk-example/
pyenv local 3.8.2

Install looker_sdk using pipenv

pipenv --python 3.8.2 install --pre looker_sdk

Configuring the SDK

The SDK supports configuration through a .ini file on disk as well as setting environment variables (the latter override the former).

Note: The .ini configuration for the Looker SDK is a sample implementation intended to speed up the initial development of python applications using the Looker API. See this note on Securing your SDK Credentials for warnings about using .ini files that contain your API credentials in a source code repository or production environment.

In order to configure the SDK client, create a “looker.ini” file to reference during client.setup()

example file:

[Looker]
# Base URL for API. Do not include /api/* in the url. If hosted on GCP, remove the :19999 leaving just https://your.cloud.looker.com
base_url=https://your.looker.com:19999
# API 3 client id
client_id=YourClientID
# API 3 client secret
client_secret=YourClientSecret
# Set to false if testing locally against self-signed certs. Otherwise leave True
verify_ssl=True

Note: If the application using the Looker SDK is going to be committed to a version control system, be sure to ignore the looker.ini file so the API credentials aren’t unintentionally published.

For any .ini setting you can use an environment variable instead. It takes the form of LOOKERSDK_<UPPERCASE-SETTING-FROM-INI> e.g. LOOKERSDK_CLIENT_SECRET

Code example

See many python sdk examples in our examples repo

Changelog

Located in our github repo

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

looker_sdk-21.6.1.tar.gz (298.4 kB view details)

Uploaded Source

Built Distribution

looker_sdk-21.6.1-py3-none-any.whl (319.7 kB view details)

Uploaded Python 3

File details

Details for the file looker_sdk-21.6.1.tar.gz.

File metadata

  • Download URL: looker_sdk-21.6.1.tar.gz
  • Upload date:
  • Size: 298.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for looker_sdk-21.6.1.tar.gz
Algorithm Hash digest
SHA256 fa5b704a23e9b8390431c4adc2f283177d76a9ff859c78f4962be3f352281206
MD5 f6beb66d77eaf6a34077161b8bae1816
BLAKE2b-256 85ab36cb8e66564e84c8fa73fa52cbae7a278a100f84dc8c37c9076cd45afdbe

See more details on using hashes here.

Provenance

File details

Details for the file looker_sdk-21.6.1-py3-none-any.whl.

File metadata

  • Download URL: looker_sdk-21.6.1-py3-none-any.whl
  • Upload date:
  • Size: 319.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for looker_sdk-21.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 716208977a149d674065e50040846342c024ca18ba7b57bcaf40d5573aafb984
MD5 50c9decf20159fd86d955af4e83da357
BLAKE2b-256 de03fb48515831ed22958175490529581bfa070e34237139dd00d33a451bdf87

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page