We made an API Playground available that offers an interactive way to discover the Nuxeo Platform API. This module runs fully client side in JavaScript, and makes use of the API of Nuxeo Platform it targets. You can use it on any server as long as you deploy a CORS configuration on it.
Functional Overview
Nuxeo API Playground can be used online at http://nuxeo.github.io/api-playground/ or locally at http://NUXEO_SERVER/nuxeo/playground
after you install the Nuxeo Package on your server (see the Installation and Configuration section).
Note that the online version proposes to connect the API Playground to our demo.nuxeo.com instance by default, but you can use it with your own Nuxeo server.
Repository
As you play with the APIs, you will modify the content of the repository. The Repository section of the playground will let you check the impact of your API call attempts.
The content is represented as a tree which allows you to navigate the repository. Unfold the tree and click on a document. Its content is retrieved through the REST API with the JSON response and headers displayed on the right panel.
The default GET tab allows you to invoke adapters on the current document as well as toggle content enrichers. By default the thumbnail
and breadcrumb
enrichers are selected since they are used to build the header where this information is shown. Selecting an adapter shows a form with its parameters, if any.
Data Structure
One of the main cases of using the API is to create/read/update documents. For doing so, you need to know what properties are expected for your document. The Data Structures section helps you understand it, by listing all the document types, facets and schemas that have been configured on your Nuxeo Platform repository.
For instance, to get information about the userWorkspaceRoot
document type:
- In Types, click on the
userWorkspaceRoot
document type. - Click on the icon .
The complete inheritance structure of
userWorkspaceRoot
is displayed. - Click on one of the schema names, like dublincore for instance, to see its structure.
Resources Endpoints
In this section you can perform calls to all the "Resources" endpoints.
Depending on the endpoint, you can do GET, PUT, POST or DELETE calls to read, update, create and delete documents.
- Click on the resource endpoint you want to work on and then on the call you want to make.
- Fill in the Parameters form.
Tips:
- For Resources of type document, you can select the document in the repository tree by clicking on the icon , without having to type its exact id.
- For all the resources, when you want to do a PUT (most of the time to update the resource), you can click on the Fetch document button to prefill the body parameter of your request with the document JSON definition. Then you just need to modify the property you want to update.
- When you are doing a POST call and need an example of the expected JSON object, click on the value displayed in the Type column. The documentation of the corresponding JSON structure opens.
- Optionally click on the icon
Click on the Run button. You get three tabs:
- The Response content, most of the time a JSON string, but sometimes the returned error, or a bite stream if the answer was a binary.
- The headers both of the request and the response:
- The CURL syntax of the request
This tab is a key one as it allows you to reproduce the same call on your own environment/shell so as to make sure you didn't miss anything for building a successful request.
- The Response content, most of the time a JSON string, but sometimes the returned error, or a bite stream if the answer was a binary.
Command Endpoint
The command endpoint section lists all the available operations and chain of operations available on the server. You can then run an operation by filling the expected input (nothing, documents or binaries) and then get the output.
- Click on operation category and then on the operation you want to run.
- Fill in the operation parameters form. See the Operation parameters documentation or operations list on the Explorer for more information on the parameters. Tip: For document input, click on the icon to browse the repository tree and find your document, instead of typing the document path.
- Optionally click on the icon
Click on the Run button. You get three tabs:
- The Response content, most of the time a JSON string, but sometimes the returned error, or a bite stream if the answer was a binary.
- The headers both of the request and the response:
- The CURL syntax of the request
This tab is a key one as it allows you to reproduce the same call on your own environment/shell so as to make sure you didn't miss anything for building a successful request.
- The Response content, most of the time a JSON string, but sometimes the returned error, or a bite stream if the answer was a binary.
Batch Upload
The Batch Upload endpoint provides a way to upload one or more files and then reference that set of files from the API (PUT and POST calls, operation parameters, etc.). This approach is favored over regular HTTP MultiPart encoding upload in the following cases:
When you have several files to upload
When your client does not natively support multipart encoding
- When you want to upload files as soon as possible and then run the operation when everything has been uploaded on the server
Pre-Requisites
Because the Nuxeo API Playground currently uses the old API, you need to some configuration to enable. See the section Enabling Batch Upload.
Creating a Batch Upload
- Select one or more files to upload.
- Click the Upload button. Once your files are uploaded the batch will be displayed in the list of batches. You can create any number of batches before referencing them in your requests.
Using a Batch Upload
- Click on the Reference a batch button which is displayed for any JSON document parameter.
file:content
value is displayed. - Copy the relevant part of the JSON definition in the form.
- Click on the Run button.
Installation and Configuration
Installing Nuxeo Playground
This addon requires no specific installation steps. It can be installed like any other package from the Update Center or using the nuxeoctl command line.
After you installed the Nuxeo Package, go to http://NUXEO_SERVER/nuxeo/playground
to use the API Playground. Note that it suggest to log in to the public website demo.nuxeo.com by default. Make sure you change the URL to use your server's (http://NUXEO_SERVER/nuxeo
by default).
Enabling Batch Upload
Batch Upload on the API Playground currently uses the old API which is currently deprecated but kept for backward compatibility. It also relies on client side generated batch ids which must to be enabled so the upload from the API Playground UI works.
To enable Batch upload set the runtime configuration property allowClientGeneratedBatchId
to "true", using an XML extension.
<component name="org.nuxeo.ecm.automation.server.BatchManager.configuration.test">
<extension target="org.nuxeo.runtime.ConfigurationService" point="configuration">
<property name="allowClientGeneratedBatchId">true</property>
</extension>
</component>
Setting up a CORS Configuration
If your Nuxeo server and the API Playground are not in the same domain, you need to set up a CORS configuration. We provide a sample configuration file that works as long as you put it in the NUXEO_HOME/nxserver/config
folder. Read the CORS documentation for more details.