Connect

From Wordfast Wiki
Revision as of 13:03, 17 March 2015 by Remiandre (talk | contribs) (text)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Return to command list

connect

connect (string key, int cmd)
Connect to the TMs and glossaries.

Parameters

key string a valid API Key, generated by making a share at www.freetm.com
cmd int command number is 22
joinTmGloInOneConnection boolean optional - Will create one connection for a standard Wordfast Anywhere TM and glossary having the same languages and variants - This allow to use only one command, searchSegment, to make the searches in the TM and in the glossary - Default value is false

Returned value

connections array connection details
id int connection ID
type string connection type
wkgid string workgroup ID
userId string user ID
tms array TM detail
tmid int TM ID
srcLang string source language
trgLang string target language
name string assigned or symbolic name
readonly boolean read/write status
glos array glossary detail
gloid int glossary ID
srcLang string source language
trgLang string target language
name string assigned or symbolic name
readonly boolean read/write status
error string error during connection

Request example

json post with javascript

var data = {};
data["key"] = "example@key";
data["cmd"] = 22;
data["joinTmGloInOneConnection"] = false; //optional
ar xhr = new XMLHttpRequest();
xhr.open("POST", "www.freetm.com/wfa/api", true);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send(JSON.stringify(data));

post

<form action="www.freetm/wfa/api" method="post">
   Key:<input type="text" id="key" name="key" value="example@key"/>
   Cmd:<input type="text" id="cmd" name="cmd" value="22"/>	
   Join TmGlo Connections (optional)<input type="checkbox" id="joinTmGloInOneConnection"  name="joinTmGloInOneConnection"/>
   <input type="submit" value="Submit">				
</form>

get

www.freetm.com/wfa/api?key=example@key&cmd=22

Response example

json

{

    "connections": [{
                 "id":      1
                 ,"type":   "WFA"
                 ,"wkgid":  "#TC4=XNTd6" 
                 ,"userId": "g7PWd4"
                 ,"tms": [{
                            "tmid":1, "srcLang":"DE-DE", "trglang":"EN-US", "name":"cat", "readonly":"false"
                      }
                      ,{...}
                  ]
                  ,"glos": [{
                            "gloid":1, "srcLang":"DE-DE", "trglang":"EN-US", "name":"cat", "readonly":"false"
                      }
                      ,{...}
                  ]
                 ,"error":  ""
            }
            ,{...}
    ]      
}

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

text

id:1 LF
type:WFA LF
wkgid:#TC4=XNTd6 LF
userId: g7PWd4 LF
tmid:1 tab srcLang:DE-DE tab trglang:EN-US tab name:cat tab readonly:false LF
gloid:2 tab srcLang:DE-DE tab trglang:EN-US tab name:cat tab readonly:false LF
error: LF

LF is a Line feed (new line \u000A) tab is a tabulation (\u0009)

Remarks

Timeout is 30 seconds
TM types are WFA (hosted by Wordfast TM server having only private TUs), SPE (A specific TM hosted by someone else and may contain public and private TUs), VLTM (Very Large TM Server hosted by Wordfast having a limited number of TMs containing only public TUs)
Glossary types are WFA, SPE and TMGR (A specific type imported as a read-only WFA type)