View the Command History

GET /api/v1.2/commands/

Use this API to view command history.

Required Role

The following users can make this API call:

  • Users who belong to the system-user or system-admin group.
  • Users who belong to a group associated with a role that allows viewing the command history. See Managing Groups and Managing Roles for more information.

View Queries by User ID

Resource URI commands/
Request Type GET
Supporting Versions v1, v1.2
Return Value This curl request returns a JSON object containing the Command Objects with all its attributes as described above. Additionally, the returned JSON object contains the next_page, previous page, and per page parameters.

Parameters

Note

Parameters marked in bold below are mandatory. Others are optional and have default values.

Parameter Description
page The number of pages that contain the commands’ history. Its value is an integer.
per_page The number of commands to be retrieved per page. Its value is an integer and the maximum value can be 100. Retrieves the next 100 commands based on the last command ID for a given QDS account.
all_users By default, it is set to 0. Set it to 1 to get the command history of all users.
include_query_properties By default, this parameter is set to false. Setting it to true displays query properties such as tags and query history comments.
start_date The date from which you want the command history (inclusive). The API default is 30 days before the end date. This parameter also supports timestamp in the UTC timezone (YYYY-MM-DDTHH:MM:SSZ) format.
end_date The date until which you want the command history (inclusive). The API default is today. This parameter also supports timestamp in the UTC timezone (YYYY-MM-DDTHH:MM:SSZ) format.
command_type The type of the command. Enter a single or multiple (comma-separated) values.
status

The status of the command. It can be one of the following:

  • success: denotes that the command is successful
  • failed: denotes that the command has failed
  • inprogress: denotes that the command is in process
  • cancelled: denotes that the command is complete but was cancelled by the user
command_source The source of creation of the command. For example, UI, API, and/ or Scheduler. Enter a single or multiple (comma-separated) values.
name Use the name of the command to filter commands from the command history. & (ampersand), < (lesser than), > (greater than), ” (double quotes), and ‘ (single quote) special characters, and HTML tags are not accepted. It can contain a maximum of 255 characters.

Sample API Requests

Examples:

  • To get the last 10 commands for the current user:
curl -i -X GET -H "X-AUTH-TOKEN:$AUTH_TOKEN" -H "Content-Type:application/json" -H "Accepts:application/json" \
"https://api.qubole.com/api/v1.2/commands"

Note

The above syntax uses https://api.qubole.com as the endpoint. Qubole provides other endpoints to access QDS that are described in Supported Qubole Endpoints on Different Cloud Providers.

  • (Pagination) To get results 10-12 for current user (4th page with 3 results per page):
curl -i -X GET -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"page":"4", "per_page":"3"}' "https://api.qubole.com/api/v1.2/commands"

Note

The above syntax uses https://api.qubole.com as the endpoint. Qubole provides other endpoints to access QDS that are described in Supported Qubole Endpoints on Different Cloud Providers.

or

curl -i -H "X-AUTH-TOKEN: $AUTH_TOKEN" "https://api.qubole.com/api/v1.2/commands?page=4&per_page=3"

Note

The above syntax uses https://api.qubole.com as the endpoint. Qubole provides other endpoints to access QDS that are described in Supported Qubole Endpoints on Different Cloud Providers.

To search by the command type and name (returns last 10 commands with the specified name and specified command type):

curl -i -X GET -H "X-AUTH-TOKEN:$AUTH_TOKEN" -H "Content-Type:application/json" -H "Accepts:application/json" \
-d '{"command_type":"ShellCommand,HiveCommand", "name":"named_command"}' \
"https://api.qubole.com/api/v1.2/commands"

Note

The above syntax uses https://api.qubole.com as the endpoint. Qubole provides other endpoints to access QDS that are described in Supported Qubole Endpoints on Different Cloud Providers.

Sample API Response

The sample response for the paginated call will be:

{
   “paging_info":{"previous_page":3,"next_page":5,"per_page":3},
   “commands”: [{<standard command object as described in create a command>}, ..]
}