This topic describes how to use the software development kits (SDKs) that Alibaba Cloud Content Moderation provides in different development languages for you to call the Content Moderation API.

SDK instructions

Before using the SDKs, read the Content Moderation API documentation to understand the feature of each Content Moderation API operation.

  • In the SDKs, we expose the image moderation features, such as pornography detection, terrorist content detection, Optical Character Recognition (OCR), and logo detection, as one API. This API provides the following operations for you to call:
    • ImageSyncScanRequest operation: a synchronous operation to moderate images. You can call this operation to moderate multiple images at a time. The operation returns the moderation results of all images in real time. We recommend that you call this operation to moderate one image each time.
    • ImageAsyncScanRequest operation: an asynchronous operation to moderate images. You can call this operation to moderate multiple images at a time. If you submit multiple tasks to moderate multiple images, the operation returns a task ID for each image. You can use the task ID to poll the moderation result of each image. We recommend that you call this operation to moderate multiple images at a time.
  • In the SDKs, we expose the video moderation features, such as pornography detection, terrorist content detection, and logo detection, as one API. This API provides the following operations for you to call:
    • VideoSyncScanRequest operation: a synchronous operation to moderate videos. To call this operation to moderate a video, you must convert the video to a sequence of image frames and submit the image frames for moderation. We recommend that you do not call this operation to moderate videos.
    • VideoAsyncScanRequest operation: an asynchronous operation to moderate videos. You can call this operation to submit either a video or a sequence of image frames captured from the video for moderation. After you submit a video moderation task, the operation returns a task ID for the task. You can use the task ID to poll the moderation result. Alternatively, you can configure a callback URL to receive a callback notification of the moderation result. We recommend that you call this operation to moderate videos.
  • Audio anti-spam: The SDKs can detect spam in audio streams and audio files. Currently, the SDKs provide only an asynchronous operation to moderate audio content. After you submit an audio moderation task, the operation returns a task ID for the task. You can use the task ID to poll the moderation result. Alternatively, you can configure a callback URL to receive a callback notification of the moderation result.
  • Text anti-spam: The SDKs provide only a synchronous operation to detect spam in text. You can send a request to moderate one or more pieces of text.
Note If you specify multiple moderation scenarios when calling an operation, such as an image moderation operation, the expenses of all scenarios are calculated separately and summed up. The expense of a scenario equals the product of the unit price in that scenario and the quantity of scanned content.

Development preparations

  • Prepare the development environment for the Content Moderation SDK in the specific language that you choose.
  • Content Moderation provides the following SDKs in three different languages:
  • Download the SDK sample code.

    Click to download the green-sdk-sample_doc package.

    The sample code provides complete call examples of Java, PHP, and Python SDKs for your reference.

  • Obtain third-party SDKs in other languages for reference.
    If you use a development language other than Java, PHP, or Python, we recommend that you directly send an HTTP request to call the corresponding Content Moderation API operation. We have also listed some content moderation SDKs compiled by third-party developers for your reference. The third-party SDKs are available in the following languages: C#, C++, Node.js, and Go. For more information, see SDKs in other languages.
    Note The third-party SDKs are only for your reference. Alibaba Cloud does not provide follow-up maintenance for them.