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.

Endpoint
GET https://api.uclassify.com/v1/{username}/{classifierName}/classify/?readKey=YOUR_READ_API_KEY_HERE&text=This+is+the+text+to+classify
URL parameters are
Name Type Description
readKeystringYour read key.
textstringThe text you want to classify, remember to url encoded it. Max length 16KB, for longer use the JSON REST API

Select classifier language

The classifier language is still in BETA and may be subject of unannounced changes.

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.

Endpoint for alternative language
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
keyRestrictedStringThe name of the class.
valuedoubleThe probability that the text belongs to class [0-1].
This example shows how to classify a text with the public 'Sentiment' classifier
https://api.uclassify.com/v1/uClassify/Sentiment/classify/?readKey=YOUR_READ_API_KEY_HERE&text=I+am+so+happy+today
Response
{
  "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
statusCodeint400=BAD_REQUEST, 413=REQUEST_ENTITY_TOO_LARGE, 500=INTERNAL_SERVER_ERROR, 530=SERVICE_UNAVAILABLE
messagestringThe error message.
Trying to classify with a non existing classifier gives the following error response
{
  "statusCode": 400,
  "message": "Authentification with the api key 'xxxxxxxxxnTB' for the classifier 'Not Existing' failed. The classifier doesn't exist."
}