MyScript iink SDK Web REST Overview

Overview

Call to the REST API of the iink SDK allows you to easily recognize digital content from your already collected strokes. The REST iink recognition APIs consist of two endpoints which take charge of several types of recognition:

  • <host_of_rest_endpoint>/api/v4.0/iink/batch/ allows you to use our legacy recognitions engines.
  • <host_of_rest_endpoint>/api/v4.0/iink/recognize/ allows you to use our latest recognitions engines.

Each call to the API allows you to perform iink recognition and output in the requested format.

While each recognition endpoint has specific parameters described in the next pages, the following sections describe parameters and behaviors common to both endpoints.

Swagger API specifications

The swagger API specification of the iink SDK REST recognition is embedded in the REST endpoint.

You can reach it getting <host_of_rest_endpoint>/rest_endpoint/api-docs.

It can be useful to use a client UI in order to get the API in a human-readable form. For example, Swagger UI

For example, the Swagger specifications of MyScript's cloud production environment can be reached here in a raw format and here using SwaggerUI.

Output formats

The setting of the output format is compliant with HTTP standards. The required mime type of the recognition result must be set in the Accept HTTP header . Available mime types depend on the recognition type and endpoint. The recognition service will choose the first available mime type of the list as the output mime type and set accordingly the Content-Type HTTP header of the response.

Jiix is a common JSON format introduced by MyScript that can be used as an output for most type of recognition. Its content can be parametrized in the [configuration]confJiix. Its mime type is application/vnd.myscript.jiix.

Because the error output is in JSON format, application.json MUST appear in the list of mime type in the Accept HTTP header.

The recognition service does not recognize the following features of the Accept HTTP header and will send an error if found:

  • Range type or subtype (*/*, application/*)
  • Factor weighing (;q=0.5)

Example of valid Accept HTTP header for text recognition : "application/vnd.myscript.jiix,application/json".

Credentials

To use the iink REST APIs, you need to register with MyScript Cloud or install and configure a MyScript Server instance, and then retrieve both an application key and an HMAC key.

The application key has to be set as-is in every call to the API in the applicationKey header of the HTTP request. The HMAC authentication code is computed using:

  • The SHA-512 algorithm
  • The whole body of the HTTP Request as the message to be hashed
  • The concatenation of the application key and the hmac key as the user key.

The resulting code has to be set in the hmac header of the HTTP request.

Please find here a javascript example of computing the HMAC code.

Body of the request

The body of the request contains several parts to adjust the recognition, that depend on the recognition engines. All requests include the strokes coordinates of the ink to recognize.

Any x and y coordinate has to be calculated from the starting point as described below.

Response

Response structure

Any call to the iink REST SDK returns the 200 HTTP code if everything goes smoothly with the output result in the body of the response. The Content-Type HTTP header is set accordingly to the output format.

Should any problem occur during the recognition process, the HTTP return code is set to a different value and the response contains a JSON object which structure is:

attributeDefinition
codeThe code of the error
messageA message that gives more information about the error

Errors

When it is relevant, a location of the error is provided in the message. In that location information, the first index of arrays is 0.

Http codeError codeExplanation
400recognition.invalid.strokeThere is a problem with the structure and/or the values in the definition of a stroke. That can be arrays not having same sizes or empty stroke or coordinates outside the writing area (too big or negative).
400recognition.stroke.emptyA stroke is empty.
400recognition.stroke.missing.arrayA mandatory array is missing in a stroke.
400recognition.stroke.wrong.array.sizeAn array has a wrong size. In a stroke, X, Y, P and T arrays must have the same size if they are provided. The reference for the excepted size is the X array.
400recognition.stroke.null.valueThere is a null value in an array of a stroke.
400recognition.stroke.negative.valueThere is a negative value in P or T array in a stroke.
400recognition.stroke.timestamp.too.bigA time value in a T array of a stroke is beyond the maximum timestamp.
400recognition.stroke.chronological.errorTwo sequential time values in a T array do not respect chronological order.
400recognition.no.strokegroup.foundThere is no strokeGroup in the payload.
400recognition.strokegroup.emptyThere is no stroke information in a strokeGroup.
400recognition.invalid.pointer.typeThe pointer type was not set with an authorized value.
400recognition.limit.exceededThe ink that was sent exceeds the capacity of the recognition engine. It is likely that the ink contains too many strokes that cannot result in a structured document.
400configuration.resource.not.foundThe [resource]textCustom you used for the recognition was not found. It has to be [built]textCustomBuild before recognition.
400configuration.resource.duplicate.math.grammarTwo math grammars were provided, one by id and one by content. There can be only one math grammar provided for a math recognition.
400configuration.resource.bad.grammarThere are compilation errors in the provided math grammar.
400configuration.invalid.themeThe provided theme is not valid CSS.
400configuration.invalid.pen.styleThe provided penStyle is not valid CSS.
400configuration.invalid.pen.style.classesOne of the provided penStyleClasses does not refer to a class from the theme.
400configuration.invalid.conversion.stateThe conversionState is invalid.
400recognition.conversion.state.not.supportedThe conversionState is not valid for this type of recognition.
400api.json.errorThe body of the request is not valid JSON.
400api.missing.invalid.parameterA mandatory parameter is missing.
400api.unrecognized.propertyAn unrecognized parameter has been found.
400api.invalid.formatA property doesn't have the required format (for example int instead of string).
400api.mapping.errorGeneral JSON mapping error.
400incorrect.ink.errorThe ink is incorrect (for example when a stroke has too many points).
401access.not.grantedThe application key does not exist or the HMAC signature is invalid. Please refer to documentation of credentials.
403access.account.counter.threshold.reachedA counter of your application has reached aconfigured threshold. Please refer to the pricing page.
403access.account.disabledThe account that owns the application key is disabled. Please contact support or use another application key.
403access.account.expiredThe account that owns the application key has expired. Please consider registering another account or using another application key.
403access.account.not.activatedThe account that owns the application key is not activated. Please contact support or use another application key.
403access.application.deletedThe account that owns the application key has been deleted. Please consider registering another account or using another application key.
403access.application.disabledThe application relative to the application key is disabled. Please contact support or use another application key.
403access.invalid.application.keyThe application key has been revoked. Please consider registering another account or using another application key.
403access.bad.ip.addressThe call to the API is not granted from this IP address. Please contact support.
403access.bad.refererThe call to the API is not granted for this HTTP referer. Please contact support.
403access.empty.cartridgeYour cartridge is empty. Please refer to the pricing page.
403access.empty.global.cartridgeThe global cartridge of your site is empty. Please refer to the pricing page.
403access.invalid.languageThe asked language is not authorized for your application. Please control that the language code you provided exists or refer to the pricing page or contact support.
403access.ip.filter.rejectedThe IP address of the caller does not match the set IP filter. Please contact support.
403access.mandatory.parameterThe application relative to the application key is configured to need a mandatory parameter. Please contact support.
403access.quota.exceededA qouta has been exceeded for the applicationrelative to the application key. Please contact support.
403access.recognition.typeThe application relative to the application key does not have access to the asked recognition type. Please contact support.
403access.revokedThe application relative to the application key has been revoked. Please consider registering another account or using another application key.
403access.userid.missingThe application relative to the application key requires an userID. Please contact support.
413access.payload.too.bigThe payload size exceeds the server limits.
416recognition.no.suitable.mime.typeNo mime type acceptable for the type of recognition was found in the Accept HTTP header. Please refer to the docupentation to find out what mime type you can use.
500internal.errorInternal error. Please contact support and provide the corresponding message.