Help Center> RES> API Reference> API> Scenario> Creating a Custom Scenario

Creating a Custom Scenario

Function

This API is used to create a custom scenario in a specified workspace.

URI

POST /v2.0/{project_id}/workspaces/{workspace_id}/scenes

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details on how to obtain the project ID, see Obtaining a Project ID.

workspace_id

Yes

String

Workspace ID

Table 2 Query parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. For details on how to obtain the user token, see Obtaining a User Token Through Password Authentication.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Content type. The value is application/json.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

category

Yes

String

Scenario type. The option is:

  • customize indicates the custom recommendation scenario.

datasource_id

Yes

String

Data source ID

ds_config

Yes

ds_config object

Data source settings

scene_name

Yes

String

Scenario name, which is a string of 1 to 64 characters and contains letters, digits, underscores (_), and hyphens (-)

Minimum: 1

Maximum: 64

specs_config

Yes

SpecsConfig object

Computing specifications

type

Yes

String

Scenario type. The options are:

  • UI: recommending items based on users

  • UU: recommending users based on users

  • II: recommending items based on items

  • IU: recommending users based on items

service_type

Yes

String

Service type. The options are:

  • rank: ranking service

  • rec: recommendation service

Table 5 ds_config

Parameter

Mandatory

Type

Description

time_interval

No

Integer

Time range for selecting data (days)

category_type

No

String

Item type

Table 6 SpecsConfig

Parameter

Mandatory

Type

Description

offline

Yes

String

Offline computing specifications

nearline

No

String

Real-time computing specifications

rank

No

String

Deep learning computing specifications

online_tps

No

Integer

Max. number of concurrent online services

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

is_success

Boolean

Whether the request is successful

message

String

Response message (This field is not returned when the request is successful.)

scene

scene object

Scenario

error_code

String

Error code (This parameter is not returned when the request is successful.)

Table 8 scene

Parameter

Type

Description

category

String

Type

type

String

Scenario type

scene_name

String

Scenario name

scene_id

String

Scenario ID

datasource_id

String

Data source ID

status

String

Status

created_at

String

Creation time

update_at

String

Update time

workspace_id

String

Workspace ID

service_type

String

Service type

Example Requests

This API is used to create a scenario.

/v2.0/testuuidxxxxxxxxxxxxxxxxxxxxxxxx/workspaces/testuuidxxxxxxxxxxxxxxxxxxxxxxxx/scenes

{
  "scene_name" : "jby-test-0227-4",
  "category" : "customize",
  "type" : "UI",
  "service_type" : "rank",
  "datasource_id" : "6a3475a7dd11492e8d14f73a3719333b",
  "ds_config" : {
    "time_interval" : 30
  },
  "specs_config" : {
    "offline" : "4CU",
    "nearline" : "2CU",
    "rank" : "8CU",
    "online_tps" : 10
  }
}

Example Responses

Status code: 200

OK

{
  "scene" : {
    "type" : "UI",
    "service_type" : "rank",
    "scene_name" : "jby-test-0227-4",
    "category" : "customize",
    "scene_id" : "f715e1c61f1f40489b2e4594650fffd8",
    "datasource_id" : "6a3475a7dd11492e8d14f73a3719333b",
    "status" : "INITIALIZED",
    "created_at" : 1584628346333,
    "update_at" : 0,
    "workspace_id" : "68887f2a855f45e7ab4850ecc7ca28c2"
  },
  "is_success" : true
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.