GlobalLink Web API Supported Mime Types
The Content-Type header on the incoming request determines how to interpret the request body:
- Content-Type: url-form-encoded ==> name/valuepairs
- Content-Type: text/html ==> htmlpage/email/etc., must be 100% valid
- Content-Type: text/plain ==> text, charset=us-ascii
- Content-Type: application/json ==> any validJSON structure
- Content-Type: application/xml ==> an RSS feed orany valid XML structure
Only the first mime type (url-form-encoded) allows for parameters like tx_account, tx_content, and tx_service to be supplied in the request body. The other three use the request body as the actual content to be translated.
Type one url-form-encoded
The following header is needed:
Content-Type: application/x-www-form-urlencoded
The following headers are supported:
x_tx_account=...
x_tx_content=...
x_tx_service=...
The following query parameters are needed:
tx_mimetype= <content-type of content>
tx_token=API-demo <security token>. <----- optional variant ofX-TX_Token only for URL-FORM-ENCODED
tx_content= <content for translation>
The following query parameters are supported:
tx_account=...
tx_content=...
tx_service=...
Type two: text/HTML
The DEMO translation key may be used to test the/TX API: 97BB-3CE8-1CD2-FE93. You must ask your implementation manager if you would like to set up a real key.
Note: The text/HTML method is async and should not be used for instant translations.
Step 1 - Create a new session for your Project by specifying your ProjectKey
https://www.onelink-edge.com/xapis/TX/P<PKEY>?create_session=1
curl --request POST \ --url 'https://www.onelink-edge.com/xapis/TX/P6560-5B89-3A89-08DE?create_session=1' \ --header 'Content-Type: text/html'
https://www.onelink-edge.com/xapis/TX/P<PKEY>?create_session=1
The response contains the created session ID that you can use to POST HTML translation requests:
{ "message":"created.", "session_id": "session-XXXX-XXXX-XXXX-XXXX" }
Step 2 - POST HTML content to be translated for various Translation Keys
You can POST as much content as you want. The <filename> must be unique per Translation Key for each POST request.
https://www.onelink-edge.com/xapis/TX/<TKEY>/<filename>?session_id=<session_id>
curl --request POST \ --url 'https://www.onelink-edge.com/xapis/TX/97BB-3CE8-1CD2-FE93/zhcn_file?session_id=session-XXXX-XXXX-XXXX-XXXX' \ --header 'Content-Type: text/html' \ --header 'X-TX_Token: API-demo' \ --data 'Maitake <b>Cellular Support</b> - 120 Vegetarian Capsules'
Step 3 - Get the Translated HTML Results
https://www.onelink-edge.com/xapis/TX?session_id=<session_id>
The response if all the translations are not done yet, you will get a JSON status message:
{ "message": "completed 3 of 10" } curl --request GET \ --url 'https://www.onelink-edge.com/xapis/TX?session_id=session-5049-7D35-C719-9572'
You will get a zip file of the translated content if all the translations are completed. The session will then be marked as completed, and you will no longer be able to GET any more Translate requests to it.
session-XXXX-XXXX-XXXX-XXXX.zip
9588-88DF-0AC0-AF90/zhcn_file
A3C6-EEDD-EDA7-0FB2/nlnl_file
Type three: text/plain
curl --request POST \ --url https://www.onelink-edge.com/xapis/TX/97BB-3CE8-1CD2-FE93 \ --header 'Content-Type: text/plain' \ --header 'X-TX_Token: API-demo' \ --data 'Maitake Cellular Support- 120 Vegetarian Capsules'
Result:
Måïțåķëǿ C룣ȗŁåȑǿ Sȗƥƥǿȑțǿ- 120 Vëģëțåȑïåǹåŷ CåƥșȗŁëșǿ
Note: invalid HTML is not supported
Type four: application/JSON
curl --request POST \ --url https://www.onelink-edge.com/xapis/TX/97BB-3CE8-1CD2-FE93 \ --header 'Content-Type: application/json' \ --header 'X-TX_Token: API-demo' \ --data '{"product_desc":"Maitake Cellular Support - 120 Vegetarian Capsules","product_sku":"FJFOFOOSO1231213"}' PAYLOAD: { "product_desc": "Maitake Cellular Support - 120 Vegetarian Capsules", "product_sku": "FJFOFOOSO1231213" } NOTE: Config required to translate product_desc: "tx_api_rules": { "tx_token": "API-demo", "translate": [{"T":"product_desc"}] },
Result:
{ "product_desc": "Måïțåķëǿ C룣ȗŁåȑǿ Sȗƥƥǿȑțǿ - 120 Vëģëțåȑïåǹåŷ CåƥșȗŁëșǿ", "product_sku": "FJFOFOOSO1231213" }
Note:
- The client needs to provide a list of JSON keys that need translating
- The default behavior for JSON is do not translate
If OneLinkTx is anywhere in the key, the following will occur:
curl --request POST \ --url https://www.onelink-edge.com/xapis/TX/97BB-3CE8-1CD2-FE93 \ --header 'Content-Type: application/json' \ --header 'X-TX_Token: API-demo' \ --data '{"product_OneLinkTx":"Maitake Cellular Support - 120 Vegetarian Capsules","product_sku":"FJFOFOOSO1231213"}' PAYLOAD: { "product_OneLinkTx": "Maitake Cellular Support - 120 Vegetarian Capsules", "product_sku": "FJFOFOOSO1231213" }
Result:
{ "product_OneLinkTx":"Måïțåķëǿ C룣ȗŁåȑǿ Sȗƥƥǿȑțǿ - 120 Vëģëțåȑïåǹåŷ CåƥșȗŁëșǿ", "product_sku":"FJFOFOOSO1231213" }
This allows you to configure your own JSON for translation. The same is true of OneLinkNoTx. Use either OneLinkTx or OneLinkNoTx for customization of what gets translated.
Type five: application/XML
curl --request POST \ --url https://www.onelink-edge.com/xapis/TX/97BB-3CE8-1CD2-FE93 \ --header 'Content-Type: application/xml' \ --header 'X-TX_Token: API-demo' \ --data '<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0"><channel><title>W3Schools Home Page</title><link>https://www.w3schools.com</link><description>Free web building tutorials</description><item><title>RSS Tutorial</title><link>https://www.w3schools.com/xml/xml_rss.asp</link><description>New RSS tutorial on W3Schools</description></item></channel></rss>' PAYLOAD: <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <title>W3Schools Home Page</title> <link>https://www.w3schools.com</link> <description>Free web building tutorials</description> <item> <title>RSS Tutorial</title> <link>https://www.w3schools.com/xml/xml_rss.asp</link> <description>New RSS tutorial on W3Schools</description> </item> </channel> </rss>
Result:
<?xmlversion="1.0" encoding="UTF-8"?> <rssversion="2.0"> <channel> <title>W3Schools HǿmëǿPåģëǿ</title> <link>ħțțƥșǿ://ŵŵŵ.w3schools.çǿm</link> <description>Fȑëëǿ ŵëß ßȗïŁðïǹģǿțȗțǿȑïåŁșåŷ</description> <item> <title>RSSTȗțǿȑïåŁǿ</title> <link>ħțțƥșǿ://ŵŵŵ.w3schools.çǿm/xmŁ/xmŁ_ȑșș.åșƥ</link> <description>Nëŵ RSSțȗțǿȑïåŁǿ ǿǹ W3Schools</description> </item> </channel> </rss>
Note:
- The default behavior is to translate every tag