Assets API

Available in Nexus Repository OSS and Nexus Repository Pro

Introduction

This set of endpoints is for interacting with assets directly.

Endpoints

List Assets

GET /service/rest/v1/assets

This endpoint allows us to iterate through a listing of assets contained in a given repository.

Let's get a listing of the assets in the maven-central repository:

curl -u admin:admin123 -X GET 'http://localhost:8081/service/rest/v1/assets?repository=maven-central'

This produces a response that is the first pages of many assets in that repository:

Example Response
{
  "items" : [ {
    "downloadUrl" : "http://localhost:8081/repository/maven-central/asm/asm/3.1/asm-3.1-sources.jar",
    "path" : "asm/asm/3.1/asm-3.1-sources.jar",
    "id" : "bWF2ZW4tY2VudHJhbDozZjVjYWUwMTc2MDIzM2I2MTRkZWJlOTExOGFjNjMwOQ",
    "repository" : "maven-central",
    "format" : "maven2",
    "checksum" : {
      "sha1" : "2eaa4de56203f433f287a6df5885ef9ad3c5bcae",
      "md5" : "0c0e3e83d9ce7907334c5eb519dab10c"
    }
  },
...
  ],
  "continuationToken" : "3f5cae01760233b6506547dc7be10e0b"
}

This endpoint uses a pagination strategy that can be used to iterate through all the assets if desired.

Note that the ordering of assets is consistent across multiple queries and is not alphabetical.

Get Asset

GET /service/rest/v1/assets/{id}

This endpoint allows us to get the details of an individual asset.

curl -u admin:admin123 -X GET 'http://localhost:8081/service/rest/v1/assets/bWF2ZW4tY2VudHJhbDozZjVjYWUwMTc2MDIzM2I2MjRiOTEwMmMwMmNiYmU4YQ'
Example Response
{
  "downloadUrl" : "http://localhost:8081/repository/maven-central/org/sonatype/nexus/buildsupport/nexus-buildsupport-metrics/2.9.1-02/nexus-buildsupport-metrics-2.9.1-02.pom",
  "path" : "org/sonatype/nexus/buildsupport/nexus-buildsupport-metrics/2.9.1-02/nexus-buildsupport-metrics-2.9.1-02.pom",
  "id" : "bWF2ZW4tY2VudHJhbDozZjVjYWUwMTc2MDIzM2I2MjRiOTEwMmMwMmNiYmU4YQ",
  "repository" : "maven-central",
  "format" : "maven2",
  "checksum" : {
    "sha1" : "a3bf672b3ea844575acba3b84790e76ed86a7c66",
    "md5" : "49e439c814c3098450dc4bbee952463f"
  }
}

Delete Asset

DELETE /service/rest/v1/assets/{id}

This endpoint can be used to delete an individual asset.

curl -u admin:admin123 -X DELETE 'http://localhost:8081/service/rest/v1/assets/bWF2ZW4tY2VudHJhbDozZjVjYWUwMTc2MDIzM2I2MjRiOTEwMmMwMmNiYmU4YQ'

A successful deletion will return no content, for example:

Example Response
HTTP/1.1 204 No Content
Date: Fri, 19 Jan 2018 20:41:47 GMT
...