Generating Client SDKs for the Looker API


(leticia.esparza) #41

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!



(longfei) #42

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

(Danny Thorpe) #43

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! :slight_smile:


(Dan Groman) #44

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.

(Charlie Chafin) #45

I had the same problem and doing
git clone worked for me.

(Russ) #46

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?

(Russ) #48

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!