URL REST API
Overview
This is the easiest to use API, it's directed to users who only want to classify one text at a time. A request is done via GET, all authentification and data is passed as parameters in the URL. The response is a JSON dictionary, where the key is the class name and the value the probability.
It doesn't support long texts (>16KB), batching or training classifiers.
Requests
All requests must go via HTTPS, the base URL is
https://api.uclassify.com/v1/
Classify
The call
classify
classifies one text and returns a dictionary with class names and probabilities.
GET https://api.uclassify.com/v1/{username}/{classifierName}/classify/?readKey=YOUR_READ_API_KEY_HERE&text=This+is+the+text+to+classifyURL parameters are
Name | Type | Description |
---|---|---|
readKey | string | Your read key. |
text | string | The text you want to classify, remember to url encoded it. Max length 16KB, for longer use the JSON REST API |
Select classifier language
Multilingual classifiers will show a list of available languages above the description. E.g. see the Sentiment classifier.
Set the language
in the url to one of the following language codes, 'fr' (French), 'es' (Spanish) or 'sv' (Swedish).
This will assume your texts are in the given language and use the corresponding version of the classifier.
GET https://api.uclassify.com/v1/{username}/{classifierName}/{language}/classify/?readKey=YOUR_READ_API_KEY_HERE&text=This+is+the+text+to+classify
Response
The classify response is a json dictionary where the keys are the class names and the values are corresponding probabilities.
Name | Type | Description |
---|---|---|
key | RestrictedString | The name of the class. |
value | double | The probability that the text belongs to class [0-1]. |
https://api.uclassify.com/v1/uClassify/Sentiment/classify/?readKey=YOUR_READ_API_KEY_HERE&text=I+am+so+happy+todayResponse
{ "negative": 0.133089, "positive": 0.866911 }
Error Responses
If the request was unsuccessful (HTTP status code other than 2xx) an JSON encoded error response body is returned.
Name | Type | Description |
---|---|---|
statusCode | int | 400=BAD_REQUEST, 413=REQUEST_ENTITY_TOO_LARGE, 500=INTERNAL_SERVER_ERROR, 530=SERVICE_UNAVAILABLE |
message | string | The error message. |
{ "statusCode": 400, "message": "Authentification with the api key 'xxxxxxxxxnTB' for the classifier 'Not Existing' failed. The classifier doesn't exist." }