Using the API |
Top Previous Next |
The CTexT NCHLT Web Services can be accessed via a RESTful API.
Step 1:
Generate a valid session ID using the following POST call:
http://{server:port}/CTexTWebAPI/services/setuser
When making this API call, the request header must contain the following property:
Key: Authorization Value: Basic aGVsZW4ncyBzdGludCBhcyBsZWFndWUgbWFuYWdlcg==
The response will be a JSON object containing a string array labeled token.
Example of reponse:
{"token":["4E3EDB46C33517701FC18F540FEBD5EE"]}
Step 2:
The API can then be called using a GET call and should always consist of the following information:
http://{server:port}/CTexTWebAPI/services?core={technology}&lang={code}&text={text}
Where the following is required:
•the server (and optional port number) on which the service is being hosted •the technology, either by number or shortened name •the two letter language code, as defined in Technologies and Supported Languages •the URL escaped Unicode text that should be processed by the technology •The token obtained using step 1 must be included in the request header as the authToken property
Examples:
http://127.0.0.1:8080/CTexTWebAPI/services?core=pos&lang=AF&text=teks+om+te+toets
http://127.0.0.1:8080/CTexTWebAPI/services?core=2&lang=EN&text=helen's+stint+as+league+manager
API parameter values:
Files can also be uploaded for processing (as long as they are smaller than 20Mb), through the curl tools or a multi-part form data, such as using curl. A valid authToken must be included in the request header. An example of this would be:
curl -F "file=@C:\Users\user\Desktop\Temp\Test.jpg" --form language=af --form core=ocr -X POST http://127.0.0.1:8080/CTexTWebAPI/services/file
|