Generating Client SDKs for the Looker API

  • 16 August 2016
  • 65 replies

Show first post

65 replies

Do we have any Video on the how can the looker api be setup and configured.

Userlevel 4

@svarun, here’s a few links to documentation to get you started:

  •, switch out your domain here to access the api-docs, where you can test API calls.

  • (data science with Python)


mvn package

Make yourself a cup of coffee. Fry up some donuts while you’re at it - this will take awhile!

If you run mvn clean package -DskipTests it takes less than 30 seconds to build.

Also swagger-codegen 2.2.3 worked for auto generating Java against Looker 5.2.21

Is there any plan to distribute examples of using the swagger generated api’s in languages such as Java? I’ve found the link below before, and it has just about every language other than java.

Hey Dan,

It looks like LookerEmbedClientExample is the Java version of the SSO script you linked to here,

but this is for generating an SSO Login URL.

To generate a Swagger SDK for Java, follow the above instructions until you get to the header “Generate a Looker API Client SDK.” After the command there is a paragraph describing how to alter the statement to get a Java SDK.

You can use the same command to generate Looker API client SDKs for Java, .NET, and a variety of other languages and platforms supported by the Swagger-Codegen tools. Change the language target with the -l parameter and the output directory with the -o parameter.

Let me know if you have any more questions.


Sorry my original comment was misleading.

I’ve generated the Looker API SDK via the swagger generation. My problem is finding tangible examples of the swagger api sdk in action. Would love to see some tangible examples in java. Let me know if that makes sense.


Ah I see, thanks for clarifying. At this time there aren’t tangible examples of using the Looker API with Java but I will let our Product/Docs team know these would be helpful.

We do have these examples in Python, but it doesn’t look like we currently have the same thing for Java.

FWIW, when creating a Python SDK v.2.3.1 for Python 3.6.4, I found I needed to change the sample usage script:

# instantiate Auth API
unauthed_client = looker.ApiClient(configuration=None)
unauthed_auth_api = looker.ApiAuthApi(unauthed_client)

# authenticate client
token = unauthed_auth_api.login(
client_id=client_id, client_secret=client_secret)
client = looker.ApiClient(
header_value='token ' + token.access_token)

The reason is that if I merely passed strings as positional parameters, then the configuration object wasn’t an object, but was just strings, which don’t have the configuration object’s methods, so the SDK code would break.

Thanks, this took me ages to work out!

Userlevel 1

Hi Danny,

I’ve managed to perform all the steps until the last one.

A few questions to debug it:

  1. The file must be placed in python work directory (~/pywd/) and not in ~/pywd/looker/, ~/looker_sdk/python_sdk/ nor ~/looker_sdk/python_sdk/swagger_client/ ?

  2. When I run python in my python work directory ~/pywd/, the following error occurs

AttributeError: module 'looker' has no attribute 'ApiClient'

I did filled the base_url, client_idand `client_secret``

Is there something I missed ?

Many thanks in advance,


Userlevel 1

PS : I also tried Eric’s suggested amendment, without much success (same error)


You could try this method:

  • leave the Python SDK where it was built: ~/looker_sdk/python_sdk/swagger_client

  • add this directory to the environment variable PYTHONPATH (I’m assuming you use bash shell)

    $ export PYTHONPATH=~/looker_sdk/python_sdk:$PYTHONPATH

  • in your program in the Python working directory, add this line

    import swagger_client as looker

  • now you can call looker.ApiClient(), etc., in your code

The Java SDK Example

ApiClient lookerApiClient = new ApiClient();


ApiAuthApi authAPI = new ApiAuthApi(lookerApiClient);

AccessToken authenticatingToken = authAPI.login(clientid, clientkey);

lookerApiClient.addDefaultHeader(“Authorization”, "token " + authenticatingToken.getAccessToken());

DashboardApi dashboardApi = new DashboardApi(lookerApiClient);

Userlevel 2

I am trying to generate a client using swagger-codegen in aspnetcore. When I generate the client everything gets generated but all the code in the controllers is filled with TODO comments rather than the actual code for the method:


public virtual IActionResult Login([FromQuery]string clientId, [FromQuery]string clientSecret)
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(AccessToken));

//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400, default(Error));

//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404, default(Error));

string exampleJson = null;
exampleJson = "{\n \"access_token\" : \"access_token\",\n \"token_type\" : \"token_type\",\n \"expires_in\" : 0\n}";

var example = exampleJson != null
? JsonConvert.DeserializeObject<AccessToken>(exampleJson)
: default(AccessToken);
//TODO: Change the data returned
return new ObjectResult(example);

However, when I generate the client using .net starndard, everything gets generated fine and I can consume the API endpoints as documented.

Here is the command I’m running:

swagger-codegen generate -i swagger.json -l aspnetcore -o LookerAPI

Does the swagger file provided by looker (API 3.0) support dotnet core? Seems like it might not be completed yet…

Userlevel 1

Hey @Marc_Wilson,

I hope all is well! I did some research regarding this and found that the open API spec that our swagger file follows can be used by swagger to generate SDKs; however, we currently don’t do anything on our end to make it work for specific languages. In the swagger-codegen repository it is noted that .NET is supported as a client SDK but .NET Core is supported as a server stub. So it’s not necessarily that Looker does not support dotnet core, but rather it appears that swagger codegen does not currently support a client for .NET core. It only supports generating server stubs, which would not work since Looker is the server. Let me know if I can clarify anything about this on my end!



Hey Danny, thanks for the great documentation!

I found the “Generate a Looker API Client SDK” step sort of confusing and took me awhile to get it to work because:

  1. There two lines with 1. before it.

  2. it wasn’t clear the the multiple lines for the python command is supposed to be one command

  3. the back slashes are actually not supposed to be part of the command

So I’d suggest replacing it with the following!

Generate a Looker API Client SDK

To generate a Looker API client SDK for Python, do this:

  1. cd looker_sdk

  2. java -jar ./swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i lookerapi.json -l python -o python_sdk

Userlevel 2

Hi Dan,

Is there any plan to distribute examples of using the swagger generated api’s in languages such as Java?

Yes! We are investigating requirements and scoping out the work required to deliver pre-built Looker client SDKs for a variety of languages (including Java) and be able to show Looker API example snippets in the same set of languages as well.

There’s a lot of work that has to be done to make that happen, but yes, it is on our radar (not just on the wish list!). I really (really) want to remove this swagger-codegen step from the Looker SDK bootstrap as it is a rather large, frustrating barrier to entry. We can make this easier for you all! 🙂


Danny thanks for the response. Examples of Java API’s are the last thing on wish list at the moment as we have a slew of other functionalities we’d like fixed. Glad to know it’s moving forward. Thanks for the reply.

I had the same problem and doing

git clone worked for me.

Userlevel 3

I posted the swagger-generated python sdk in pip. This now works:

pip install lookerapi

import lookerapi as looker

# replace with your custom Looker API Host domain and port, if applicable.
base_url = 'https://your.looker.instance:19999/api/3.0/'
client_id = 'your-API3-client-id'
client_secret = 'your-API3-client-secret'

# instantiate Auth API
unauthenticated_client = looker.ApiClient(base_url)
unauthenticated_authApi = looker.ApiAuthApi(unauthenticated_client)

# authenticate client
token = unauthenticated_authApi.login(client_id=client_id, client_secret=client_secret)
client = looker.ApiClient(base_url, 'Authorization', 'token ' + token.access_token)

# instantiate User API client
userApi = looker.UserApi(client)
me =;

print me

# instantiate Look API client
lookApi = looker.LookApi(client)

print lookApi.all_looks()

@russ - Thank you so much for pushing the SDK to PyPI! Just in case we ever need to do this on our own in the future (for example, if our API version diverges from the one available on PyPI), can you provide the steps you needed to take to go from the Swagger-produced files to something submittable to PyPI (or another local Python repository such as Artifactory) as a complete Python package?

Userlevel 3

Hi Rob,

I’ll continue updating this in pip. But if you want to see the steps to publish it, it was really just having the swagger output and then the recipe from PyPI itself:

Hopefully that points you in the right direction, and please share any feedback on the pip package!

Hello everyone,

I’ve managed to generate a .Net Standard 1.3 compatible SDK with the following command using swagger codegen v2.4.5.

java -jar .\swagger-codegen\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i lookerapi.json -l csharp -o csharp_sdk_v5.0 --additional-properties targetFramework=v5.0 --additional-properties netCoreProjectFile=true

Technically it should be compatible with dotnet core 1.0, but it seems to work with dotnet core 2.2. I made simple tests with get/run look and run query async and it worked.

The only issue I found so far was with ‘get look’. It returned the message Internal Server Error. Unexpected character encountered while parsing value: {. Path ‘query.vis_config.series_types’, line 1, position 1893.. Debugging the SDK, the return of the API was "series_types": {},, and deserialization was mapping to an entry of Dictionary<string, string>. By changing manually to Dictionary<string, object> seemed to resolve. Most probably a swagger-codegen issue rather than Looker’s.

Have you any of you guys tried to experiment with dotnet core 2.2 ? Thanks!

Has anyone generated a python SDK for API 3.1 yet?

Userlevel 3

Hi Jerome – Unfortunately not yet (to my knowledge). It is on my to do list in the next couple weeks.

You have an interim solution?