...
All below listed curl examples are generated via Google Chromes DevTools.
Authentication
...
In order to use the API an authentication is needed. Since Translate5 6.0.0 API usage is only possible with API auth tokens.
See the API token documentation how to generate such API tokens. The so generated token must be used in each request - replace below YOUR_APP_TOKEN with the generated token in that example request:
Code Block |
---|
curl --location --request GET 'https://demo.translate5.net/editor/index/applicationstate' \
--header 'Translate5AuthToken: YOUR_APP_TOKEN' |
Authentication the old way - POST example
Before the API tokens were introduced, the API user had to authenticate against the session endpoint, retrieving then a session ID and a session token.
Both can still be used to authenticate a user for the UI, see therefore the session APIFirst of all we have to authenticate us at the translate5 installation.The authentication is session based.
To authenticate we POST the data parameter containing the JSON data to the /editor/session URL.More information about the session API.
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/session' -X POST -H 'Accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ --data-urlencode 'data={"login":"manager","passwd":"asdfasdf"}' |
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/task?start=0&limit=20' -X GET -H 'Accept: application/json' -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' |
On success this results in a JSON containing the first (start=0) 20 (limit=20) tasks in translate5.
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/task/TASKID' -X GET -H 'Accept: application/json' -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' |
On success this results in a JSON containing the requested task.
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/task/TASKID' -X PUT -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json' \ --data-urlencode 'data={"taskName":"New Task Name","entityVersion":123}' |
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/task' -X POST \ -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' \ -F "format=jsontext" \ -F "taskName=This is a import test" \ -F "sourceLang=de" \ -F "targetLang=it" \ -F "edit100PercentMatch=1" \ -F "lockLocked=1" \ -F "importUpload=@/PATH/TO/YOUR/FILE.xlf" |
On success this results in a JSON containing the importing task.
Since a import is running in the background, the so created task will be returned with a state = import. For checking if the import is done, a callback should be configured: task import push callback
Associate users to a task
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/taskuserassoc/' \ -X POST -H 'Accept: application/json' \ -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' \ --data-urlencode 'data={"taskGuid":"TASKGUID","userGuid":"USERGUID","role":"translator","state":"open", "entityVersion":TASKVERSION}' |
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/task/export/id/TASKID' -X GET -H 'Accept: application/json' -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' --output export.zip |
On success this results in a file "export.zip" containing the task data.
...
Code Block | ||||
---|---|---|---|---|
| ||||
curl 'https://demo.translate5.net/editor/task/TASKID' -X DELETE -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' \ -H 'Accept: application/json' -H 'Mqi-Entity-Version: 123' |
...
Code Block |
---|
curl 'https://demo.translate5.net/editor/task/TASKID/workflow' -X POST -H 'CookieTranslate5AuthToken: zfExtended=HERE_WILL_BE_YOUR_SESSIONAPP_ID_THENTOKEN' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'Accept: application/json' --data 'trigger=notifyAllUsersAboutTaskAssociation' --compressed |
...