The API Explorer, all you need to start using the Liferay Headless APIs

Browse, learn and try the Headless API using the API Explorer

The API Explorer is an integrated application inside Liferay Portal offering all you need to familiarize and start using the Liferay Headless APIs.

To access the API Explorer:

  1. Start the portal.
  2. Sign in.
  3. Navigate to /o/api URL. 

There you will find the updated documentation of all the APIs that are available on your Liferay instance for REST and GraphQL.

Using the API Explorer to explore REST APIs

The REST view is the default view and the one that you will see when you enter the application.

If you have already used SwaggerHub to search API docs, you will probably find the interface so familiar, as we are using the same technology under the hood.

In the upper right corner of the screen you have a dropdrdown menu to select between every API group/category available in the portal. When you select one of them, the page will list all available endpoints, methods for each endpoint and schemas.

But you don’t need to stop at the docs, you can make some test requests inside the application:

  1. Look for the endpoint you want to test inside the list of endpoints.
  2. Click in the endpoint to expand the endpoint detail information.
  3. Click the Try it out button.
  4. Fill the required parameters and request body if needed.
  5. You can also add Headers to be sent in the request in the upper right corner of the screen
  6. Click the Execute button.
  7. See the received response with the actual data that exists in your portal instance. (The API explorer is invoking the actual endpoints in your installation)
  8. You can also copy the equivalent curl command to use it from your terminal


This is a great way to explore and find the useful APIs for your application, test the requests and then implement them in your code.

Using the API Explorer to explore GraphQL queries and mutations

If you are more into using GraphQL than REST APIs, you can also explore all the available queries and mutations of your portal instance clicking in the GraphQL link in the top right corner of the screen to change to the GraphQL view.

The GraphQL view uses GraphiQL so it should be familiar to those who have used that tool before. For those who have not, it presents three columns:

  • The Query Editor to write your GraphQL queries, with autocomplete capabilities and validation.

  • The Response Window to check the resulting response.

  • The Doc Explorer to explore the documentation of all available queries, mutations and types.

To make a test request:

  1. Start writing your request in the Query Editor. Let the autocompletion and validation help you to find what you are looking for.

  2. You can use the Doc Explorer to check the queries and mutations available, required parameters and type definitions.

  3. Click the ▶ button to execute the query.

  4. See the received response with the actual data that exists in your portal instance.


 

Add the API Explorer to your toolbox

Whether you use REST or GraphQL to access the features exposed through the Headless API, adding the API Explorer tool to your flow will allow you to increase your development productivity with an easy way to find and understand the API, and try your requests to get the information you need before you implement them in your code.

And all of it right away within your Liferay installation, without the need of external tools!

If you have a Liferay bundle installed, just point your browser to /o/api and start playing around with the APIs

Important!

Don't forget to visit our official documentation to find a complete and detail description on how to consume our REST and GraphQL APIs:

https://learn.liferay.com/dxp/7.x/en/headless-delivery/consuming-apis/consuming-rest-services.html

https://learn.liferay.com/dxp/7.x/en/headless-delivery/consuming-apis/consuming-graphql-apis.html