Skip to main content

Repositories API

This set of endpoints is for interacting with repositories directly. These endpoints are used to create, update, and retrieve repository configuration. See the embedded Swagger documentation for details on how each format is used.

Accessing the documentation can be found using the following link:

<server-url>/#admin/system/api

List Repositories Example

GET /service/rest/v1/repositories

This endpoint lists the repositories the authenticated user has the browse permission to access. The ordering of results are consistent across queries, however, they are not alphabetical nor paginated.

curl -u admin:admin123 -X GET http://localhost:8081/service/rest/v1/repositories

This produces a response listing the repositories the user has permission to browse:

[{
  "name": "nuget.org-proxy",
  "format": "nuget",
  "type": "proxy",
  "url": "http://localhost:8081/repository/nuget.org-proxy",
  "attributes": {
    "proxy": {
      "remoteUrl" : "https://www.nuget.org/api/v2/"
    }
  }
},{
  "name": "maven-releases",
  "format": "maven2",
  "type": "hosted",
  "url": "http://localhost:8081/repository/maven-releases"
}]

Add a Repository Example

The below example is taken from the Swagger UI for adding a Maven-hosted repository and is listed for demonstration purposes only. Each format and repository type has different requirements that are documented in the Swagger interface. Building your query through the Swagger interface is recommended.

curl -X POST -u admin:admin123 'http://localhost:8081/service/rest/v1/repositories/maven/hosted' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'NX-ANTI-CSRF-TOKEN: 0.2000863451060393' \
  -H 'X-Nexus-UI: true' \
  -d '{
  "name": "maven-internal",
  "online": true,
  "storage": {
    "blobStoreName": "default",
    "strictContentTypeValidation": true,
    "writePolicy": "allow_once"
  },
  "cleanup": {
    "policyNames": [
      "string"
    ]
  },
  "component": {
    "proprietaryComponents": true
  },
  "maven": {
    "versionPolicy": "MIXED",
    "layoutPolicy": "STRICT",
    "contentDisposition": "ATTACHMENT"
  }
}