Hi -
I am looking to create a python script that would connect to looker dataset ? Can anyone help me with how can I establish the API connection and extract the data.
Thanks in advance
Cheers
Varun
Hi -
I am looking to create a python script that would connect to looker dataset ? Can anyone help me with how can I establish the API connection and extract the data.
Thanks in advance
Cheers
Varun
Hi
You can use Python to connect to your Looker instance and query the data from the connections set up in your instance!
Looker itself does not store any of your database’s data.
In order to use the API in Python we can either generate the Python SDK following the instructions on this post here
Otherwise, if you’re familiar with the requests library, using Python3 we can use this approach to get you started:
import requests
def log_me_in(id secret, base_url):
payload = {'client_id': id, 'client_secret': secret}
url = base_url + '/login'
r = requests.post(url, data=payload)
# check for successful auth
if r.status_code == 200:
token = r.json()['access_token']
return token
else:
print('Authentication failed')
def get_look(token, look_id, base_url):
# hard coded for json format response
url = base_url +'/looks/' + look_id + '/run/json?access_token=' + token
r = requests.get(url)
if r.status_code == 200:
for elem in r.json():
print(str(elem))
id = "your_API3_client_id"
secret = "your_API3_client_secret"
base_url = "https://your_company.looker.com:19999/api/3.0"
Cheers,
-Romain
Try out this github repo Pull Data into Python / Jupyter
More info on using Looker’s API for Data Science [Link]
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.