REST API documentation embedded in the application
Posted by Sarah Maddox
Our development team has built a tool that documents an application’s REST APIs within the application itself. What’s more, you can test the REST resources and methods too. All from the application’s user interface. Now, that’s embedded help for nerds.🙂 I’m writing this post because I think many technical writers and developers will be interested in this solution. It may trigger ideas about adding something similar to other applications too.
The tool is called the REST API Browser, and it is implemented as a plugin. At the moment, it is available only within the Atlassian Plugin SDK. In the future, you may be able to download the REST API Browser as a separate plugin and install it into any Atlassian application.
So, what does the REST API Browser do, what is the Atlassian Plugin SDK, and how can you get the REST API Browser to work within an Atlassian application?
Overview of the REST API Browser
This is what the REST API Browser looks like, when running inside an application called JIRA:
JIRA is an issue tracker developed by Atlassian. The above screenshot shows one of the JIRA administration screens, part of the application’s user interface. I’m running JIRA on my local machine, in plugin development mode. The REST API Browser is available as one of the options on the application’s administration screens. It’s as simple as that.
In the screenshot, you can see the resources in the JIRA REST API, starting at the /user/search resource. For each resource, the REST API Browser shows the methods (GET, POST, PUT) and the parameters available.
You can even do real-time testing of the APIs, by submitting a request and seeing the response. In the screenshot below, I have run a GET request using the /user/search resource, asking for details of username “admin”. You can see:
- A form, prompting you for the parameters relevant to the resource and method. In this case, the only parameter is the username.
- The request, as formulated by the REST API Browser.
- The response headers.
- The JSON in the response body.
The application’s REST APIs at your fingertips!
Which REST APIs does the Browser show?
The REST API Browser displays all the REST and JSON-RPC APIs available in the running installation of the application. That means all the remote APIs that are part of the application’s default installation (JIRA, in this case) as well as any additional REST APIs provided by a plugin.
So, if you install a plugin into JIRA, and that plugin exposes a REST API, the resources will show up in the REST API Browser too. Magic.
Introduction to Atlassian Plugin SDK
The Atlassian Plugin SDK is a tool for developers who want to create a plugin (add-on) for an Atlassian application. For example, you may want to add a new option to the Confluence page menu, showing all authors who have ever updated the current page. Or you may want to add a new option in JIRA that points to your organization’s intranet site.
But the SDK is useful even for people who don’t want to build a plugin. You can use the SDK to download and run an Atlassian application on your own machine, in plugin developer mode. One of the features that you get is the REST API Browser.
How can you get hold of such sweetness?
Here’s a quick start guide. First, install the SDK and use it to download and run your application:
- Follow the guide to installing the Atlassian Plugin SDK. Do just steps 1, 2 and 3. You can skip the last step, which sets up an IDE (Eclipse, IDEA or NetBeans), if you do not need a development environment.
- Create a directory in your file system to store the application executables. Let’s assume you want to run the REST API Browser in JIRA. Then, for example, you could create a directory called myjira.
- Open a command window.
- Go to the new directory that you just created, myjira.
- Run atlas-run-standalone --product APPLICATION. For example, atlas-run-standalone --product jira.
Note: There are two dashes in front of the word product.
After following the above steps, you will have the application running on your computer. When all the downloads and installation are complete (which may take a while), you will see a message in your command window that includes the URL for the local installation of the application.
For JIRA, the message will look something like this:
[INFO] jira started successfully in 174s at http://localhost:2990/jira [INFO] Type CTRL-D to shutdown gracefully [INFO] Type CTRL-C to exit
Now you can access the application in your browser and use the REST API Browser from the application user interface:
- Go to your web browser and enter the URL given for your application. For example, http://localhost:2990/jira.
- Enter the username and password: admin / admin.
- Go to the application’s administration screen. For example, in JIRA: Click Administration at top right of the screen.
- Click REST API Browser on the administration screen.
- Choose an API from the dropdown list at the top left of the screen.
- Choose a resource from the list on the left of the screen.
- See the methods (GET, POST, PUT, etc) and the parameters available for that resource.
- To test the resource, enter the parameter values as prompted then click Execute.
Getting technical: How the REST API Browser works
The source code is available on Bitbucket, as part of the Atlassian Developer Toolbox. The developer’s guide describes how to ensure that a REST API is included in the Remote API Browser. That document also gives a summary of how the browser is put together.
Pretty neat, huh
From a plugin developer’s point of view, the REST API Browser is very useful. From a technical writer’s point of view, I think it’s pretty revolutionary. Has anyone seen other examples of embedded REST API documentation?
Kudos to Rich Manalang and the Atlassian developer relations team for developing this shiny tool. Here is the blog post in which Rich announced it: Introducing the REST API Browser and the Atlassian Developer Toolbox.
About Sarah MaddoxTechnical writer, author and blogger in Sydney
Posted on 12 January 2012, in APIs, atlassian, online help, technical writing and tagged API documentation, atlassian, embedded help, JIRA, online help, plugins, REST API, technical communication, technical documentation, technical writing. Bookmark the permalink. 3 Comments.