The search command queries the Collector for matching patterns and returns the results in JSON format, limiting
the output to a maximum of 1000 records.
Specifies the search query in Human Query Language (HQL) format, which operates as follows:
A word without double quotes indicates a partial match (e.g., err will display all lines that
contain 'err' as part of a word).
A word enclosed in double quotes indicates a whole word match (e.g., "err" will display all lines
that contain 'err' as a complete word).
The operators AND and OR can be used to refine the search (e.g., error AND "404" OR "505" will
display all lines that contain the word 'error' and either the number '404' or '505' as a whole
word).
time
Specifies the time scope for the search. Possible values range from "1d," representing today, to "30d,"
representing the past 30 days. You can set the time scope as "1d" for today, "2d" for the past two days,
"3d" for the past three days, and so on, up to "30d" for the past 30 days. The default is 1d.
* Indicates a mandatory field. Code Snippets
Here are several code snippets provided for your direct use. Simply select your
preferred tool/language by clicking on it.
const apiUrl = "https://your_nexus_server_or_ip/api/v3/";
//JSON data to be sent
const data = {
"id": "V7dcf7bce3-xxxx-xxxx-xxxx-7e49xxxxx1148",
"search": "x.svg",
"time": "1d"
};
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-access-account": "YOUR_ACCOUNT_ID",
"x-access-authorization": "YOUR_ACCESS_KEY",
"x-secret-key": "YOUR_SECRET_KEY",
"x-api": "API_NAME",
"x-api-command": "API_COMMAND"
},
body: JSON.stringify(data),
};
fetch(apiUrl, requestOptions)
.then((response) => {
if (!response.ok) {
throw new Error("Connection error");
}
return response.json();
})
.then((data) => {
//process received JSON data
console.log(JSON.stringify(data, null, 4));
if (data.result == "OK") {
console.log("TASK SUCCESSFUL");
} else {
console.log("ERROR: " + data.message);
}
})
.catch((error) => {
console.log("Error: " + error);
});
API Request
Copy
import fetch from 'node-fetch';
/*
Using the following code as a workaround for self-signed certificate
errors is discouraged in production environments.
*/
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
const apiUrl = "https://your_nexus_server_or_ip/api/v3/";
//JSON data to be sent
const data = {
"id": "V7dcf7bce3-xxxx-xxxx-xxxx-7e49xxxxx1148",
"search": "x.svg",
"time": "1d"
};
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-access-account": "YOUR_ACCOUNT_ID",
"x-access-authorization": "YOUR_ACCESS_KEY",
"x-secret-key": "YOUR_SECRET_KEY",
"x-api": "API_NAME",
"x-api-command": "API_COMMAND"
},
body: JSON.stringify(data),
};
fetch(apiUrl, requestOptions)
.then((response) => {
if (!response.ok) {
throw new Error("Connection error");
}
return response.json();
})
.then((data) => {
//process received JSON data
console.log(JSON.stringify(data, null, 4));
if (data.result == "OK") {
console.log("TASK SUCCESSFUL");
} else {
console.log("ERROR: " + data.message);
}
})
.catch((error) => {
console.log("Error: " + error);
});
API Request
Copy
import requests
apiUrl = "https://your_nexus_server_or_ip/api/v3/"
#JSON data to be sent
data = {
"id": "V7dcf7bce3-xxxx-xxxx-xxxx-7e49xxxxx1148",
"search": "x.svg",
"time": "1d"
}
headers = {
"Content-Type": "application/json",
"x-access-account": "YOUR_ACCOUNT_ID",
"x-access-authorization": "YOUR_ACCESS_KEY",
"x-secret-key": "YOUR_SECRET_KEY",
"x-api": "API_NAME",
"x-api-command": "API_COMMAND"
}
###
# Using verify=False in the following code as a workaround for
# self-signed certificate errors is discouraged in production environments.
###
response = requests.post(apiUrl, headers=headers, json=data, verify=False)
#process received JSON data
ret = response.json()
print(ret)
if (ret['result'] == "OK"):
print("TASK SUCCESSFUL")
else:
print("ERROR: "+ret['message'])
API Request
Copy
require 'uri'
require 'net/http'
require 'json'
apiUrl = URI.parse("https://your_nexus_server_or_ip/api/v3/")
@data = {
"id": "V7dcf7bce3-xxxx-xxxx-xxxx-7e49xxxxx1148",
"search": "x.svg",
"time": "1d"
}.to_json
http = Net::HTTP.new(apiUrl.host, apiUrl.port)
http.use_ssl = true
###
# Using OpenSSL::SSL::VERIFY_NONE in the following code as a workaround for
# self-signed certificate errors is discouraged in production environments.
###
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Post.new(apiUrl, initheader = {'Content-Type' => 'application/json'})
req['x-access-account'] = 'YOUR_ACCOUNT_ID'
req['x-access-authorization'] = 'YOUR_ACCESS_KEY'
req['x-secret-key'] = 'YOUR_SECRET_KEY'
req['x-api'] = 'API_NAME'
req['x-api-command'] = 'API_COMMAND'
req.body = @data
#make the api request
res = http.request(req)
# process received JSON data
ret = JSON.parse(res.body)
puts ret
if ret["result"] == "OK"
puts "TASK SUCCESSFUL"
else
puts "ERROR: "+ret["message"]
end