Sonatype Nexus Repository has new supported REST API endpoints that can automate your binary management needs. REST APIs allow clients to interact with an application, providing them with the capabilities of retrieving and transforming application data. Sonatype Nexus Repository endpoints make it possible to automate and seamlessly integrate with your tools and CI/CD pipeline.
A number of programming languages can be used to interact with Sonatype Nexus Repository. In the examples below we will be using the command line tool cURL in addition to the Groovy programming language . In this tutorial we will show you how to quickly get setup with Sonatype Nexus Repository by using its API endpoints to create a user, a repo, and user permissions.
Create a blobstore
Create a blobstore. This is the blobstore that we will be associating with our new repo.
Create a repository
We will need to create our repository and we will be using Groovy to accomplish this.
i) Create JSON file mavenScript.json. Here we are creating a script called "mavenRepo" which will create a hosted repository titled "ny-maven-internal":
Post script to Sonatype Nexus Repository
ii) Post this as a script to NXRM:
Run the script on Sonatype Nexus Repository
iii) Run this script on Sonatype Nexus Repository to create the repo.
Create a role
We need to create a role so that this can later be assigned to our new user. This role grants read and write permissions on repo ny-maven-internal.
Create a user
Create User. In this step we will assign this user the ny-dev-role we created in step 1.
That's it! In four steps you have created a user that has read/write access to their team's new repository.
You can view the full list of supported APIs in the UI or in our documentation here. For additional scripts you may find our community GitHub repo a fun place to stop by and say hello.

Written by Sable Yemane
Sable Yemane is a Sales Engineer at Sonatype focused on providing DevSecOps solutions to enterprises
Try Nexus Repository Free Today
Sonatype Nexus Repository is the world’s most trusted artifact repository manager. Experience the difference and download Community Edition for free.