Difference between revisions of "SearchTu"

From Wordfast Wiki
Jump to: navigation, search
(No difference)

Latest revision as of 15:56, 20 March 2015

Return to command list


searchTu (string key, int cmd, string query)

Search a word or phrase in the Translation Memory and return a list of Translation Units containing this word or phrase. It is a concordance search and the command duration is more long than the searchSegment command and may return lots of matches. The matches are not scored.


key string a valid API Key, generated by making a share at www.freetm.com
cmd int command number is 15
query string word or phrase

Returned value

tus array TU details
tmId int Translation Memory ID
tuId string Translation Unit ID
date string
userId string user ID
srcLang string source language
source string source segment
trgLang string target language
target string target segment
attribute1 string first attribute
attribute2 string second attribute
attribute3 string third attribute
attribute4 string fourth attribute

Request example

json post with javascript

var data = {};
data["key"] = "example@key";
data["cmd"] = 15;
data["query"] = "brown fox";
var xhr = new XMLHttpRequest();
xhr.open("POST", "www.freetm.com/wfa/api", true);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");


<form action="www.freetm./wfa/api" method="post">
   Key: <input type="text" id="key" name="key" value="example@key"/>
   Command: <input type="text" id="cmd" name="cmd" value="15"/>
   query: <textarea id="segment" name="query" style="width: 500px; height: 60px;">brown fox</textarea>
   <input type="submit" value="Submit">



Response example


{ "tus": [    {
               "tmId": 1
               ,"tuId": "81444b70-5f70-11e4-aad0-5c514f6f39a2" 
		,"date": "0140725~174345"
		,"userId": "DGfMDw"
               ,"usageCount": 0
		,"srcLang": "EN"
		,"source": "The brown fox is jumping over the lazy dog"
		,"trgLang": "FR"
		,"target": "Le renard brun saute par dessus le chien paresseux"
		,"attribute1": ""
		,"attribute2": ""
		,"attribute3": ""
		,"attribute4": ""

without white space (new line, carriage return or tabulation).


1 tab 81444b70-5f70-11e4-aad0-5c514f6f39a2 tab 0140725~174345 tab DGfMDw tab 0 tab EN tab The brown fox is jumping over the lazy dog. tab FR tab Le renard brun saute par dessus le chien paresseux. tab tab tab LF

LF is Line Feed (\u000A)
tab is a tabulation (\u0009)

return 000 is nothing is found