What's Swagger UI? How to access it & test out API endpoints? - LabCollector

Search Knowledge Base by Keyword

You are here:
← All Topics

LabCollector  offers various set-up options. It is ready-to-use (insofar as is possible), its configuration can be easily managed by the Super-Admin in order to meet your specific laboratory requirements. As part of this, LabCollector provides a Swagger UI that enables you to explore and test the REST API.

Swagger is a web-based interface that provides a user-friendly way to interact with the API. It allows users to view the available API endpoints, their parameters, and the responses they return. Users can also send requests to the API and view the responses in real-time.

In the following Knowledge Base, we will walk you through how to use the LabCollector’s Swagger, we will also cover how to access the Swagger UI, how to explore and test the available API endpoints, and how to generate documentation automatically based on the OpenAPI specification.

1. How can I access LabCollector’s Swagger?

2. How to test out API endpoints?

1. How can I access LabCollector’s Swagger?

To configure your web services API, simply go to ADMIN -> OTHER -> SETUP -> Web Services API:

  • A new range of applications based on your LabCollector instance can be implemented and developed.
  • Using LabCollector as a backend database, the laboratory can provide remote information in external catalogs, biological resources, etc.
  • LabCollector offers you API services that can help you connect a third-party application to LabCollector.

           * For more information, please refer to this KB.

Swagger can be easily accessed by clicking on the orange icon located to the right of the Application you want to integrate (as shown in the screenshot below).

Once you have clicked on the corresponding Swagger icon, a new popup will appear displaying the message “Generating swagger could take a few seconds“. Since generating the OpenAPI specification can take some time depending on the complexity of the API itself. Once you are ready, simply click on “Create Swagger for this app” to access the Swagger UI.

If you have previously created a Swagger for an app, clicking on the Swagger icon will open a popup that gives you the option to either show the current Swagger or refresh it to generate a new one. This is particularly useful if changes have been made to the API since the last time the Swagger was generated.

The popup also displays the last time the Swagger was updated, which help you keep track of the Swagger’s validity and can be especially useful for large APIs that are frequently updated.

For example, suppose you have made some changes to your LabCollector API endpoints, such as adding or modifying parameters, and you want to ensure that the Swagger accurately reflects these changes. In that case, you can simply refresh the Swagger by clicking on the refresh button, and a new Swagger will be generated with the updated information.

1. How to test out API endpoints?

Once you have created a Swagger for your chosen app, you will be automatically redirected to the Swagger UI interface, which displays a list of available API endpoints on the left-hand side of the screen (as shown in the screenshot below). This user-friendly interface allows you to easily explore the API’s capabilities, test it, and generate documentation based on the OpenAPI specification.

Then, click on an endpoint to view its details, including its parameters and the responses it returns, In our example, we can see all the modules and their corresponding endpoints, alongside a brief description of their action. For instance, we can see that GET/strains works on getting records from the module Strains & Cells, POST/strains works on adding records to the same module… etc.

To test an endpoint, click the “Try it out” button and enter the required parameters (as shown in the screenshot below). This is particularly helpful when developing and testing new endpoints before integrating them into your application.

Finally, once you have entered all your parameters, click on the “Execute” button to send the request to the API and view the response.

You can then see the result of your request, alongside all bad / unauthorized / forbidden requests if there were any.

Furthermore, the Swagger UI allows you to generate documentation automatically based on the OpenAPI specification. This documentation can be downloaded in various formats, such as PDF or JSON, and can be used to communicate the API’s capabilities to other developers.

Using the LabCollector Swagger UI, you can explore the available API endpoints and test their functionality without writing any code. This makes it easy to understand how the API works and helps integrate LabCollector with other systems.

Related topics: