Saturday, July 28, 2018

ModernMT Enterprise Edition API Documentation

ModernMT Enterprise Edition is available through publicly available REST API that allows you to request translations, manage your memories and check your billing profile.

Api key

In order to use ModernMT Enterprise edition you need an api key. If you do not have an api key yet, you can get one here: https://www.modernmt.eu/license/buy.
For every API request you have to include an HTTP Header with name MMT-ApiKey and your api key as value.
MMT-ApiKey: 01234567-8901-2345-6789-012345678901

Client Identity

Clients for ModernMT Enterprise Edition should also specify a few more details when sending requests to ModernMT APIs. These data mainly concern the client identity, and they can be extremely valuable in our support activities to our clients, allowing us to track the traffic from and to a specific client, and letting us immediately intervene in case of necessity. These client identity data should be set as HTTP Headers in the client requests:
  • MMT-Platform: the name of the software that is using ModernMT Enterprise edition (example: “MyWonderfulCATTool”).
  • MMT-PlatformVersion: the version of the software that is using ModernMT Enterprise edition (example: “2.1.3”).
  • MMT-PluginVersion: the version of the plugin that is being used to call the ModernMT Enterprise edition APIs (example: “1.1”).
The ideal requests, therefore, looks like this (using curl for simplicity):
curl -H "MMT-ApiKey:<my_api_key>" \
-H "MMT-PluginVersion:<my_plugin_version>" \
-H "MMT-Platform:<my_platform_name>" \
-H "MMT-PlatformVersion:<my_platform_version>" \
http://api.modernmt.eu/... 

Endpoints

A REST endpoint consists of an HTTP method and a path to the resource. Usually the HTTP method describes the action, while the path identifies the resource or the service you are interacting with.
There can be cases in which the caller is limited in the use of HTTP methods for tecnical reasons or by HTTP protocol limitations (i.e. max allowed GET request length). For this reason ModernMT allows you to use any actual HTTP method, while separately declare the REST API method through the X-HTTP-Method-Override header.
For example, it is allowed to request a translation with an HTTP POST request like this:
curl -X POST \
   -H 'X-HTTP-Method-Override: GET' \
   -H 'MMT-ApiKey: <your_api_key>' \
  'http://api.modernmt.eu/translate?source=en&target=it&q=Hello'

Translation

Memory

User and Billing

General aspects

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 &lt;, &gt; and &amp;.
  • XML Tags are positioned in the translation based on the alignments. Tag’s attributes are 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'<div id="example-div">esempio</div>!

Quick Example

curl -X GET \
   -H 'MMT-ApiKey: <your_api_key>' \
  'http://api.modernmt.eu/translate?source=en&target=it&q=Hello=&context=Mr%20President' \
   | python -mjson.tool

{
    "data": {
        "contextVector": {
            "entries": [
                {"memory": {"id": 1, "name": "europarl"}, "score": 0.20658109},
                {"memory": {"id": 2, "name": "ibm"}, "score": 0.0017772929}
            ]
        },
        "translation": "Ciao"
    },
    "status": 200
}

Description

This method returns the translation of the provided text. The text is XML encoded and can contain XML Tags. Since one ModernMT Engine may supports multiple language pairs and directions, you need to specify the source and target languages.

Resource URL

http://api.modernmt.eu/translate

Parameters

source The language tag of the source language.

Example: en
target The language tag of the target language.

Example: it
q The text to translate in XML format (XML tags accepted, text must be XML-encoded).

Example: This is an example
context_vector
optional
The context vector to use in the translation, as a series of comma-separated key-value pairs `id1:score1,id2:score2,...`.

Example: Example: 1:0.34,3:0.045
hints
optional
A list containing the Memories to use for this translation.

Example: 10
type
optional
The type of translation request. It can be either interactive or batch. Default value is interactive.

Result

translation The translation of the input sentence.
contextVector The Context Vector object calculated by analyzing the context text provided. For more details on the object format, please have a look at <a href=/apis/api-get-context-vector.md>API Get Context Vector.

API Get Context Vector

Quick example

curl -X GET \
     -H "MMT-ApiKey: <your_api_key>" \
     "http://api.modernmt.eu/context-vector?source=en&targets=it&text=Hello" \
     | python -mjson.tool

{
    "status": 200,
    "data": {
        "source": "en",
        "vectors": {
            "it": "4:1,5:0.042476345"
        }
    }
}

Description

This method returns the Context Vector containing the best-matching domains and their scores for the provided content. The score is the cosine similarity between the given context, and that domain.

Resource URL

http://api.modernmt.eu/context-vector

Parameters

source The language tag of the source language

Example: en
targets The target languages, as a series of comma-separated language tags

Example: it,es
text
optional
The context text to be analyzed.

Example: Mr President
content
optional
This parameter can be used to upload and calculate the Context Vector of a large file. In order to do that, Content-Type: multipart/form-data` and X-HTTP-Method-Override: GET headers must be specified and a POST request must be used instead of GET.
compression
optional
While using the "content" parameter, if the content file is compressed you need to specify the compression type. So far only GZIP compression is supported.

Example: gzip
hints
optional
A list containing the Memories to force the use of in this translation.

Example: 1,4

Response Fields

source The source language
vectors An object containing, for each supported target language, the corresponding Context Vector

API Get Memories

Quick example


curl -H "MMT-ApiKey:<my_api_key>" http://api.modernmt.eu/memories | python -mjson.tool

{
    "status": 200,
    "data": [
        {
            "id": 5,
            "key": "mk_f4932hg205vh7h20h05g72",
            "name": "BeautifulMemory",
            "description": "My most precious memories",
            "externalId": null,
            "creationDate": "2017-10-13T13:32:34+00:00"
        },
        {
            "id": 9,
            "key": "mk_890qjf8hf0qhf04hf7403f",
            "name": "EvenMoreBeautifulMemory",
            "description": "My even more precious memories",
            "externalId": null,
            "creationDate": "2017-11-13T13:33:01+00:00"
        }
    ]
}

Description

This method retrieves all the memories associated to the owner of the MMT-ApiKey header used in the HTTP Request.
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}

Resource URL

http://api.modernmt.eu/memories

Request Fields

None.

Response Fields

This API returns an array containing multiple Memory objects. Each Memory object contains the following fields:
id The ModernMT Memory id for this Memory.

Example: 5
key The ServiceApi Memory key for this Memory.

Example: mk_f4932hg205vh7h20h05g72
externalId Private parameter for internal use only
name The name with which this user was linked to the memory.

Example: BeautifulMemory
description The description with which this user was linked to the memory.

Example: My most precious memories
creationDate A timestamp marking the instant that the Memory was created.
It refers to the creation of the actual Memory, and not to the moment when the User connected to it.

Example: 2017-10-13T13:32:34+00:00

API Get Memory

Quick example


curl -X GET -H "MMT-ApiKey:<my_api_key>" http://api.modernmt.eu/memories/5 | python -mjson.tool

{
    "status": 200,
    "data": {
        "id": 5,
        "key": "mk_f4932hg205vh7h20h05g72",
        "name": "BeautifulMemory",
        "description": "My most precious memories",
        "externalId": null,
        "creationDate": "2017-10-13T13:32:34+00:00"
    }
}

Description

This method retrieves a specific memory associated to the owner of the MMT-ApiKey header used in the HTTP Request.
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}
If passed ID does not correspond to any Memory that the User is connected to, this API returns an HTTP ERROR 404:
{
    "error": {
        "message": "Requested resource not found",
        "type": "NotFoundException"
    },
    "status": 404
}

Resource URL

http://api.modernmt.eu/memories/:id

Request Fields

None. The memory identifier is specified directly in the URL. Note: the identifier can be:
  • the id of the MMT Memory that this ServiceApi Memory refers to (example: 5);
  • the ServiceApi Memory Key (example: mk_f4932hg205vh7h20h05g72);

Response Fields

id The ModernMT Memory id for this Memory.

Example: 5
key The ServiceApi Memory key for this Memory.

Example: mk_f4932hg205vh7h20h05g72
externalId Private parameter for internal use only
name The name with which this user was linked to the memory.

Example: BeautifulMemory
description The description with which this user was linked to the memory.

Example: My most precious memories
creationDate A timestamp marking the instant that the Memory was created. It refers to the Memory, and not to the link between User and Memory.

Example: 2017-10-13T13:32:34+00:00

API Create Memory

Quick Example


curl -X POST \
     -H "MMT-ApiKey:<your_api_key>" \
     -d "name=newMemory" \
     -d "description=newDescription" \
     http://api.modernmt.eu/memories \
     | python -mjson.tool

{
    "status": 200,
    "data": [
        {
            "id": 5,
            "key": "mk_4890fj840qjf4gggfga55",
            "name": "newMemory",
            "description": "newDescription",
            "externalId": null,
            "creationDate": "2017-10-13T13:32:34+00:00"
        }
    ]
}

Description

This method creates a new ModernMT Memory and links it to the current User.
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}

Resource URL

http://api.modernmt.eu/memories

Parameters

name The name with which the new Memory must be associated to the current User

Example: newMemory
description
optional
The description that the new Memory must use for the current User

Example: new description for the new memory
external_id
optional
The id of the TM stored in an external provider, and that should be imported in the new MMT Memory.
The external id must be in format x_providerTag-idString

Example: x_mm-fh548297h54f0281hf47

Response Fields

id The MMT Memory id for the newly created Memory.

Example: 5
key The MMT Memory key for the newly created Memory.

Example: mk_f4932hg205vh7h20h05g72
externalId This is a private parameter only for internal use
name The Memory name with which this User was linked to the newly created Memory.

Example: BeautifulMemory
description The Memory description with which this user was linked to the newly created memory.

Example: My most precious memories
creationDate A timestamp marking the instant that the Memory was created.
It refers to the creation of the actual Memory, and not to the moment when the User has connected to the Memory.

Example: 2017-10-13T13:32:34+00:00

API Delete Memory

Quick example


curl -X DELETE -H "MMT-ApiKey:<my_api_key>" http://api.modernmt.eu/memories/5 | python -mjson.tool

{
    "status": 200,
    "data": {
        "id": 5,
        "key": "mk_f4932hg205vh7h20h05g72",
        "name": "memoryName",
        "description": "memoryDescription",
        "externalId": null,
        "creationDate": "2017-10-13T13:32:34+00:00"
    }
}

Description

This method removes the connection between the current User and the specified Memory, and returns the Memory object. It does not remove the actual Memory from ModernMT. If the current User was not linked to the passsed Memory, this API returns an HTTP ERROR 404:
{
    "error": {
        "message": "Requested resource not found",
        "type": "NotFoundException"
    },
    "status": 404
}
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}

Resource URL

http://api.modernmt.eu/memories/:id

Request Fields

None. The memory identifier is specified directly in the URL. Note: the identifier can be:
  • the id of the MMT Memory that this ServiceApi Memory refers to (example: 5);
  • the MMT Memory Key (example: mk_f4932hg205vh7h20h05g72);

Response Fields

id The ModernMT Memory id for this Memory.

Example: 5
key The MMT Memory key for this Memory.

Example: mk_f4932hg205vh7h20h05g72
externalId Private parameter for internal use only
name The name with which the user is linked to the memory.

Example: BeautifulMemory
description The description with which the user is linked to the memory.

Example: My most precious memories
creationDate A timestamp marking the instant that the Memory was created. It refers to the creation of the Memory, and not to the moment when the User was linked to it.

Example: 2017-10-13T13:32:34+00:00

API Update Memory

Quick example


curl -X PUT -H "MMT-ApiKey:<my_api_key>" http://api.modernmt.eu/memories/5 \
   -d "name=newName" \
   -d "description=newDescription" \
   | python -mjson.tool

{
    "status": 200,
    "data": {
        "id": 5,
        "key": "mk_f4932hg205vh7h20h05g72",
        "name": "newName",
        "description": "newDescription",
        "externalId": null,
        "creationDate": "2017-10-13T13:32:34+00:00"
    }
}

Description

This method updates the name and description of a specific Memory that is already connected to the owner of the MMT-ApiKey header used in the HTTP Request.
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}
If the Memory was not already connected to the User, this API returns an HTTP ERROR 404:
{
    "error": {
        "message": "Requested resource not found",
        "type": "NotFoundException"
    },
    "status": 404
}

Resource URL

http://api.modernmt.eu/memories/:id

Request Fields

name The new name to use in the connection between this Memory and this User.

Example: newName
key The new description to use in the connection between this Memory and this User.

Example: newDescription
Note: The Memory identifier must be specified in the URL. It can be:
  • the id of the MMT Memory that this ServiceApi Memory refers to (example: 5);
  • the MMT Memory Key (example: mk_f4932hg205vh7h20h05g72);

Response Fields

id The MMT Memory id for the newly created Memory.

Example: 5
key The MMT Memory key for this Memory.

Example: mk_f4932hg205vh7h20h05g72
externalId Private parameter for internal use only
name The new name with which the User is linked to the Memory.

Example: BeautifulMemory
description The new description with which the User is linked to the Memory.

Example: My most precious memories
creationDate A timestamp marking the instant that the Memory was created. It refers to the creation of the actual Memory, and not to the moment when the User was connected to the Memory.

Example: 2017-10-13T13:32:34+00:00

API Delete Memory Content

Quick example


curl -X DELETE -H "MMT-ApiKey:<my_api_key>" http://api.modernmt.eu/memories/5/content | python -mjson.tool

{
    "status": 200,
    "data": {
        "id": 5,
        "key": "mk_f4932hg205vh7h20h05g72",
        "name": "memoryName",
        "description": "memoryDescription",
        "externalId": null,
        "creationDate": "2017-10-13T13:32:34+00:00"
    }
}

Description

This method removes from the models in the ModernMT server all the contents for the specified Memory. The specified Memory must be associated to the owner of the MMT-ApiKey header used in the HTTP Request.
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}
If the Memory is not connected to the current User, this API returns an HTTP ERROR 404:
{
    "error": {
        "message": "Requested resource not found",
        "type": "NotFoundException"
    },
    "status": 404
}

Resource URL

http://api.modernmt.eu/memories/:id/content

Request Fields

None. The memory identifier is specified directly in the URL. Note: the identifier can be:
  • the id of the MMT Memory that this ServiceApi Memory refers to (example: 5);
  • the ServiceApi Memory Key (example: mk_f4932hg205vh7h20h05g72);

Response Fields

id The MMT Memory id for the newly created Memory.

Example: 5
key The ServiceApi Memory key for this Memory.

Example: mk_f4932hg205vh7h20h05g72
externalId Internal parameter for private use only
name The name with which the user is linked to the memory.

Example: BeautifulMemory
description The description with which the user is linked to the memory.

Example: My most precious memories
creationDate A timestamp marking the instant that the Memory was created. It refers to the creation of the actual Memory, and not to the moment when it was connected to the current User.

Example: 2017-10-13T13:32:34+00:00

API Add Memory Content

Quick Example

Adding a TMX file to an already existing memory

curl -X POST \
     -H "Content-Type: multipart/form-data" \
     -H "MMT-ApiKey: <your_api_key>" \
     -F "tmx=@<absolute_path_to_your_tmx>" \
     http://api.modernmt.eu/memories/5/content \
     | python -mjson.tool

{
    "data": {
        "begin": 76692,
        "dataChannel": 0,
        "end": 76699,
        "id": "00000000-0000-0000-0000-000000000004",
        "memory": 5,
        "progress": 0,
        "size": 8
    },
    "status": 200
}

Adding a single contribution to an already existing memory


curl -X POST \
     -H "MMT-ApiKey: <your_api_key" \
     -d "source=en" \
     -d "target=it" \
     -d "sentence=Hello Mike!" \
     -d "translation=Ciao Mike!" \
     http://api.modernmt.eu/memories/5/content \
     | python -mjson.tool

{
    "data": {
        "begin": 16,
        "dataChannel": 1,
        "end": 16,
        "id": "80000001-0000-0000-0000-000000000010",
        "memory": 0,
        "progress": 0,
        "size": 1
    },
    "status": 200
}

Description

This method appends parallel text to the content of a Memory.
It is possible to append either a single translation unit (source/translation pair), or an entire TMX file.
Adding more data to a Memory can improve the quality of the translation of ModernMT; appending post-edited segments for example is the best way to let MMT learn from corrections made by professional translators and be also able to adapt translation output to the translator’s taste.
To add a TMX to a Memory, the user must be linked to that Memory. To add a single contribution to a Memory, the user can be either linked or not linked to it (it must have a valid MMT-apiKey anyway).

Resource URL

http://api.modernmt.eu/memories/:id/content

Parameters

</tr>
source
oprional
The source language of the content to add, in the form of a language tag. Mandatory if the content to add is a single contribution.

Example: en
target
optional
The target language of the content to add, in the form of a language tag. Mandatory if the content to add is a single contribution.

Example: it
sentence
optional
The source part of a translation unit. Mandatory if the content to add is a single contribution.

Example: Hello Mike!
translation
optional
The target part of a translation unit. Mandatory if the content to add is a single contribution.

Example: Ciao Mike!
tmx
optional
This parameter represents a TMX file to import into a memory. To import a tmx, the Content-Type: multipart/form-data` header must be specified.
compression
optional
If you are sending a compressed TMX file, you also need to specify the compression type.
NOTE: at the moment the only supported compression type is GZIP.

Example: gzip
Note: The Memory identifier must be specified in the URL. It can be:
  • the id of the MMT Memory that this ServiceApi Memory refers to (example: 5);
  • the MMT Memory Key (example: mk_f4932hg205vh7h20h05g72);

Response Fields

The response object is an ImportJob, for more details please have a look at the API Get Import Job documentation.

API Update Memory Content

Quick Example

curl -X PUT \
     -H "MMT-ApiKey: <your_api_key>" \
     -d "source=en" \
     -d "target=it" \
     -d "sentence=Hi Mike!" \
     -d "translation=Ciao Mike!" \
     -d "old_sentence=Hello Mike!" \
     -d "old_translation=Salve Michele!" \
     http://api.modernmt.eu/memories/5/content \
     | python -mjson.tool

{
    "data": {
        "begin": 16,
        "dataChannel": 1,
        "end": 16,
        "id": "80000001-0000-0000-0000-000000000010",
        "memory": 0,
        "progress": 0,
        "size": 1
    },
    "status": 200
}

Description

This method updates a past contribution in a Memory. The target Memory does not have to be linked to the current User.
If the same contribution was added multiple times, all of its instances in the Memory will be updated.

Resource URL

http://api.modernmt.eu/memories/:id/content

Parameters

</tr>
source The source language of the contribution to update, in the form of a language tag.

Example: en
target The target language of the contribution to update, in the form of a language tag.

Example: it
sentence The source part of the contribution to write over the old contribution.

Example: Hello Mike!
translation The target part of the contribution to write over the old contribution

Example: Ciao Mike!
old_sentence The source part of the old contribution to update.

Example: Hello Mike!
old_translation The target part of the old contribution to update.

Example: Salve Michele!

Response Fields

The response object is an ImportJob, for more details please have a look at the API Get Import Job documentation.

API Add Content To Multiple Memories

Quick Example


curl -X POST \
     -H "MMT-ApiKey: <your_api_key>" \
     -d "memories=1,4,5" \
     -d "source=en" \
     -d "target=it" \
     -d "sentence=Hello Mike!" \
     -d "translation=Ciao Mike!" \
     http://api.modernmt.eu/memories/content \
     | python -mjson.tool

{
    "data": [
        {
            "begin": 16,
            "dataChannel": 1,
            "end": 16,
            "id": "80000001-0000-0000-0000-000000000010",
            "memory": 0,
            "progress": 0,
            "size": 1
        },
        {
            "begin": 17,
            "dataChannel": 1,
            "end": 17,
            "id": "80000001-0000-0000-0000-000000000011",
            "memory": 0,
            "progress": 0,
            "size": 1
        },
        {
            "begin": 18,
            "dataChannel": 1,
            "end": 18,
            "id": "80000001-0000-0000-0000-000000000012",
            "memory": 0,
            "progress": 0,
            "size": 1
        }
    ],
    "status": 200
}

Description

This method adds a single contribution to multiple MMT Mmories.
Adding more data to a memory can improve the quality of the translation of MMT; appending post-edited segments for example is the best way to let MMT learn from corrections made by professional translators and be also able to adapt translation output to the translator’s taste.
The User can be either linked or not linked to the target memories (it must have a valid MMT-ApiKey anyway).
If no target memory is passed, this API will append the contribution to the User’s default memory.

Resource URL

http://api.modernmt.eu/memories/content

Parameters

memories A list containing the identifiers of the target memories in the format of a comma-separated string.
A Memory identifier can be either the MMT Memory ID, or the MMT Memory Key.
If no target memories are passed, the contribution will be added to the User's default Memory.

Example: 1,3,5
source The source language of the contribution to add, in the form of a language tag.

Example: en
target The target language of the contribution to add, in the form of a language tag.

Example: it
sentence The source content of the contribution to add.

Example: Hello Mike!
translation The target content of the contribution to add.

Example: Ciao Mike!

Response Fields

The response object is an array of ImportJobs, for more details please have a look at the API Get Import Job documentation.

API Update Content in Multiple Memories

Quick Example


curl -X POST \
     -H "MMT-ApiKey: <your_api_key>" \
     -d "memories=1,4,5" \
     -d "source=en" \
     -d "target=it" \
     -d "sentence=Hello Mike!" \
     -d "translation=Ciao Mike!" \
     -d "old_sentence=Hello Mike!" \
     -d "old_translation=Salve Michele!" \

     http://api.modernmt.eu/memories/content \

| python -mjson.tool

{
    "data": [
        {
            "begin": 16,
            "dataChannel": 1,
            "end": 16,
            "id": "80000001-0000-0000-0000-000000000010",
            "memory": 0,
            "progress": 0,
            "size": 1
        },
        {
            "begin": 17,
            "dataChannel": 1,
            "end": 17,
            "id": "80000001-0000-0000-0000-000000000011",
            "memory": 0,
            "progress": 0,
            "size": 1
        },
        {
            "begin": 18,
            "dataChannel": 1,
            "end": 18,
            "id": "80000001-0000-0000-0000-000000000012",
            "memory": 0,
            "progress": 0,
            "size": 1
        }
    ],
    "status": 200
}

Description

This method updates a past contribution in multiple MMT Memories.
The User can be either connected or not connected to the target memories to update; she must have a valid MMT-apiKey anyway.
If no target memory is passed, this API will update the contribution in the User’s default memory.
If the same contribution was added multiple times, all of its instances in the target Memories will be updated.

Resource URL

http://api.modernmt.eu/memories/content

Parameters

memories A list containing the identifiers of the target memories in the format of a comma-separated string.
A Memory identifier can be either the ModernMT Memory ID, or the ServiceApi Memory Key, or the corresponding External Id (if there is one).
If no target memories are passed, the contribution will be added to the User's default Memory.

Example: 1,3,5
source The source language of the contribution to update, in the form of a language tag.

Example: en
target The target language of the contribution to update, in the form of a language tag.

Example: it
sentence The source content of the contribution to write over the old contribution.

Example: Hello Mike!
translation The target content of the contribution to write over the old contribution

Example: Ciao Mike!
old_sentence The source content of the old contribution to update.

Example: Hello Mike!
old_translation The target content of the old contribution to update.

Example: Salve Michele!

Response Fields

The response object is an array of ImportJobs, for more details please have a look at the API Get Import Job documentation.

API Get Import Job

Quick example

curl -X GET -H "MMT-ApiKey:<my_api_key>" http://api.modernmt.eu/import-jobs/00000000-0000-0000-0000-000000000001 | python -mjson.tool

{
    "data": {
        "begin": 0,
        "dataChannel": 0,
        "end": 50487,
        "id": "00000000-0000-0000-0000-000000000001",
        "memory": 7,
        "progress": 0.43
        "size": 50488
    },
    "status": 200
}

Description

This method returns an Import Job status.

Resource URL

http://api.modernmt.eu/memories/import-jobs

Parameters

None. The id of the import job is specified directly in the URL.

Response Fields

id The id of the import job. The id is a UUID (128-bit number).
memory The id of the memory that is receiving the updates.
dataChannel The id of the data channel where this contribution was written by MMT
begin The start position of this contribution in the data channel.
end The end position of this contribution in the data channel.
size The number of translation units in this import job.
progress This value indicates the percentage of progress of the import job. A value of 1 (corresponding to 100%) indicates that the job is completed.


API Get User

Quick example


curl -H "MMT-ApiKey:<my_api_key>" "http://api.modernmt.eu/users/me" | python -mjson.tool

{
    "data": {
        "billingPeriod": {
            "amount": 0,
            "begin": "2017-10-01T00:00:00+00:00",
            "currency": "EUR",
            "currencySymbol": "\u20ac",
            "end": "2017-11-01T00:00:00+00:00",
            "words": 0
        },
        "email": "andrea@translated.net",
        "id": 1,
        "name": "Andrea Rossi"
    },
    "status": 200
}

Description

This method retrieves the user associated to the MMT-ApiKey header sent in the HTTP Request.
If the MMT-ApiKey header is missing or invalid, this API returns an HTTP ERROR 401:
{
    "status":401,
    "error": {
        "type":"AuthException",
        "message":"Missing or invalid authentication header"
    }
}

Resource URL

http://api.modernmt.eu/users/me

Request Fields

None.

Response Fields

name The user name.

Example: Andrea Rossi
id The user id.

Example: 1
email The user email. Two users can never share the same email address.

Example: andrea@ŧranslated.net
billingPeriod The user's current billing period for this month. If there is no billing period for this month, this field will return a new billing period for this month. </table </tr>
currency The currency used for this user, in ISO 4217 standard

Example: EUR
currencySymbol The currency symbol, as a Unicode character code

Example: \u20ac
begin A timestamp marking the beginning of this billing period. If always corresponds to the first day of a month.

Example: 2017-10-01T00:00:00+00:00
end A timestamp marking the end of this billing period. If always corresponds to the first day of a month.

Example: 2017-11-01T00:00:00+00:00
amount The amount of money billed in the billing period

Example: 254.5498
words The amount of billed words in the billing period

Example: 18967