Question

Downloading looker-latest.jar via API (wget example request)

  • 26 January 2019
  • 2 replies
  • 136 views

Dear Looker,


Could you please provide an example of how to use the looker download API, using curl or wget , (it was not clear whether ‘data’ was raw header, form data, etc.) I’m sorry, I don’t know axios.


Follow up question:

Will the API support downloading of md5sum?


Thank you,


2 replies

Userlevel 7
Badge +1

We’re working on getting this officially doc’ed on that page you linked. In the meantime, ask and you shall recieve!


wget -O- --post-data='{"lic": "YOURLOOKERLICENSE", "email": "example.org", "latest":"specific", "specific":"looker-5.24-latest.jar}' --header=Content-Type:application/json "https://apidownload.looker.com/download"

curl -i -X POST -H 'Content-Type: application/json' -d '{"lic": "YOURLOOKERLICENSE", "email": "example.org", "latest":"latest"}' https://apidownload.looker.com/download
Userlevel 2

I thought I’d leave this Python snippet here, in case anyone needs it.

 

#!/bin/python
import argparse
import requests
import wget

parser = argparse.ArgumentParser()
parser.add_argument("--lic", "-l", help="Your Looker license.", type=str, required=True)
parser.add_argument(
"--email", "-e", help="Email of authorized downloader", type=str, required=True
)
parser.add_argument(
"--version",
"-v",
help="Major version of Looker jars. E.g., '21.12'. ",
type=str,
required=True,
)
parser.add_argument(
"--minor",
"-m",
help="Minor version of Looker jar. E.g., '39'. If not set, 'latest' for the major version will be used.",
type=str,
)

args = parser.parse_args()

minor_version = f".{args.minor}" if args.minor is not None else "-latest"
DOWNLOAD_URL = "https://apidownload.looker.com/download"

params = {
"lic": args.lic,
"email": args.email,
"latest": "specific",
"specific": f"looker-{args.version}{minor_version}.jar",
}

response = requests.post(DOWNLOAD_URL, json=params).json()

print(response["splitJarMessage"])

looker_jar_link = response["url"]
looker_deps_jar_link = response["depUrl"]

# Download the files
print("Downloading " + response["depDisplayFile"].replace("dependencies-", ""))
wget.download(looker_jar_link)
print("Downloading " + response["depDisplayFile"])
wget.download(looker_deps_jar_link)

Usage would look something like this:

chmod +x download_specific_jars.py
./download_specific_jars.py -l YOUR_LOOKER_LICENSE -e EMAIL_OF_AUTH_USER -v 21.16 -m 39

This script has two dependencies. It also expects Python3.

pip3 install requests wget

Unless it is a critical business need, it is best not set the minor version, as this ensures the latest version per major release is used.

Hope it helps someone.

Reply