Run an URL encoded query.
This requires the caller to encode the specifiers for the query into the URL query part using Looker-specific syntax as explained below.
Generally, you would want to use one of the methods that takes the parameters as json in the POST body for creating and/or running queries. This method exists for cases where one really needs to encode the parameters into the URL of a single 'GET' request. This matches the way that the Looker UI formats 'explore' URLs etc.
The parameters here are very similar to the json body formatting except that the filter syntax is tricky. Unfortunately, this format makes this method not currently callable via the 'Try it out!' button in this documentation page. But, this is callable when creating URLs manually or when using the Looker SDK.
Here is an example inline query URL:
https://looker.mycompany.com:19999/api/4.0/queries/models/thelook/views/inventory_items/run/json?fields=category.name,inventory_items.days_in_inventory_tier,products.count&f[category.name]=socks&sorts=products.count+desc+0&limit=500&query_timezone=America/Los_Angeles
When invoking this endpoint with the Ruby SDK, pass the query parameter parts as a hash. The hash to match the above would look like:
query_params =
{
fields: "category.name,inventory_items.days_in_inventory_tier,products.count",
:"f[category.name]" => "socks",
sorts: "products.count desc 0",
limit: "500",
query_timezone: "America/Los_Angeles"
}
response = ruby_sdk.run_url_encoded_query('thelook','inventory_items','json', query_params)
Again, it is generally easier to use the variant of this method that passes the full query in the POST body. This method is available for cases where other alternatives won't fit the need.
Supported formats:
result_format | Description |
---|---|
json | Plain json |
json_bi | (RECOMMENDED) Row data plus metadata describing the fields, pivots, table calcs, and other aspects of the query. See JsonBi type for schema |
json_detail | (LEGACY) Row data plus metadata describing the fields, pivots, table calcs, and other aspects of the query |
csv | Comma separated values with a header |
txt | Tab separated values with a header |
html | Simple html |
md | Simple markdown |
xlsx | MS Excel spreadsheet |
sql | Returns the generated SQL rather than running the query |
png | A PNG image of the visualization of the query |
jpg | A JPG image of the visualization of the query |
Request
Response
200: Query
400: Bad Request
404: Not Found
422: Validation Error
429: Too Many Requests
Examples
C#
https://github.com/looker-open-source/sdk-codegen/blob/main/csharp/sdk/4.0/methods.cs |
Go
https://github.com/looker-open-source/sdk-codegen/blob/main/go/sdk/v4/methods.go |
Kotlin
TypeScript
Python
https://github.com/looker-open-source/sdk-codegen/blob/main/python/looker_sdk/sdk/api40/methods.py |
Swift
https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/sdk/methods.swift |
https://github.com/looker-open-source/sdk-codegen/blob/main/swift/looker/sdk/streams.swift |