Learning the Nexus REST API: Read the Docs or Fire Up a Browser
By Tim OBrien
2 minute read time
When you use Nexus, it is more than a UI. It is a collection of services available for you to automate. With these services you can integrate Nexus in whatever workflow makes sense for you. As a developer, this is what I look for in a product: something beyond the UI, something I can automate, and, most importantly, something that is documented. In Nexus, we've made it easy to start integrating Nexus REST services into your workflow by providing extensive documentation.
Yesterday's post was all about automating Nexus with REST services, and today's post is focused on giving you the tools you need to access the hundreds of REST endpoints you have access to with Nexus. If you are trying to automate anything in Nexus, you should know that there are two ways to "read" the Nexus REST API. You can access plugin documentation via the Nexus UI, or you can use a tool like Firebug in Firefox or Chrome's Developer Tools and inspect the requests generated by the Nexus UI.
Reading the Nexus REST Documentation
While Nexus has a rich set of hundreds of REST endpoints for everything from core actions like storing artifacts in a repository to professional features like procurement and staging, the documentation is little tough to find. Here are the steps you need to take to access this documentation:
- Login as an Administrator
- In the Administration section of the left-hand menu, click on Plugin Console to open the Plugin Console.
- Once in the Plugin Console you will see a list of Nexus Plugins. Click on a plugin to view the APIs it provides.
- Once you select a plugin, you should see a list of APIs. For example, the video below shows the Core API, click on the link in the Plugin Console to view the REST API documentation.
Here's a video walkthrough that shows you how to get to the Nexus REST documentation:
[iframe width="560" height="315" src="http://www.youtube.com/embed/EId8jXVOv7Q" frameborder="0" allowfullscreen/]
The REST API documentation is extensive and detailed, but there are often times when the best documentation for the Nexus REST API is Nexus itself. In these cases, fire up one of several modern browsers and just watch the network traffic...
Learning the Nexus API by Example
Nexus is a lightweight Javascript UI that connects to REST endpoints on the server-side. Unlike other repositories, the bulk of our application's UI logic happens in your browser. We don't do a round-trip to the server and ask for HTML, Nexus uses ExtJS and is communicating to these REST endpoints and exchanging JSON.
For us the REST API isn't just an extra feature that is "nice" to have, the Nexus UI is based on this REST API. Consider it solid and tested, we rely on it as much as you will come to rely on it. Everything you do in the Nexus UI is calling back to this API. This is why the best way to figure out how to interact with the Nexus REST API is often just fire up a tool like Chrome and watch what the UI is sending across the wire back to Nexus.
Here's a video that demonstrates how to use Chrome to spy on Nexus. This is often the fastest way to figure what your automation scripts need to do to automate common Nexus tasks:
[iframe width="560" height="315" src="http://www.youtube.com/embed/5k8_tJVk4BQ" frameborder="0" allowfullscreen/]
Written by Tim OBrien
Tim is a Software Architect with experience in all aspects of software development from project inception to developing scaleable production architectures for large-scale systems during critical, high-risk events such as Black Friday. He has helped many organizations ranging from small startups to Fortune 100 companies take a more strategic approach to adopting and evaluating technology and managing the risks associated with change.
Explore All Posts by Tim OBrienTags