How to Use Looker API

Cody Schneider7 min read

The Looker API is your key to unlocking the full potential of your business intelligence platform, allowing you to embed analytics, automate reporting, and manage your instance programmatically. It transforms Looker from a destination for data into a service you can integrate anywhere. This guide will walk you through setting up your credentials, authenticating, and performing a few common tasks to get you started.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

What is the Looker API? A Quick Overview

In simple terms, an Application Programming Interface (API) is a set of rules that lets different software applications communicate with each other. The Looker API exposes a vast range of Looker’s functionality, giving you developer-level control over the platform without having to use the graphical user interface.

What can you do with it? Pretty much anything you can do in the Looker UI, and more. Think of building things like:

  • A custom internal portal that surfaces key metrics from different dashboards.
  • An automated workflow that emails a PDF of the weekly sales dashboard every Monday morning.
  • A Slack bot that can answer questions like "what was our revenue yesterday?" by querying Looker.
  • Scripts to help manage users and content across your organization at scale.

By using the API, you can bring your data to where your users are, fitting analytics seamlessly into their existing workflows.

Getting Started: Enabling the API and Getting Your Keys

Before you can make your first API call, you need to enable the API on your instance and generate credentials for yourself. This is a straightforward process you can handle in the Admin settings.

Step 1: Enable API Access on Your Looker Instance

First, a Looker Admin must ensure the API is enabled. This is usually on by default, but it's always good to check.

  1. Navigate to the Admin panel in Looker.
  2. Under the Server section, click on API.
  3. Make sure the Enable API Access checkbox is ticked.

Once that’s confirmed, you can generate your personal API keys.

Step 2: Create Your API Credentials

To authenticate with the API, you need a unique Client ID and a Client Secret. These act like a username and password for a script or application.

  1. Click your user icon in the top right and select Edit User.
  2. On the right side of the page, under your personal information, find the API3 Keys section and click Edit Keys.
  3. Click the New API3 Key button. Looker will immediately generate your Client ID and Client Secret.

Important: Your Client Secret is shown to you only once. Make sure to copy and paste it into a secure location, like a password manager, immediately. If you lose it, you'll have to delete the key and generate a new one.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Making Your First API Call: Authentication

With your Client ID and Client Secret in hand, you’re ready to authenticate. The API security model requires you to exchange these static credentials for a temporary access token. This token is what you will include with every subsequent request to prove you are authorized to access the API.

The process is simple: you make a specific POST request to the /login endpoint with your ID and secret, and Looker will respond with a short-lived access_token.

Example: Authenticating with cURL

Here’s how you can do it using cURL, a common command-line tool. Just replace the placeholder values with your own.

# Replace these with your actual Looker instance info
LOOKER_BASE_URL="https://yourcompany.cloud.looker.com:19999"
LOOKER_CLIENT_ID="your_client_id_here"
LOOKER_CLIENT_SECRET="your_client_secret_here"

# Make the POST request to the login endpoint and store the response
LOGIN_RESPONSE=$(curl -X POST \
  -d "client_id=${LOOKER_CLIENT_ID}" \
  -d "client_secret=${LOOKER_CLIENT_SECRET}" \
  "${LOOKER_BASE_URL}/api/4.0/login")

# Extract only the access_token string from the JSON response
ACCESS_TOKEN=$(echo ${LOGIN_RESPONSE} | sed -n 's/.*"access_token": *"\([^"]*\)".*/\1/p')

echo "Your successfully retrieved access token is: ${ACCESS_TOKEN}"

Once you run this, the ACCESS_TOKEN variable will hold the temporary token. In all future API calls, you will include this token in the header like this: Authorization: token YOUR_ACCESS_TOKEN_HERE.

Common Use Cases For The Looker API

Now for the fun part. Let's look at a few practical examples of what you can accomplish with the API.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

1. Running a saved Look

A simple yet powerful use case is programmatically running an existing Look (a saved query) and getting the data back in JSON format. This is perfect for feeding data into another service or a custom script.

You’ll need the ID of the Look, which you can easily find in its URL (e.g., in https://.../looks/123, the ID is 123).

LOOK_ID=123 # Replace with your Look's ID
# Your ACCESS_TOKEN from the previous authentication step is required here

JSON_RESULT=$(curl -X GET \
  -H "Authorization: token ${ACCESS_TOKEN}" \
  "${LOOKER_BASE_URL}/api/4.0/looks/${LOOK_ID}/run/json")

echo ${JSON_RESULT}

This script executes the Look and prints the resulting data as a JSON object, which you can then parse and use as needed.

2. Downloading a Dashboard as a PDF

Automating report generation is a prime use case for the API. Generating a PDF or image of a dashboard involves a two-step "asynchronous" process: first you start a rendering job, and then you fetch the results once it's complete.

Step A: Start the render task

DASHBOARD_ID=456 # Replace with your Dashboard's ID

# Making the API call to start the rendering task
RENDER_TASK=$(curl -X POST \
     -H "Authorization: token ${ACCESS_TOKEN}" \
     -H "Content-Type: application/json" \
     -d '{ "result_format": "pdf", "width": 800, "height": 600 }' \
     "${LOOKER_BASE_URL}/api/4.0/dashboards/${DASHBOARD_ID}/render_tasks")

# Extract the unique ID for the render task
RENDER_TASK_ID=$(echo ${RENDER_TASK} | sed -n 's/.*"id": *"\([^"]*\)".*/\1/p')

echo "Render task started with ID: ${RENDER_TASK_ID}"

This call tells Looker to start creating a PDF. It quickly returns a task ID so you can check on its progress.

Step B: Check the task status and download the file

# This call fetches the generated document if it is ready
# In production, you'd check the /render_tasks/{id} endpoint first
# For simplicity, we directly try downloading it here

curl -X GET \
  -H "Authorization: token ${ACCESS_TOKEN}" \
  "${LOOKER_BASE_URL}/api/4.0/render_tasks/${RENDER_TASK_ID}/results" \
  --output my_dashboard_export.pdf

echo "Dashboard saved to my_dashboard_export.pdf"
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

3. Managing Users

The API is also an incredibly effective tool for administration. You can use it to synchronize your users with another directory, perform audits, or update user permissions in bulk. For example, you can easily search for a user by their email address.

USER_EMAIL="example@yourcompany.com"

USER_DATA=$(curl -X GET \
  -H "Authorization: token ${ACCESS_TOKEN}" \
  "${LOOKER_BASE_URL}/api/4.0/users/search?email=${USER_EMAIL}")

echo ${USER_DATA}

This returns all information about that user, including their ID, which you could then use in another call to update their details or deactivate their account.

Tips for Working with the Looker API

To make your development journey smoother, here are a few final tips:

  • Use the API Explorer: Every Looker instance includes interactive API documentation. You can find it by navigating to Admin > API in your instance. This tool lets you explore every available endpoint, see the required parameters, and even make sample calls directly from your browser.
  • Leverage an SDK: While cURL is great for simple examples, for a real application you should use one of Looker's official Software Development Kits (SDKs). They offer SDKs for Python, TypeScript, R and others, which handle the tedious parts like authentication and retries for you, so you can focus on building your application.
  • Notice the API Version: The API URL includes a version number (like /api/4.0/). Looker maintains older versions for backward compatibility, but always start new projects with the latest stable version to take advantage of new features.

Final Thoughts

Learning to use the Looker API moves you from a consumer of data to a builder of data-driven experiences. We've seen how to get API credentials, authenticate, and use key endpoints to run queries, download reports, and manage your instance. It truly opens up a world of possibilities for automation and deep platform integration.

Manually scripting against different APIs to build automated dashboards is a powerful skillset, but it can be time-intensive and requires technical expertise. At Graphed, we created a different way to get those same real-time insights without writing a single line of code. We built one-click connectors for dozens of marketing and sales platforms - like Google Analytics, Shopify, and Salesforce - and let you create dashboards simply by describing what you want to see in plain English. This eliminates the manual drudgery of API scripting so you and your team can get straight to the insights.

Related Articles