Ready to get with GET? (continued)

Now you are a salted GET user, an experienced API sailor who has already checked Smartcat integration 101 and Ready to get with GET, haven't you?  So let's move on with learning how to apply GET requests to enhance your workflow. 

Get document information via API

To start with, receive document details with the GET document method using a document id. 

See our document example

Request URL: 
https://smartcat.ai/api/integration/v1/document?documentId=ac63c097c60c1d1bb54f1760_25

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
{
     "id": "ac63c097c60c1d1bb54f1760_25",
     "name": "test",
     "creationDate": "2018-12-17T23:32:04.508Z",
     "sourceLanguage": "en",
     "documentDisassemblingStatus": "success",
     "targetLanguage": "ru",
     "status": "inProgress",
     "wordsCount": 1,
     "statusModificationDate": "2018-12-17T23:32:47.528Z",
     "pretranslateCompleted": false,
     "workflowStages": [
        {
           "progress": 100,
           "wordsTranslated": 1,
           "unassignedWordsCount": 0,
           "status": "completed",
           "executives": [
           {
              "assignedWordsCount": 1,
              "progress": 100,
              "id": "92ebc7bb-9c8c-4516-b88e-ca4c753aca57"
           }
           ]
        }
     ],
     "externalId": "ac63c097c60c1d1bb54f1760",
     "placeholdersAreEnabled": true
}

Not enough details? Then you can go deeper and calculate the document statistics. Use GET document/statistics that first will respond with a "200 Build statistics in progress" message, and then in some time after you push the method again, the request will respond with the actual statistics.

See our document/statistics example

Request URL: 
https://smartcat.ai/api/integration/v1/document/statistics?documentId=e88fa692ba1c1d1bb54f07f8_25

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
  {
     "name": "test",
     "statistics": [
     {
        "name": "total",
        "words": 1,
        "percent": 100,
        "segments": 1,
        "pages": 0,
        "charsWithoutSpaces": 4,
        "charsWithSpaces": 4,
        "effectiveWordsForBilling": 0
     },
     {
        "name": "newWords",
        "words": 1,
        "percent": 100,
        "segments": 1,
        "pages": 0,
        "charsWithoutSpaces": 4,
        "charsWithSpaces": 4
     },
...
     {
        "name": "match_75_84",
        "words": 0,
        "percent": 0,
        "segments": 0,
        "pages": 0,
        "charsWithoutSpaces": 0,
        "charsWithSpaces": 0
     },
     {
        "name": "match_50_74",
        "words": 0,
        "percent": 0,
        "segments": 0,
        "pages": 0,
        "charsWithoutSpaces": 0,
        "charsWithSpaces": 0
     }
     ]
}


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
   }

Get placeholders via API

Focused on localization of games, applications, and websites? Then you definitely want to use placeholders in your projects. Get to know your placeholders with GET placeholders.

See our placeholders example

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

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Response:
[
   {
     "regex": "%[sdn]"
   },
   {
     "regex": "\\{+.+?\\}+"
   },
   {
     "regex": "\\[\\[.+?\\]\\]"
   },
   {
     "regex": "%\\d+\\$[sd]"
   },
   {
     "regex": "%@"
   }
]

Bear in mind that characters like \ will be escaped, e.g. the character \ is displayed as \\ in the example above.

You can also validate your placeholders with GET placeholders/validate, and if you get 204 in response, then everything is good.

See our placeholders/validate example

Request URL: 
https://smartcat.ai/api/integration/v1/placeholders/validate?format=/[a-z]+/g

Headers:
Authorization: Basic ZG0wMTpRd2VydHkxMjM=

Getting a team member’s profile via API

Each team member has an ID. When you add a new team member via API, you receive this ID in the response.

To get the information about the specific team member, use the GET account/myteam/{userid} method and send the Smartcat ID as a userId parameter value.

See our account/myteam/{userId} example

Request URL: 
https://smartcat.ai/api/integration/v1/account/myteam/6a097370-75a3-4bcc-b37b-2c3fd339b2dd

Headers:
Authorization: Basic dGVzdGFwaToxMjM0NTY=

To get the information about the specific team member using your own external ID, user the GET account/myteam method and use your own ID as an externalId parameter value.

See our account/myteam example

Request URL: 
https://smartcat.ai/api/integration/v1/account/myteam?externalId=1543703765

Headers:
Authorization: Basic dGVzdGFwaToxMjM0NTY=

 

Like it?

1

Similar articles:

    No related articles