Typical API use

In this section, you will find a typical API use example. We will analyze the text Power is not passing. using the productnoise model.

Prerequisites

To use the API you will need:

  • an active API key (see more about the API key here). The key value must be sent in every request in x-api-key header value.

  • a REST API / HTTP client. For example purposes, we will use Swagger embedded in the Smabbler Portal, but you can use any other client like Postman, Insomnia, curl, etc.


Typical use example

For example purposes, Swagger embedded in Smabbler Portal will be used as API client.

Initialize analysis

Each analysis in the Smabbler API must start with an /analyze/initialize POST request. This request will initialize the analysis in the Smabbler API system.

The following parameters should be included in the JSON request body:

  • algorithmVersion - the language model identifier used for the analysis (see more about language models here). For example purposes, set the value to productnoise.

  • text - the text to analyze. For example purposes, set the value to Power is not passing..

Send the request and wait for the response:

At this stage, the analysis was initialized by Smabbler system. The request result contains an operationId field, which is a unique analysis identifier. This identifier is needed for analysis status checks and / or analysis results gathering.

Check analysis status

After initializing the analysis you can check its status. You will need the operationId identifier from the previous step (/analysis/initialize request response).

To check the analysis status, send /analyze/status POST request with the operationId identifier set in the JSON body:

Send the request and wait for the response:

Observe the status field in the response (see Analysis statuses docs to find out more). In our example, the analysis is in processed status and we can acquire the results.

Fetch analysis results

If the analysis has been completed and the status is processed, you can fetch the analysis results. You will need the operationId identifier from the previous step (/analysis/initialize request response).

To fetch the results, send an /analyze/result POST request with the operationId identifier set in the JSON body:

Send the request and wait for the response:

The analysis results can be found in the result field of JSON response body.

Last updated