smartcat / smartcat-api
PHP client for SmartCAT API https://smartcat.ai/api/methods/
Installs: 50 847
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 10
Open Issues: 13
Requires
- php: ^7.4 | ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- guzzlehttp/psr7: ^2.0
- nesbot/carbon: ^2.42
- symfony/options-resolver: ^5.4
- symfony/serializer: ^2.0 || ^3.0 || ^4.0 || ^5.0
- dev-master
- 3.0.0
- 2.2.2
- 2.2.1
- 2.2.0
- v2.1.x-dev
- 2.1.9
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- v2.0.x-dev
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- v1.x-dev
- 1.7.3
- 1.7.2
- 1.7.0
- 1.6.0
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- 1.0.0
- dev-SUPPORT-5497
- dev-CSMS-1032-v2
This package is auto-updated.
Last update: 2025-03-25 13:36:51 UTC
README
How to use:
- Install composer
- composer require smartcat/smartcat-api
- composer install
use SmartCat\Client\SmartCat; $sc=new SmartCat($login, $password);
Account
Gets the account details
GET /api/integration/v1/account
$sc->getAccountManager()->accountGetAccountInfo();
Gets MT engines available for the account
GET /api/integration/v1/account/mtengines
$sc->getAccountManager()->accountGetMTEnginesForAccount();
Gets LSP's services available for the account](https://smartcat.com/api/methods/#!/Account/Account_GetLSPServicesForAccount)
GET /api/integration/v1/account/lsp/services
$sc->getAccountManager()->accountGetLSPServicesForAccount();
Gets available assignees (MyTeam freelancers or internal account users)
GET /api/integration/v1/account/assignableExecutives
$sc->getAccountManager()->accountGetAssignableExecutives();
Callback
Reset configurations of notifications reception DELETE /api/integration/v1/callback
$sc->getCallbackManager()->callbackDelete()
Reading configurations of notifications reception of the account GET /api/integration/v1/callback
$sc->getCallbackManager()->callbackGet()
Creating and updating configurations of notifications reception POST /api/integration/v1/callback
$callback=new CallbackPropertyModel(); $callback->setUrl('https://smartcat.ai'); $res=$sc->getCallbackManager()->callbackUpdate($callback);
Reading the last sending errors (no more than 100) GET /api/integration/v1/callback/lastErrors
$sc->getCallbackManager()->callbackGetLastErrors(['limit'=>$limit])
Client
Creates a client with the specified name and returns the Id
If the client already exists, just returns the Id.
POST /api/integration/v1/client/create
$clientId = $sc->getClientManager()->clientCreateClient('Test client');
Get details on a client specified within an account
GET /api/integration/v1/client/{clientId}
$client = $sc->getClientManager()->clientGetClient($clientId);
Sets the specified net rate model for the specified customer
PUT /api/integration/v1/client/{clientId}/set
$client = $sc->getClientManager()->clientSetClientNetRate($clientId, ['netRateId' => $netRateId]);
Directories
Receive the specified directory GET /api/integration/v1/directory
$sc->getDirectoriesManager()->directoriesGet(['type'=>'projectStatus'])
Gets parsing formats supported by the account
GET /api/integration/v1/directory/formats
$sc->getDirectoriesManager()->directoriesGetSupportedFormatsForAccount();
Document
Delete one or several documents DELETE /api/integration/v1/document
$sc->getDocumentManager()->documentDelete(['documentIds'=>['id1','id2']])
Receive document model GET /api/integration/v1/document
$sc->getDocumentManager()->documentGet(['documentId'=>$docId])
Update assigned document PUT /api/integration/v1/document/update
$bilingualFileImportSettings = new BilingualFileImportSettingsModel(); $bilingualFileImportSettings ->setConfirmMode('none') ->setLockMode('none') ->setTargetSubstitutionMode('all'); $updateDocumentModel = new UploadDocumentPropertiesModel(); $updateDocumentModel->setBilingualFileImportSettings($bilingualFileImportSettings); $res = $sc->getDocumentManager()->documentUpdate([ 'documentId' => $docId, 'updateDocumentModel' => $updateDocumentModel, 'uploadedFile' => [ 'fileContent' => fopen(__DIR__ . '\Resources\File2_EN.docx', 'r'), 'fileName' => 'File2_EN.docx' ] ]);
Rename assigned document PUT /api/integration/v1/document/rename
$sc->getDocumentManager()->documentRename(['documentId'=>$docId,'name'=>'New file name'])
Translate indicated document using the transferred file with translations PUT /api/integration/v1/document/translate
$sc->getDocumentManager()->documentTranslate([ 'documentId'=>$docId, 'translationFile'=>[ 'filePath'=>'file path', 'fileName'=>'file name' ] ])
Импортировать xliff-файл с переводами документа
PUT /api/integration/v1/document/translateWithXliff
$sc->getDocumentManager()->documentTranslateWithXliff([ 'documentId' => $docId, 'confirmTranslation' => true, 'overwriteUpdatedSegments' => true, 'translationFile' => [ 'filePath' => 'file path', 'fileName' => 'file.xliff' ] ]);
Receive the status of adding document translation GET /api/integration/v1/document/translate/status
$sc->getDocumentManager()->documentGetTranslationStatus(['documentId'=>$docId])
Gets a detailed report about translation importing results
GET /api/integration/v1/document/translate/result
$sc->getDocumentManager()->documentGetTranslationsImportResult(['documentId' => $docsId]);
Gets statistics
GET /api/integration/v1/document/statistics
$sc->getDocumentManager()->documentGetStatistics(['documentId' => $docsId]);
Split document into equal segments according to the number of words and assign each freelancer to one segment POST /api/integration/v1/document/assignFreelancers
$sc->getDocumentManager()->documentAssignFreelancersToDocument( ['Abbyyaolid1','Abbyyaolid2'], [ 'documentId' => $documentId, 'stageNumber' => $stageNumber ] )
DocumentExport
Request document (-s) export POST /api/integration/v1/document/export
$sc->getDocumentExportManager()->documentExportRequestExport(['documentIds'=>['documenId1','documentId2'])
Download the results of export GET /api/integration/v1/document/export/{taskId}
$sc->getDocumentExportManager()->documentExportDownloadExportResult($taskId);
Glossary
Получить набор глоссариев
GET /api/integration/v1/glossaries
$res = $sc->getGlossaryManager()->glossaryGetGlossaries();
Invoice
Creates a payable for a freelancer
POST /api/integration/v1/invoice/job
$importJobModel = new ImportJobModel(); $importJobModel->setFreelancerId($freelanceId) ->setServiceType('translation') ->setJobDescription('Test invoice') ->setUnitsType('Any text') ->setUnitsAmount(10) ->setPricePerUnit(1) ->setCurrency('usd'); $res=$sc->getInvoiceManager()->invoiceImportJob($importJobModel);
PlaceholderFormatApi
Gets all placeholder formats available in the current account
GET /api/integration/v1/placeholders
$res = $sc->getPlaceholderFormatApiManager()->placeholderFormatApiGetPlaceholderFormats();
Saves a set of placeholder formats for the current account
PUT /api/integration/v1/placeholders
$placeHolder1 = new PlaceholderFormatModel(); $placeHolder1->setRegex($regEx1); $placeHolder2 = new PlaceholderFormatModel(); $placeHolder2->setRegex($regEx2); $res = $sc->getPlaceholderFormatApiManager()->placeholderFormatApiUpdatePlaceholderFormats([$placeHolder1, $placeHolder2]);
Validates the specified placeholder format
GET /api/integration/v1/placeholders/validate
$res = $this->sc->getPlaceholderFormatApiManager()->placeholderFormatApiValidatePlaceholderFormat(['format' => 'Stable\:(\s+)(.+)[\r|]\n']);
Project
Delete project DELETE /api/integration/v1/project/{projectId}
$sc->getProjectManager()->projectDelete($projectId)
Receive project model GET /api/integration/v1/project/{projectId}
sc->getProjectManager()->projectGet($projectId)
Update project using ID
PUT /api/integration/v1/project/{projectId}
Receive the list of all projects in account GET /api/integration/v1/project/list
$sc->getProjectManager()->projectGetAll()
Receive the list of all projects in account with offset (v2)
GET /api/integration/v2/project/list
$sc->getProjectManager()->projectsGetWithOffset($offset = 0, $limit = 100)
Receive statistics and project value
GET /api/integration/v2/project/{projectId}/statistics
$sc->getProjectManager()->projectGetProjectStatistics($projectId); do { sleep(5); $res = $sc->getProjectManager()->projectGetProjectStatistics($projectId); } while(!is_array($res));
Receiving statistics for the completed parts of the project
GET /api/integration/v1/project/{projectId}/completedWorkStatistics
$res = $sc->getProjectManager()->projectGetCompletedWorkStatistics($projectId);
Receiving a list of the TMs plugged into the project
GET /api/integration/v1/project/{projectId}/translationmemories
$res = $sc->getProjectManager()->projectGetProjectTranslationMemories($projectId);
Rewrite connected TMs — same set of TMs for all target languages
POST /api/integration/v1/project/{projectId}/translationmemories
$translationMemoryForProjectModel = new TranslationMemoryForProjectModel(); $translationMemoryForProjectModel->setId($tmId); $translationMemoryForProjectModel->setIsWritable(true); $translationMemoryForProjectModel->setMatchThreshold(100); $res = $sc->getProjectManager()->projectSetTranslationMemoriesForWholeProject($projectId, [$translationMemoryForProjectModel]);
Gets a set of glossaries enabled for a project
GET /api/integration/v1/project/{projectId}/glossaries
$res = $sc->getProjectManager()->projectGetGlossaries($projectId);
Enables a set of glossaries for a project
PUT /api/integration/v1/project/{projectId}/glossaries
$res = $this->sc->getProjectManager()->projectSetGlossaries($projectId, [$glossaryId1, $glossaryId2]);
Starts generating statistics for the project
POST /api/integration/v1/project/{projectId}/statistics/build
$sc->getProjectManager()->projectBuildStatistics($this->prj->getId());
Rewrite connected TMs — each target language with its own set of TMs
POST /api/integration/v1/project/{projectId}/translationmemories/bylanguages
$translationMemoryForProjectModel = new TranslationMemoryForProjectModel(); $translationMemoryForProjectModel->setId($tmId); $translationMemoryForProjectModel->setIsWritable(true); $translationMemoryForProjectModel->setMatchThreshold(100); $tm = new TranslationMemoriesForLanguageModel(); $tm->setLanguage('en'); $tm->setTranslationMemories([$translationMemoryForProjectModel]); $res = $sc->getProjectManager()->projectSetProjectTranslationMemoriesByLanguages($projectId, [$tm]);
Create a project POST /api/integration/v1/project/create
$prjCreate = new CreateProjectWithFilesModel(); $prjCreate->setName('Test project'); $prjCreate->setDescription('Test project'); $prjCreate->setSourceLanguage('ru'); $prjCreate->setTargetLanguages(['en']); $prjCreate->setAssignToVendor(false); $prjCreate->setUseMT(false); $prjCreate->setPretranslate(false); $prjCreate->setAutoPropagateRepetitions(false); $prjCreate->setIsForTesting(true); $prjCreate->setWorkflowStages(['translation']); $prjCreate->attacheFile(fopen(__DIR__.'\Resources\File1_EN.docx'),'File1_EN.docx'); $sc->getProjectManager()->projectCreateProjectWithFiles($prjCreate);
Add new document to project POST /api/integration/v1/project/document
$bilingualFileImportSettings = new BilingualFileImportSettingsModel(); $bilingualFileImportSettings ->setConfirmMode('none') ->setLockMode('none') ->setTargetSubstitutionMode('all'); $documentModel = new CreateDocumentPropertyWithFilesModel(); $documentModel->setBilingualFileImportSettings($bilingualFileImportSettings); $documentModel->attachFile(fopen(__DIR__ . '\Resources\File2_EN.docx'), 'File2_EN.docx'); $res = $sc->getProjectManager()->projectAddDocument([ 'documentModel' => [$documentModel], 'projectId' => $projectId ]);
If you want to set Disassemble Settings, you should set Disassemble Algorithm. For example:
$bilingualFileImportSettings = new BilingualFileImportSettingsModel(); $bilingualFileImportSettings ->setConfirmMode('none') ->setLockMode('none') ->setTargetSubstitutionMode('all'); $disassembleSettings = (new DisassembleSettingsModel()) ->setTranslatableAttributes(['img'=>['data-caption']]); $documentModel = new CreateDocumentPropertyWithFilesModel(); $documentModel->setDisassembleAlgorithmName('html'); $documentModel->setDisassembleSettings($disassembleSettings); $documentModel->setBilingualFileImportSettings($bilingualFileImportSettings); $documentModel->attachFile(fopen(__DIR__ . '\Resources\File2_EN.docx'), 'File2_EN.docx'); $res = $sc->getProjectManager()->projectAddDocument([ 'documentModel' => [$documentModel], 'projectId' => $projectId ]);
Deprecated:
$sc->getProjectManager()->projectAddDocument([ 'projectId'=>$projectId, 'file' => [ 'filePath'=>'path to file', 'fileName'=>'File name' ] ]);
Add new target language to project POST /api/integration/v1/project/language
$sc->getProjectManager()->projectAddLanguage(['projectId'=>$projectId,'targetLanguage'=>'ja']);
Assign the group of translators for the specific stage of documents in project PUT /api/integration/v1/project/{projectId}/assignGroupToWorkflowStage
$sc->getProjectManager()->projectAssignGroupToWorkflowStage($projectId,['groupName'=>'Administrators','workflowStage'=>'translation'])
Cancel project POST /api/integration/v1/project/cancel
$sc->getProjectManager()->projectCancelProject(['projectId'=>$projectId])
Restore project POST /api/integration/v1/project/restore
$sc->getProjectManager()->projectRestoreProject(['projectId'=>$projectId])
Completes the workflow for all project documents. The project status will change to Completed.
POST /api/integration/v1/project/restore
$sc->getProjectManager()->projectCompleteProject(['projectId' => $this->prj->getId()]);
TranslationMemories
Deletes the TM
DELETE /api/integration/v1/translationmemory/{tmId}
$sc->getTranslationMemoriesManager()->translationMemoriesRemoveTranslationMemory($tmId)
Gets TM details
GET /api/integration/v1/translationmemory/{tmId}
$sc->getTranslationMemoriesManager()->translationMemoriesGetMetaInfo($tmId);
Imports TMX files into the TM
POST /api/integration/v1/translationmemory/{tmId}
$sc->getTranslationMemoriesManager()->translationMemoriesImport( $tmId, [ 'replaceAllContent' => 'true', 'tmxFile' => [ 'filePath' => __DIR__ . '\Resources\Space.tmx' ] ] );
Gets a collection of TMs available for the account
GET /api/integration/v1/translationmemory
$thirstRes = $sc->getTranslationMemoriesManager()->translationMemoriesGetTranslationMemoriesBatch([ 'lastProcessedId' => '', 'batchSize' => 10 ]); $last = array_pop($thirstRes); $secondRes = $sc->getTranslationMemoriesManager()->translationMemoriesGetTranslationMemoriesBatch([ 'lastProcessedId' => $last->getId(), 'batchSize' => $count ]);
Creates an empty TM
POST /api/integration/v1/translationmemory
$tm = new CreateTranslationMemoryModel(); $name = 'PHP Unit ' . date('U'); $tm->setName($name); $tm->setSourceLanguage('ru'); $tm->setTargetLanguages(['en']); $tm->setDescription("Description: $name"); $tmId = $sc->getTranslationMemoriesManager()->translationMemoriesCreateEmptyTM($tm);
Gets a collection of tasks for TMX import
GET /api/integration/v1/translationmemory/task
$sc->getTranslationMemoriesManager()->translationMemoriesGetPendingTasks();
Sets an array of target languages required by the TM
PUT /api/integration/v1/translationmemory/{tmId}/target
$sc->getTranslationMemoriesManager()->translationMemoriesSetTMTargetLanguages($tmId, ["en", "es"]);
Exports TMX files from the TM
GET /api/integration/v1/translationmemory/{tmId}/file
$sc->getTranslationMemoriesManager()->translationMemoriesExportFile($tmId, ['withTags' => true])
Gets matches from a given TM
POST /api/integration/v1/translationmemory/matches
$tmMatch = new TmMatchesRequest(); $tmMatch->setSourceLanguage('en'); $tmMatch->setTargetLanguage('ru'); $segmentModel = new SegmentModel(); $segmentModel->setText('Test text message'); $segmentModel->setPrevContext(''); $segmentModel->setNextContext(''); $segmentModel->setTags([]); $tmMatch->setSegmentModel($segmentModel); $sc->getTranslationMemoriesManager()->translationMemoriesGetTMTranslations($tmMatch, ['tmId' => $tmId]);
Removes a given import task
DELETE /api/integration/v1/translationmemory/task/{taskId}
$sc->getTranslationMemoriesManager()->translationMemoriesRemoveSpecificImportTask($last->getId())
User
Creates a new user with the specified parameters
POST /api/integration/v1/user
$user = new CreateUserRequest(); $user->setEmail('test@test.com') ->setFirstName('FirstName') ->setLastName('LastName') ->setExternalId('my-external-id') ->setRightsGroup('executive'); $res = $sc->getUserManager()->userCreate($user);
Deletes a user
DELETE /api/integration/v1/user/{accountUserId}
$sc->getUserManager()->userDelete($smartcatAccountUserId);
Gets a user model
GET /api/integration/v1/user/{accountUserId}
$res = $sc->getUserManager()->userGet($smartcatAccountUserId);
Updates user data
PUT /api/integration/v1/user/{accountUserId}
$updateModel = new UpdateUserRequest(); $updateModel->setFirstName($newName); $sc->getUserManager()->userUpdate($smartcatAccountUserId, $updateModel);
Gets a user by its external ID
GET /api/integration/v1/user/external
$res = $sc->getUserManager()->userGetExternal(['id' => $externalId]);