Skip to content
Adam Bittlingmayer edited this page Apr 17, 2020 · 19 revisions

For the cloud-based ModernMT API, see https://www.modernmt.com/api/

ModernMT comes with built in REST API that allows the user to control every feature of MMT via a simple and powerful interface.

Methods

Translation

Memory

Tags Projection

Admin

  • GET / - Get the server metadata, such as the build number, version number and cluster topology.

General Notes

All APIs responses have a common structure that allows the user to quickly understand if the request returned a valid output or if an error occurred. This is the positive response wireframe:

{
    "data": "...request specific data..." ,
    "status": 200
}

In case of error, the API will send back a response like the following:

{
    "error": {
        "message": "Missing parameter text",
        "type": "ParameterParsingException"
    },
    "status": 400
}

Error Codes

In an error response you can always find error.message that contains a text that explains the error and error.type that is the id of the error.

The ModernMT API uses the HTTP status codes to identify which type of error has occurred. The status field in the response is always the same as the HTTP status code, it is reported twice just for convenience.

  • Status 2xx: OK - The API returned successfully.
  • Status 4xx: CLIENT ERROR - The API has detected a problem with the request made by the caller (a missing parameter or a nonexistent API).
  • Status 5xx: SERVER ERROR - The API has failed unexpectedly for an internal server error.

Input format

MMT support XML input type for translations. XML tags are extracted from the source text, and re-inserted in the translation in the right position, based on the translation alignments.

During the pre-processing:

  • XML Tags are identified and extracted from the text.
  • Pure text is then de-escaped: XML entities are replaced with the actual literal (e.g. &lt; is replaced with char <).

The text is then translated by the decoder. During the post-processing step:

  • Text is then escaped following the XML conventions. Characters ", ', <, > and & are escaped in &quot;, &apos;, &lt;, &gt; and &amp;.
  • XML Tags are positioned in the translation based on the alignments. Tag's content is kept untouched.

See the following example:

  • Input: You&apos;ll see the <div id="example-div">example</div>!
  • Preprocessed: You 'll see the example !
  • Translation: Vedrai l' esempio !
  • Postprocessed: Vedrai l&apos;<div id="example-div">esempio</div>!