Python Examples
Translate Function
This Python snippet can be used to translate a texts array texts from src language code to tgt language code using the engine with id engine and using an apiKey
def relay(texts, src, tgt, engine, apiKey): url = 'https://prod.pangeamt.com:8443/NexRelay/v1/translate' data = { "src":src, "tgt":tgt, "apikey":apiKey, "engine": engine, "text": texts } headers = {'Content-type': 'application/json'} print(data) r = requests.post(url, data=json.dumps(data), headers=headers) ans=r.text try: translationresponse = json.loads(ans, strict=False) except: print(translationresponse) return translationresponse