Prediction APIs (Ranking)

Function

This API is used to perform online prediction.

URI

POST Prediction address returned after the service is successfully deployed

Request

Table 1 describes the request parameters.

Table 1 Request parameters

Parameter

Mandatory

Type

Description

rec_num

No

Integer

Number of the returned requests. The default value is 50.

user_id

Yes

String

User ID

rank_items

Yes

List

List of candidate sets uploaded by a user

Response

Table 2 describes the response parameters.
Table 2 Response parameters

Parameter

Mandatory

Type

Description

is_success

Yes

Boolean

Whether the request is successful. The value can be true or false. true indicates the request is successful, and false indicates the request has failed.

data

Yes

JSON

Data parameter. For details, see Table 3.

Table 3 data parameters

Parameter

Mandatory

Type

Description

trace_id

Yes

String

Message tracing ID, which identifies the recommendation result of the current request

rec_num

Yes

Integer

Number of returned results

user_id

Yes

String

User ID

content

Yes

List

Content of recommended items. For details, see Table 4

Table 4 content parameters

Parameter

Mandatory

Type

Description

score

Yes

Float

Score of an item. A larger value indicates a higher probability of being recommended.

item

Yes

JSON

Recommended item. For details, see Table 5.

Table 5 item parameters

Parameter

Mandatory

Type

Description

id

Yes

String

ID of a recommended item

Example

  • Example request
    {
        "rec_num": 50,
        "user_id": "260086000000100759",
        "rank_items": ["00860135010002401", "3101010003401"]
    }
  • Example of a successful response
    {
        "is_success": true,
        "data": {
            "trace_id": "a94495c062c6443b87c097427d99232d",
            "user_id": "260086000000100759",
            "rec_num": 2,
            "content": [
                {
                    "score": 0.524979,
                    "item": {
                        "id": "00860135010002401"
                    }
                },
                {
                    "score": 0.524979,
                    "item": {
                        "id": "3101010003401"
                    }
                }
            ]
        }
    }
  • Example of a failed response
    {
        "is_success": false,
        "error_msg": "Backend service found error. Failed to respond due to backend service not found or failed to respond, please check the service you request. "
    }

Status Code

For details about status codes, see Status Codes.