URL Risk Detection API (Synchronous)

更新时间:
复制 MD 格式

The URL risk detection feature helps you identify risks such as fraud, pornography, and gambling in third-party URLs to maintain a healthy content ecosystem on your platform. This topic describes how to use the synchronous API to perform URL risk detection.

Get started

  1. Create an Alibaba Cloud account. If you do not have one, Sign up and complete the registration process.

  2. Activate Content Moderation. Make sure you Activate Service. Activation is free. After you start making API calls, you are billed on a pay-as-you-go basis. For more information, see URL Risk Detection and billing. You can also purchase a resource package. Resource packages offer tiered pricing and are recommended for users with predictable or high-volume usage.

  3. Create an AccessKey. Ensure you have an AccessKey. If you use an AccessKey that belongs to a RAM user, you must grant the AliyunYundunGreenWebFullAccess permission to the RAM user from your Alibaba Cloud account. For details, see RAM authorization.

  4. Start development. We recommend using an SDK to call the API. For more information, see the Developer guide.

Usage

You can call this operation to check URLs for risks. For information about how to construct HTTP requests, see HTTPS-based API calls. You can also use pre-configured requests. For more information, see the Developer guide.

  • Operation name: TextModeration

  • Supported regions and endpoints:

    Region

    Public endpoint

    Internal endpoint

    China (Shanghai)

    https://green-cip.cn-shanghai.aliyuncs.com

    https://green-cip-vpc.cn-shanghai.aliyuncs.com

    China (Hangzhou)

    https://green-cip.cn-hangzhou.aliyuncs.com

    https://green-cip-vpc.cn-hangzhou.aliyuncs.com

    China (Beijing)

    https://green-cip.cn-beijing.aliyuncs.com

    https://green-cip-vpc.cn-beijing.aliyuncs.com

    China (Shenzhen)

    https://green-cip.cn-shenzhen.aliyuncs.com

    Not available

    China (Chengdu)

    https://green-cip.cn-chengdu.aliyuncs.com

    Not available

  • Billing:

    This is a billable operation. Only requests with an HTTP status code of 200 are metered and billed. Requests that return other status codes are not billed. For more information about billing, see URL Risk Detection and billing.

  • URL format:

    The URL risk detection service supports URLs in the following format: http(s)://{IP or domain name}{:port}{/path}

    Note
    1. The URL prefix (http:// or https://) is optional.

    2. The domain name must consist of alphanumeric characters and periods (.). The top-level domain must be two to six characters long.

    3. The port must be a one- to four-digit number.

    4. The path supports digits, letters, and common characters such as _!~*'().;?:@&=+$,%#-). It does not support Chinese characters.

    The API returns the BAD_REQUEST(400) error code for URLs that do not match this format.

QPS limits

The queries per second (QPS) limit for this operation is 100 for a single user. If you exceed this limit, the system throttles your API calls, which may affect your business.

Debug the API

Before integration, you can use OpenAPI Explorer to test Content Moderation-Enhanced, view sample code and SDK dependencies, and get an overview of how to use the operation and its parameters.

Important

The online debugging tool calls Content Moderation API operations based on the currently logged-in account. These calls are included in your billable usage. To test the URL risk detection feature, call the Content Moderation-Enhanced operation and set the Service parameter accordingly.

Request parameters

Parameter

Type

Required

Example

Description

Service

String

Yes

url_detection

The moderation service type. Set the value to:

  • url_detection: URL risk detection

ServiceParameters

JSONString

Yes

The service-specific parameters, formatted as a JSON string. For details about the fields in this string, see the table below.

Table 1. ServiceParameters

Parameter

Type

Required

Example

Description

content

String

Yes

The content to scan

The URL to scan. The URL cannot exceed 600 characters.

accountId

String

No

10123****

The unique ID of an account.

deviceToken

String

No

MzQvo1d7scyZ3tl_RcJ******

The device token obtained from the risk control SDK.

Response parameters

Parameter

Type

Example

Description

Code

Integer

200

The status code. For more information, see Status codes.

Data

JSONObject

{"labels":"sexuality","reason":"..."}

The moderation result data. For more information, see Table 2. Data.

Message

String

OK

The response message.

RequestId

String

AAAAAA-BBBB-CCCCC-DDDD-EEEEEEEE****

The request ID.

Table 2. Data

Parameter

Type

Example

Description

Labels

String

sexuality

The risk labels. Separate multiple labels with commas (,). Possible values include:

  • sexual_url: Indicates a website suspected of containing pornographic content.

  • gambling_url: Indicates a website suspected of containing gambling-related content.

  • phishing_url: Indicates a suspected phishing website.

  • other_risk_url: Indicates suspected fraud or other risks.

  • unmarked_url: Indicates a normal website or a website that has not been flagged for any risks.

Reason

String

{\"icpType\":\"Enterprise\",\"icpNo\":\"ICP Bei 123456789\",\"score\":\"90\"}

A JSON string that contains additional information. The string includes the following fields:

  • icpType: The type of ICP filing.

  • icpNo: The ICP filing number.

  • score: The risk score.

Examples

Sample request

{
    "Service": "url_detection",
    "ServiceParameters": "{\"content\":\"http://aliyun.com/abc\",\"accountId\":\"10123****\"}"
}

Sample response

{
    "Code": 200,
    "Data": {
        "Labels": "unmarked_url",
        "Reason": "{\"icpType\":\"Enterprise\",\"icpNo\":\"ICP123XXXX789\",\"score\":\"60\"}"
    },
    "Message": "OK",
    "RequestId": "AAAAAA-BBBB-CCCCC-DDDD-EEEEEEEE****"
}

Status codes

The following table describes the API status codes. You are billed only for requests that return a status code of 200.

Code

Message

Description

200

OK

The request was successful.

400

BAD_REQUEST

The request was invalid, possibly due to incorrect request parameters. Verify the parameters and try again.

407

NOT_SUPPORT

The language type is not recognized or supported.

408

PERMISSION_DENY

Permission denied. This error can occur if your account is not authorized, has an overdue payment, the service has not been activated, or your account is suspended.

500

GENERAL_ERROR

A temporary server-side error occurred. Retry the request. If the error persists, contact Online Support.

581

TIMEOUT

The request timed out. Retry the request. If the error persists, contact Online Support.

588

EXCEED_QUOTA

The request frequency exceeded the configured limit.