Translation Memory API v4

From Memsource
Jump to: navigation, search

Create New Translation Memory

action: api/v4/transMemory/create
    token                       string
    name                        string
    sourceLang                  locale
    targetLang                  list(locale)
    client                      domain(Client)                 O
    businessUnit                domain(BusinessUnit)           O
    domain                      domain(Domain)                 O
    subDomain                   domain(SubDomain)              O
    note                        string                         O

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

Edit Translation Memory

action: api/v4/transMemory/edit
    token                       string
    transMemory                 domain(TransMemory)
    name                        string                         O
    targetLang                  list(locale)                   O
    client                      domain(Client)                 O N
    businessUnit                domain(BusinessUnit)           O N
    domain                      domain(Domain)                 O N
    subDomain                   domain(SubDomain)              O N
    note                        string                         O N

response: empty

Get Translation Memory

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

response: JSON
    {
      "id":1,
      "internalId":1,
      "name":"TM",
      "targetLangs":[
        "de",
        "en"
      ],
      "sourceLang":"cs"
      "dateCreated":"2016-01-12T13:41:23+0000",
      "createdBy": {
         "id": 501,
         "userName": "admin",
         "email": "support@memsource.com"
      }
      "client":null,
      "businessUnit": {
         "id":5,
         "name":"BU Name"
      }
      "domain":null,
      "subDomain":null,
      "note":null
    }

Delete Translation Memory

action: api/v4/transMemory/delete
    token                       string
    transMemory                 domain(TransMemory)
    purge                       boolean                 O(false)

response: empty

Clear Translation Memory

action: api/v4/transMemory/clear
    token                       string
    transMemory                 domain(TransMemory)

response: empty

This will delete all segments from the translation memory.

List Translation Memories

action: api/v4/transMemory/list
    token                       string
    page                        integer               O(0)
    name                        string                O
    sourceLang                  locale                O
    targetLang                  locale                O
    client                      domain(Client)        O
    domain                      domain(Domain)        O
    subDomain                   domain(SubDomain)     O
    

response: JSON
[   
   {
       "id": 19274,
       "internalId": 49,
       "name": "Sample TM",
       "sourceLang": "de",
       "targetLangs": [
           "en"
       ],
       "client": null,
       "businessUnit": null,
       "domain": null,
       "subDomain": null,
       "note": null,
       "dateCreated": "2013-09-13T10:26:43+0000",
       "createdBy": {
           "id": 5175,
           "firstName": "Memsource",
           "lastName": "Support",
           "userName": "Memsource Support",
           "email": "support@memsource.com",
           "role": "ADMIN",
           "timezone": "Europe/London",
           "active": true,
           "deleted": false,
           "terminologist": false,
           "dateCreated": "2013-02-04T09:06:30+0000"
       }
   }
]

List Translation Memories By Project

To be used to list TMs that can be assigned to a project.

action: api/v4/transMemory/listByProject
    token                       string
    project                     domain(Project)
    name                        string                O
    domain                      string                O
    subDomain                   string                O
    client                      string                O
    internalId                  integer               O
    targetLang                  list(locale)          O
   

response: JSON
   {
     "selected": list(TransMemory),
     "relevant": list(TransMemory) 
   }

Import Data

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

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

Export Data

action: api/v4/transMemory/export
    token                       string
    transMemory                 domain(TransMemory)
    format                      enum(TransMemory.Format)     O(TMX)
    targetLang                  list(locale)                 O

response: binary

response headers
    Content-Disposition         file name

Insert

action: api/v4/transMemory/insert
    token                       string
    transMemory                 domain(TransMemory)
    targetLang                  locale
    sourceSegment               string
    targetSegment               string
    previousSourceSegment       string                         O
    nextSourceSegment           string                         O
    sourceTagMetadata           jsonObjectList(TagMetadata)    O
    targetTagMetadata           jsonObjectList(TagMetadata)    O

response: empty

Search

action: api/v4/transMemory/search
    token                       string
    transMemory                 domain(TransMemory)
    query                       string
    sourceLang                  locale
    targetLang                  list(locale)                   O
    previousSegment             string                         O
    nextSegment                 string                         O
    tagMetadata                 jsonObjectList(TagMetadata)    O
    trimQuery                   boolean                        O(true)
    phraseQuery                 boolean                        O(true)

response: JSON
    // same as in Search By Task

Search Segment By Task

action: api/v4/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)
    tagMetadata                 jsonObjectList(TagMetadata)    O

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",
          "tagMetadata":[]
        },
        "subSegment":false,
        "transMemory":{
          "id":"5023cb2ee4b015e0656c4a8e",
          "name":"test api",
          "reverse":false
        },
        "translations":[
          {
            "id": "7affcd08e4b015e0656c4aee"
            "client":{
              "id":127,
              "name":"client1"
            },
            "createdAt":1344523528505,
            "createdBy":{
              "firstName":"administrator",
              "id":30,
              "lastName":"admin",
              "userName":"admin"
            },
            "domain":{
              "id":13,
              "name":"domain1"
            },
            "subDomain":{
              "id":14,
              "name":"subdomain1"
            },
            "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",
            "tagMetadata":[]
            "nextSegment":"Welt",
            "previousSegment":null,
          }
        ]
      }
    ]

 error codes
      TransMemoryNotSelected                                   no translation memory is selected for the task

Search By Task

action: api/v4/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",
          "tagMetadata":[]
        },
        "subSegment":false,
        "transMemory":{
          "id":"5023cb2ee4b015e0656c4a8e",
          "name":"test api",
          "reverse":false
        },
        "translations":[
          {
            "id": "7affcd08e4b015e0656c4aee"
            "client":{
              "id":125,
              "name":"client2"
            },
            "createdAt":1344523528505,
            "createdBy":{
              "firstName":"administrator",
              "id":30,
              "lastName":"admin",
              "userName":"admin"
            },
            "domain":{
              "id":13,
              "name":"domain1"
            },
            "subDomain":{
              "id":14,
              "name":"subdomain1"
            },
            "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",
            "tagMetadata":[]
            "nextSegment":"Welt",
            "previousSegment":null,
          }
        ]
      }
    ]

 error codes
      TransMemoryNotSelected                                   no translation memory is selected for the task

Update Source

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

response: empty

Update Translation

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

response: empty

Delete Source And Translation

action: api/v4/transMemory/deleteSourceAndTranslations
    token                       string
    transMemory                 domain(TransMemory)
    segmentId                   list(string)             // max 1000

response: empty

Delete Translation

action: api/v4/transMemory/deleteTranslation
    token                       string
    transMemory                 domain(TransMemory)
    segmentId                   list(string)            // max 1000
    lang                        locale

response: empty

Get Related Projects

action: api/v4/transMemory/getRelatedProjects
    token                       string
    transMemory                 domain(TransMemory)

response: JSON
   // list of related projects