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.

Generic Endpoints

The Repositories API lists a few generic endpoints for searching through all repositories and format type specific endpoints to list the complete details of a specific repository.

Use these endpoints to query all repositories.

  • /service/rest/v1/repositories

    /service/rest/v1/repositories/{repostoryName}

    Lists all repositories configured in the Nexus Repository instance. The name attribute may be included to return limited details on a specific repository.

    See Listing Repositories

  • /service/rest/v1/repositorySettings

    Lists all repositories, however, this endpoint includes the complete settings for each repository. Use the format and type specific endpoints to return the results for a single repository.

    See Get Specific Format and Repository Type

Listing Repositories

This generic 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.

GET /service/rest/v1/repositories
GET /service/rest/v1/repositories/{repostoryName}

The contents of this endpoint is limited for attributes associated with specific formats and repository types. To provide full configuration details for the repository, use the format and type specific endpoints.

See Get Specific Format and Repository Type

Example request

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",
  "size": 495186797,
  "attributes": {
    "proxy": {
      "remoteUrl" : "https://www.nuget.org/api/v2/"
    }
  }
},{
  "name": "maven-releases",
  "format": "maven2",
  "type": "hosted",
  "url": "http://localhost:8081/repository/maven-releases",
  "size": 385809438,
  "attributes": {}
}]

Get Specific Format and Repository Type

Full configuration details are available when including the specific format and repository type within the request for a repository.

GET /service/rest/v1/repositories/{format}/{type}/{repostoryName}
  • format: The repository package format of the repository. (e.g., maven2, npm, pypi, docker)

  • type: One of the primary repository types: proxy, hosted, group

  • repositoryName: The name of the repository.

Repository Parameters

The returned repository parameters are different depending on the format/type combination of the repository. For instance, group repositories include their memberlist while proxy repositories include their remoteUrl. Even some configuration may not include the same parameters when they have not been set.

Scripts using the API should first test for the presence of parameters before accessing them. Review the swagger output for a complete listing depending on the repository format and type.

Adding a Repository

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' \
  -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"
  }
}