Content moderation provides external RESTful API services. See the API List below.
Service access is realized through domain name resolution. Regional access domain names are as follows:
Region | Domain Name |
---|---|
China | ai.jocloud.com |
For other regions, contact customer support.
RESTful API HTTP requests use JSON format. The JSON structure varies depending on the service request. See details in API List; click on an API's name for its definition.
To ensure the clarity and security of API communication, request path format and communication method definitions are provided below:
The request path differentiates moderation services. For details on all service access paths, see the API Listand click on a API for its definition.
Take the synchronous image content moderation API path as an example; its full request path is https://ai.jocloud.com/app/123456/v1/image/sync?traceId=bd526528-c0d7-4aa4-803b-f5a3fdc05805
wherein
ai.jocloud.com
specifies this particular API's service access domain name;123456789
is the service ID;v1
is the API version (the current version is v1);/image/sync
is the URL of the specific service—i.e. of the synchronous image content moderation API;traceId=bd526528-c0d7-4aa4-803b-f5a3fdc05805
specifies a trace ID for the user to differentiate requests.All APIs send requests by HTTPS protocol. Using HTTP requests will prompt a response to convert to HTTPS.
Both the request and its return are encoded in UTF-8.
Enter request parameters into the request body in JSON format. For service parameter details, see the API introduction page.
Before using the RESTful API, fill in the token field in the HTTP request's header for authentication. This document provides sample code for generating the token field with Java or Go. Refer to the code for the corresponding token values.
You will need to enter the certificate ID and certificate key into the code. To obtain these, log in and navigate to My Center. Click on your account name in the upper righthand corner, then select "API Certificate" from the drop-down menu.
The following is a sample code for Java and python to generate the token field.
Java sample code
Python sample code
AI moderation currently supports images, text, audio files and video files, providing API URL-based HTTPS POST requests:
Moderation Object | Function | Description |
---|---|---|
Image | Image Moderation | Detect any illegal content in images |
Audio | Voice Moderation | Detect any illegal content in voice clips |
Text | Text Moderation | Detect any illegal content in text passages |
Video | Video Moderation | Detect any illegal audio or video content in video clips |
Stream | Stream Moderation | Detect any illegal content in real-time audio and/or video streams |
Live Streaming | Live Streaming Moderation | Detect any illegal content within Jocloud's live streaming system |
API | Detection Mode | Default Concurrency | Description |
---|---|---|---|
app/{appid}/v1/image/sync | Synchronous | 20 | Synchronous image moderation |
API | Detection Mode | Default Concurrency | Description |
---|---|---|---|
app/{appid}/v1/audio/sync | Synchronous | 20 | Synchronous voice moderation |
app/{appid}/v1/audio/async | Asynchronous | 20 | Asynchronous voice moderation |
API | Detection Mode | Default Concurrency | Description |
---|---|---|---|
app/{appid}/v1/text/sync | Synchronous | 20 | Synchronous text moderation |
API | Detection Mode | Default Concurrency | Description |
---|---|---|---|
app/{appid}/v1/video/async | Asynchronous | 20 | Asynchronous video moderation |
API | Detection Mode | Default Concurrency | Description |
---|---|---|---|
app/{appid}/v1/video/live | Real-time | 20 | Real-time audio/video stream moderation |
API | Detection Mode | Default Concurrency | Description |
---|---|---|---|
app/{appId}/v1/ai/audio/live | Real-time | 20 | Jocloud Audio Interaction moderation |
app/{appId}/v1/ai/video/live/ | Real-time | 20 | Jocloud Video Interaction moderation |
All response result is JSON format
{
"code": 200, // error code for request
"message": "OK",
"traceId": "817ac1c0-7875-41ee-9bea-7edc7d2e9285",
"requestId": "21028cd6-8d9a-448c-acf6-54a17429b2ad",
"timestamp": 1590548848,
"data": [
{ // result info of every data in request
"code": 200, // error code for data
"message": "OK",
"dataId": "sex.jpg",
"taskId": "af65f1ab-df37-440b-a550-5eab48e87774",
"results": [
{ // result info of every action
"code": 200, // error code for action
"message": "OK",
"action": "porn",
"label": "sexy",
"rate": 0.9660250544548035,
"suggestion": "block"
}
]
}
]
}
code | message | desc |
---|---|---|
200 | OK | Success |
400 | Indeterminacy | Request content parsing exception or parameter error |
429 | Too many requests | Request exceeded traffic limit |
code | message | desc |
---|---|---|
200 | OK | Success |
400 | Indeterminacy | General is input exception |
401 | Download data from URL failed | Data download failed |
402 | Decode BASE64 data failed | Data Base64 decoding failed |
403 | Input too large | The incoming data is too large |
410 | Audio decode failed | Abnormal audio decoding |
411 | Input audio too long | Audio duration is too long |
412 | Convert audio to text failed | Audio to text failed |
413 | Audio check failed | Audio recognition failure |
420 | Image decode failed | Abnormal picture decoding |
421 | Image check failed | Picture recognition failure |
500 | Indeterminacy | Internal service exception |
503 | Service temporarily unavailable | Service temporarily unavailable |
Sample Code in Java
String restfulId = "qawsedrftg"; // Your Certificate ID
String restfulSecret = "abcdefghijk"; // Your Certificate Key
// Generate token
String plainIDSecret = restfulId + ":" + restfulSecret;
String base64IDSecret = new String(Base64.encodeBase64(plainIDSecret.getBytes("UTF-8")));
// Generate request object and add token information to request header
Request request = new Request.Builder()
.addHeader("token", "Basic " + base64IDSecret)
Sample Code in Python
#!/usr/bin/python3
import requests
import base64
appid = 123456 # Your Service id
restful_id = 'qawsedrftg' # Your certificate ID
restful_secret = 'abcdefghijk' # Your certificate key
# Fill in http header
headers = {
"content-type": "application/json"
}
# Generate Token
auth = base64.b64encode(("%s:%s" % (restful_id, restful_secret)).encode('utf-8'))
headers['token'] = 'Base ' + str(auth,'utf-8')
# request
url = "https://ai.jocloud.com/app/123456/v1/image/sync?traceId=bd526528-c0d7-4aa4-803b-f5a3fdc05805"
body = {}
res = requests.post(url, json=body, headers=headers)