NXRM 3.16 REST search and filtering enhancements

For our DevOps, CD, and Deployment teams, we’ve seriously improved search capabilities for the latest version of components! As you may know, there are 3 REST endpoints in NXRM 3 that are used for searching:

  • (serverUrl)/service/rest/v1/search - search for components
  • (serverUrl)/service/rest/v1/search/assets - search for assets
  • (serverUrl)/service/rest/v1/search/assets/download - search for an asset and download it

As of 3.16, each of these endpoints support a few new query parameters:

  • sort - this query parameter will define how to sort the search results. As an added bonus, for the search-and-download endpoint, this removes the requirement that only 1 result is returned in the search, simply letting you download the first result. If this parameter is omitted the default relevance sorting will be used. The following fields can be sorted on:

    • group
    • name
    • version
    • repository
  • direction - the order to sort the results in; this field is ignored if the sort field is not also supplied. The direction can either be ‘asc’ (ascending) or ‘desc’ (descending). If this field is omitted, default direction of ‘asc’ will be used, unless sorting on version then ‘desc’ will be used.

  • prerelease - a flag stating whether to include prelease assets in the response. If set to ‘true’ only prerelease results will be returned. If set to ‘false’ only release results will be returned. If this field is omitted, the default behavior of returning both release and prerelease results will be used.

    • Note that currently only the maven/npm/yum formats properly populate this ‘prerelease’ field in the search index, other formats have all assets marked as ‘release’.

When these query parameters are combined, they give the ability to download the latest release version of an asset, which has been something often requested in NXRM 3. Downloading the latest junit for example:

http://localhost:8081/service/rest/v1/search/assets/download?repository=maven-central&group=junit&name=junit&maven.classifier=& sort =version& prerelease =false

1 Like

Great feature - one question open:

How can I download a exact version of an artifact? Can you give an example?

Where can I find a list of possible parameters to pass? Is there somewhere a documentation?
Like “group, name, sort, …”

Thanks Max

Hi Max,
Were you aware of our GUI API?
It’s designed to answer questions like this.
See attached, for the location in the UI, as well as the download section expanded.
When you fill in your variables it’ll give a sample curl like curl -X GET “http://localhost:8081/service/rest/v1/search/assets/download?sort=version&name=jtzapp&version=1.0” -H “accept: application/json”. Really it depends what you want to do, and you can adjust from there once you have a sample that works for you.
I hope that helps vaguely=)

Thank you very much - didn’t know that you provide a swagger docu in the gui.
This answers all my questions …
Greetings Max

I am currently trying deploy latest artifact without downloading it from shell script. Is there a way to do this ?

Most formats I think support this thru their CLI tools. Are you saying you need to deploy not via tooling but using REST somehow?

This is what I am trying to implement.
ssh server1 sudo -u deploy.sh http://mynexus:8081/service/rest/v1/search/assets/download?sort=version&repository=mavensnapshots&group=mygroup&name=mypackage&maven.extension=war

Even with wget it does not download the latest package. wget http://mynexus:8081/service/rest/v1/search/assets/download?sort=version&repository=mavensnapshots&group=mygroup&name=mypackage&maven.extension=war
Redirecting output to ‘wget-log.6’.

Are you on the version mentioned here? If so, did you see an error or … ?

Yes, I am using

Curl also gets no results as well. No errors either.

curl curl -X GET “http://mynexus:8081/service/rest/v1/search/assets/download?sort=version&repository=mavensnapshots&group=mygroup&name=mypackage&maven.extension=war” -H “accept: application/json”


Is anonymous allowed in your system? I received no results until I enabled it then my curl worked (similar to yours just no maven.extension).

Same with curl here: no results and no errors. The URL is working in the browser though.

With anonymous on?

Yes with ‘anonymous’ on:

Version of Nexus is: Sonatype Nexus Repository ManagerOSS 3.17.0-01
Command: curl -v -u xxx:xxx "http://localhost:8080/service/rest/v1/search/assets/download?sort=version&direction=desc&repository=maven-snapshots&maven.groupId=bla.bla.bla&maven.artifactId=bla-bla&maven.extension=tar.gz"

It runs in a Docker container (‘sonatype/nexus3’). Tried same curl command within the container with no luck either.

Curl verbose output:

* About to connect() to localhost port 8080 (#0)
*   Trying
* Connected to localhost ( port 8080 (#0)
* Server auth using Basic with user 'xxx'
> GET /service/rest/v1/search/assets/download?sort=version&direction=desc&repository=maven-snapshots&maven.groupId=bla.bla.bla&maven.artifactId=bla-bla&maven.extension=tar.gz HTTP/1.1
> Authorization: Basic xxx
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
< HTTP/1.1 302 Found
< Date: Sun, 14 Jul 2019 17:33:23 GMT
< Server: Nexus/3.17.0-01 (OSS)
< X-Content-Type-Options: nosniff
< Location: http://localhost:8080/repository/maven-snapshots/bla/bla/bla/bla-assemblies/x.y.z-SNAPSHOT/bla-assemblies-x.x.x-20190712.105616-6-linux.tar.gz
< Content-Length: 0
* Connection #0 to host localhost left intact

But doesn’t do any actual downloading. As mentioned before: the URL used with the curl command works using a (Chrome) browser.

Search on assets without download option, does work as expected:

curl -v -u xxx:xxx "http://localhost:8080/service/rest/v1/search/assets?sort=version&direction=desc&repository=maven-snapshots&maven.groupId=bla.bla.bla&maven.artifactId=bla-bla&maven.extension=tar.gz"
* About to connect() to localhost port 8080 (#0)
*   Trying
* Connected to localhost ( port 8080 (#0)
* Server auth using Basic with user 'xxx'
> GET /service/rest/v1/search/assets?sort=version&direction=desc&repository=maven-snapshots&maven.groupId=bla.bla.bla&maven.artifactId=bla-bla&maven.extension=tar.gz HTTP/1.1
> Authorization: Basic xxx
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
< HTTP/1.1 200 OK
< Date: Sun, 14 Jul 2019 17:38:40 GMT
< Server: Nexus/3.17.0-01 (OSS)
< X-Content-Type-Options: nosniff
< Content-Type: application/json
< Content-Length: 636
  "items" : [ {
    "downloadUrl" : "http://localhost:8080/repository/maven-snapshots/bla/bla/bla/bla-assemblies/x.y.z-SNAPSHOT/bla-assemblies-x.y.z-20190712.105616-6-linux.tar.gz",
    "path" : "bla/bla/bla/bla-assemblies/x.y.z-SNAPSHOT/bla-assemblies-x.y.z-20190712.105616-6-linux.tar.gz",
    "id" : "xxxxxxxxxx",
    "repository" : "maven-snapshots",
    "format" : "maven2",
    "checksum" : {
      "sha1" : "xxxx",
      "md5" : "xxxx"
  } ],
  "continuationToken" : null
* Connection #0 to host localhost left intact

Found the solution! Because of the HTTP 302, to get this to work the curl option -L (or --location) is needed (see SO):

curl -L -o myartifact.tar.gz -u xxx:xxx "http://localhost:8080/service/rest/v1/search/assets/download?sort=version&direction=desc&repository=maven-snapshots&maven.groupId=bla.bla.bla&maven.artifactId=bla-bla&maven.extension=tar.gz

The option -o (or --output) is used to put the curl output into a file.

Thanks for this great feature! :ok_hand:

1 Like


I need to download the artifacts that are only 60 days older. Is there any way to do the same using Nexus REST API mentioned above ?

I didnt get this working.
I am confused mave.classifier=&?

The html of the site cutoff my link and made it into a partial link. Does this make more sense?


classifier being empty is optional, you can remove it like so


It was just an example.

Hopefully that’s more clear. Sorry for my initial snafu.

Thanks. I ignored 74 [visit count] still my afternoon url didnt work. I ve tried, the Swagger - try it option. It was printing ascii characters, and then I copied url to unix shell and prefixed a wget, but no success.

I was also not sure of attributes - name vs maven.artifactId, format as maven2, so many probabilities.
My version is a snapshot, so removed prerelease=false, as I was getting a message like - no assets found…
My requirement - Get latest snapshot

Note: I specified one property[ dont remember now] to a value - jar, as I want the jar artifact

Thanks @bartweber jtom

I used the options @bartweber -L -o and -u credentials and was able to get latest snapshot

1 Like

When I add a maven.classifier= to my url, it does not slim down the results to items with no classifier as the documentation says it should. I’m running Nexus v3.16.1 right now.

Any ideas?