Manual 4

Chapter 4. Using the API

4-1. API code

If you open the dataset and select the “API” tab, API sample code and API key information are displayed.

By executing the API with your PC or PLC, in accordance with the sample code, you can send image data and receive inspection results.

If the size of the image to be sent is larger than 800 pixels, resize to 800 pixels.

4-2. Checking information on API details

If you select the “API” tab on the side menu, you can check the API usage situation for each dataset.

Detailed information for each dataset can be checked with the respective “Detail” buttons.

[Explanation of table]

Dataset NameName of the dataset
AI model NameName of AI model for the dataset
AI model IDID of AI model for the dataset
Created byUser who created the dataset
StatusAPI availability status for the dataset
Available: API can be used
Note available: API cannot be used
Restricted: API cannot be used (temporarily suspended)
Free API availableRemaining number of free API calls for this dataset
Email address to receive alertsEmail address for receiving alerts on the dataset
Additional Email address to receive alertsAdditional email address for receiving alerts on the dataset
Send an alert at the number 1Number of API uses for sending the first alert for the dataset
Send an alert at the number 2Number of API uses for sending the second alert for the dataset
Maximum number of APIs per monthMaximum number of API uses per month for the dataset
Send a test alert mailSend test alert for the dataset

Note 1) An API report can be displayed or saved for the current or previous year. If you will need data from two years or more earlier, save the data by downloading to your local disk.

4-3. How to set API use limit and alerts

To monitor and limit greater than expected use, the fee-based plan is provided with an API use limit and alerts. Set these as necessary.

Select the “API” tab on the side menu, and select “Detail” for the dataset for which you want to set the API use limit or alerts.

The maximum number of API uses per month can be set with “Maximum number of APIs per month”.

When the maximum number of API uses is attained, “Status” changes to “Restricted”, and the API can no longer be used. To resume use, increase the value of “Maximum number of APIs per month”, press the gear icon for “API Call Status” on the dataset detail screen, and reset to “Available”.

Using “Send an alert at the number” you can set up to a maximum of two API use counts for sending alerts.

4-4. API response

When a request is sent to the API for the image you want to inspect, the following values are returned in the JSON format.

AttributesTypes 
idstringAPI request ID
timedatetimeTime image sent to API was inspected
anomaly_scorefloatMaximum anomaly score of image sent to API
main_prediction_resultintegerJudgment results for image sent to API based on main threshold
0: Normal
1: Anomaly
sub_prediction_resultintegerJudgment results for image sent to API based on sub threshold
0: Normal
1: Anomaly
image_namestringName of image file sent to API
resultstringInspection results for image sent to API
Normal: Judged to be normal
Anomaly: Judged to be anomalous
Not-clear: Judged to require reinspection

When an API request succeeds, the status code 200 is returned. If the API is not available or the API request fails, a value other than 200 is returned as the status code.

Next Page