Translation Memory API v3

From Memsource
Jump to: navigation, search

Create New Translation Memory

action: api/v3/transMemory/create
    token                       string
    name                        string
    sourceLang                  locale
    targetLang                  list(locale)

response: JSON
    {
      "id": 1954              // id of the new translation memory
    }

Get Translation Memory

action: api/v3/transMemory/get
    token                       string
    transMemory                 domain(TransMemory)

response: JSON
    {
      "id":1,
      "targetLangs":[
        "de",
        "en"
      ],
      "sourceLang":"cs"
    }

Delete Translation Memory

action: api/v3/transMemory/delete
    token                       string
    transMemory                 domain(TransMemory)

response: empty

List Translation Memories

action: api/v3/transMemory/list
    token                       string

response: JSON
   [
     {
       "id":1,
       "targetLangs":[
         "de"
       ],
       "sourceLang":"en",
       "name":"transMem"
     }
   ]

Import Data

action: api/v3/transMemory/import
    token                       string
    transMemory                 domain(TransMemory)
    file                        file                             // TMX or MXLIFF file
    strictLangMatching          boolean               O(false)
    stripNativeCodes            boolean               O(true)

response: JSON
    {
      "acceptedSegmentsCount": "21809"
    }

Search

action: api/v3/transMemory/search
    token                       string
    transMemory                 domain(TransMemory)
    query                       string
    sourceLang                  locale

response: JSON
    // same as in Search By Task

Search Segment By Task

action: api/v3/transMemory/searchSegmentByTask
    token                       string
    task                        task
    segment                     string
    workflowLevel               integer                        O(0)
    scoreThreshold              double                         O(0.0) any value from interval [0.0;1.01]
    previousSegment             string                         O
    nextSegment                 string                         O
    maxSegments                 integer                        O(5)
    maxSubSegments              integer                        O(5)

response: JSON
    [
      {
        "grossScore":1,
        "score":1,
        "segmentId":"5023cd08e4b015e0656c4a8f",
        "source":{
          "id": "80ffcd08e4b015e0656c4a4c",
          "createdAt":1344523528505,
          "lang":"en",
          "modifiedAt":1344523528505,
          "nextSegment":"World",
          "previousSegment":null,
          "rtl":false,
          "text":"Hello"
        },
        "subSegment":false,
        "transMemory":{
          "id":"5023cb2ee4b015e0656c4a8e",
          "name":"test api"
        },
        "translations":[
          {
            "id": "7affcd08e4b015e0656c4aee"
            "client":null,
            "createdAt":1344523528505,
            "createdBy":{
              "firstName":"administrator",
              "id":30,
              "lastName":"admin",
              "userName":"admin"
            },
            "domain":null,
            "fileName":"small.properties",
            "lang":"de",
            "modifiedAt":1344600081648,
            "modifiedBy":{
              "firstName":"administrator",
              "id":30,
              "lastName":"admin",
              "userName":"admin"
            },
            "project":{
              "id":427,
              "name":"test tm api"
            },
            "rtl":false,
            "text":"HalloXX"
          }
        ]
      }
    ]

 error codes
      TransMemoryNotSelected                                   no translation memory is selected for the task

Search By Task

action: api/v3/transMemory/searchByTask
    token                       string
    task                        task
    query                       string
    workflowLevel               integer                        O(0)
    reverse                     boolean                        O(false)

response: JSON
    [
      {
        "grossScore":1,
        "score":1,
        "segmentId":"5023cd08e4b015e0656c4a8f",
        "source":{
          "id": "80ffcd08e4b015e0656c4a4c",
          "createdAt":1344523528505,
          "lang":"en",
          "modifiedAt":1344523528505,
          "nextSegment":"World",
          "previousSegment":null,
          "rtl":false,
          "text":"Hello"
        },
        "subSegment":false,
        "transMemory":{
          "id":"5023cb2ee4b015e0656c4a8e",
          "name":"test api"
        },
        "translations":[
          {
            "id": "7affcd08e4b015e0656c4aee"
            "client":null,
            "createdAt":1344523528505,
            "createdBy":{
              "firstName":"administrator",
              "id":30,
              "lastName":"admin",
              "userName":"admin"
            },
            "domain":null,
            "fileName":"small.properties",
            "lang":"de",
            "modifiedAt":1344600081648,
            "modifiedBy":{
              "firstName":"administrator",
              "id":30,
              "lastName":"admin",
              "userName":"admin"
            },
            "project":{
              "id":427,
              "name":"test tm api"
            },
            "rtl":false,
            "text":"HalloXX"
          }
        ]
      }
    ]

 error codes
      TransMemoryNotSelected                                   no translation memory is selected for the task

Update Source

action: api/v3/transMemory/updateSource
    token                       string
    transMemory                 domain(TransMemory)
    segmentId                   string
    text                        string

response: empty

Update Translation

action: api/v3/transMemory/updateTranslation
    token                       string
    transMemory                 domain(TransMemory)
    segmentId                   string
    lang                        locale
    text                        string

response: empty

Delete Source And Translation

action: api/v3/transMemory/deleteSourceAndTranslation
    token                       string
    transMemory                 domain(TransMemory)
    segmentId                   string

response: empty

Delete Translation

action: api/v3/transMemory/deleteTranslation
    token                       string
    transMemory                 domain(TransMemory)
    segmentId                   string
    lang                        locale

response: empty