Links

API Documentation

Thai Text Toxicity Classification
​
post
https://api.iapp.co.th/toxic-classification
/predict
Classify the toxicity of any given text.

Sample Request

cURL
Java-Unitest
NodeJs-Request
Objective C
PHP - Request2
Python
curl --location --request POST 'https://api.iapp.co.th/toxic-classification/predict?text=' \
--header 'apikey: {YOUR API KEY}'
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.iapp.co.th/toxic-classification/predict?text=")
.header("apikey", "{YOUR API KEY}")
.asString();
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.iapp.co.th/toxic-classification/predict?text=',
'headers': {
'apikey': '{YOUR API KEY}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​
#import <Foundation/Foundation.h>
​
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
​
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.iapp.co.th/toxic-classification/predict?text="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"apikey": @"{YOUR API KEY}"
};
​
[request setAllHTTPHeaderFields:headers];
​
[request setHTTPMethod:@"POST"];
​
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.iapp.co.th/toxic-classification/predict?text=');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apikey' => '{YOUR API KEY}'
));
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
import requests
​
url = "https://api.iapp.co.th/toxic-classification/predict?text="
​
payload={}
headers = {
'apikey': '{YOUR API KEY}'
}
​
response = requests.request("POST", url, headers=headers, data=payload)
​
print(response.text)
​
Sample Response

Postman Request Example