Get resources (glossaries and translation memories) via API

Have a list of translation memories (TMs) and glossaries, but don't know what's in them? This article will reveal everything you can get off your resources. For starters, you can receive details of a TM using just its id with GET translationmemory/{tmId}.

See our translationmemory/{tmId} example

Request URL: 
https://smartcat.ai/api/integration/v1/translationmemory/5b70e882-6f8c-476b-9028-b80c6ad22bc9

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
{
   "id": "5b70e882-6f8c-476b-9028-b80c6ad22bc9",
   "accountId": "7bad195f-e984-48a0-ba3f-147a173472c0",
   "name": "test",
   "sourceLanguage": "ru",
   "targetLanguages": [
     "en"
   ],
   "createdDate": "2017-09-24T14:45:16.27Z",
   "isAutomaticallyCreated": true,
   "unitCountByLanguageId": {
   "en": 4
   }
}

If you want to get inside that TM, you can also export it with a GET translationmemory/{tmId}/file request.

See our translationmemory/{tmId}/file example

Request URL: 
https://smartcat.ai/api/integration/v1/translationmemory/5b70e882-6f8c-476b-9028-b80c6ad22bc9/file?exportMode=tmxDefault&withTags=true

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

You can control the export mode, e.g. choose "tmxDefault", "tmxWithTrados2009PlusCompatibility", "tmxWithTrados2007Compatibility", or "excel" and choose if you want to have tags in the export file by modifying "withTags" value into "true" or "false".

You most likely will need to update your TMs, and when you do, you can receive a collection of TM import tasks with GET translationmemory/task.

See our translationmemory/task example

Request URL: 
https://smartcat.ai/api/integration/v1/translationmemory/task

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
[
   {
       "accountId": "7bad195f-e984-48a0-ba3f-147a173472c0",
       "id": "bca3f23f-60a9-4cdf-9fac-452453056e45",
       "translationMemoryId": "6ab168e8-bace-436a-9400-54ae2cecfb00",
       "state": "Closed",
       "insertedUnitCount": 1
    }
]

In the end, let's go crazy and receive all TMs that exist in your account but limited by a batch size (100 max) with GET translation memory. Make sure you have prepared the id from the first method GET translationmemory/{tmId} and have in mind a TM batch size you want to receive in response. You can also add sourceLanguage, targetLanguage, clientId, and searchName parameters if you want to be more specific in your search.

See our translationmemory example

Request URL: 
https://smartcat.ai/api/integration/v1/translationmemory?lastProcessedId=5b70e882-6f8c-476b-9028-b80c6ad22bc9&batchSize=2

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
[
   {
       "id": "c9bc2283-48aa-d77b-0bbc-56899f51c30e",
       "accountId": "7bad195f-e984-48a0-ba3f-147a173472c0",
       "name": "sample1",
       "sourceLanguage": "en",
       "targetLanguages": [
          "zh-Hans"
       ],
       "createdDate": "2017-11-01T19:05:45.99Z",
       "isAutomaticallyCreated": false,
       "unitCountByLanguageId": {
          "zh-Hans": 71
       }
   },
   {
       "id": "74458983-6f5e-55ae-4970-9062f7823348",
       "accountId": "7bad195f-e984-48a0-ba3f-147a173472c0",
       "name": "sample3",
       "sourceLanguage": "tr",
       "targetLanguages": [
          "en-GB"
       ],
       "createdDate": "2017-06-04T15:53:28.123Z",
       "isAutomaticallyCreated": false,
       "unitCountByLanguageId": {
          "en-GB": 133
       }
   }
]

Glossaries, on the other hand, are not so lucky, as there is only one method you can use. GET glossaries will let you, well, just get all glossaries in your account.

See our glossaries example

Request URL: 
https://smartcat.ai/api/integration/v1/glossaries

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
[
   {
      "id": "e20a597a-ea55-443b-be36-97c67add06dd",
      "name": "English - Swedish",
      "description": "",
      "languages": [
         "en",
         "sv"
      ],
      "units": 27573,
      "unitsPending": 0
   }