Difference between revisions of "SearchTu"
(→text) |
(→searchTu) |
||
Line 84: | Line 84: | ||
data["query"] = "brown fox"; | data["query"] = "brown fox"; | ||
var xhr = new XMLHttpRequest(); | var xhr = new XMLHttpRequest(); | ||
− | xhr.open("POST", " | + | xhr.open("POST", "anywhere.wordfast.com/wfa/api", true); |
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); | xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); | ||
xhr.send(JSON.stringify(data)); | xhr.send(JSON.stringify(data)); | ||
==== post ==== | ==== post ==== | ||
− | <form action=" | + | <form action="anywhere.wordfast.com/wfa/api" method="post"> |
Key: <input type="text" id="key" name="key" value="example@key"/> | Key: <input type="text" id="key" name="key" value="example@key"/> | ||
Command: <input type="text" id="cmd" name="cmd" value="15"/> | Command: <input type="text" id="cmd" name="cmd" value="15"/> | ||
Line 97: | Line 97: | ||
==== get ==== | ==== get ==== | ||
− | + | anywhere.wordfast.com/wfa/api?key=example@key&cmd=15&segment=brown%20fox | |
=== Response example === | === Response example === |
Latest revision as of 09:56, 17 January 2024
Contents
searchTu
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.
Parameters
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
|
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", "anywhere.wordfast.com/wfa/api", true); xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xhr.send(JSON.stringify(data));
post
<form action="anywhere.wordfast.com/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"> </form>
get
anywhere.wordfast.com/wfa/api?key=example@key&cmd=15&segment=brown%20fox
Response example
json
{ "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).
text
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