Updated on 2025-08-22 GMT+08:00

Batch Adding Edges

Function

This API is used to add edges in batches.

URI

POST /ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

graph_name

Yes

String

Graph name

Request Parameters

Table 2 Request body parameter descriptions

Parameter

Mandatory

Type

Description

edges

Yes

edges List

Edge array to be added

parallelEdge

No

parallelEdge Object

How to process repetitive edges

createNotExists

No

Boolean

Whether to add source or target vertices that do not exist in the edges parameter before adding edges. The value can only be false.

false: Edges can be added regardless of whether the source or target vertex exists.

Table 3 edges parameter descriptions

Parameter

Mandatory

Type

Description

source

Yes

String

Source vertex of an edge

target

Yes

String

Target vertex of an edge

label

Yes

String

Edge label

sortKey

No

String

Sort key of duplicate edges. The options are Integer, String, and varString. If this parameter is set, label must also be set. The type must be the same as that of sortKey set during graph creation, except when null is assigned. If the sort key is empty, the value is null.

properties

No

Object

Value of each property

Table 4 parallelEdge parameter descriptions

Parameter

Mandatory

Type

Description

action

No

String

Processing mode. The value can be override or ignore.

  • If the value is override, the previous repetitive edges are overwritten.
  • If the value is ignore and an edge already exists, the previous edge will not be overwritten. If no edge exists, the system adds an edge.

ignoreLabel

No

Boolean

Whether to ignore labels on repetitive edges. The value can only be false.

false: Edges with the same source vertex, target vertex, label, and sort key are duplicate edges.

Response Parameters

Table 5 Response body parameter descriptions

Parameter

Type

Description

errorMessage

String

System prompt.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error message.

errorCode

String

System prompt.

  • If execution succeeds, this parameter may be left blank.
  • If execution fails, this parameter is used to display the error code.

result

String

Response result. If the request is successful, the value is success. If the request fails, the value is failed.

Example Request

Add edges in batches. The source vertex is 46, the target vertices are 39 and 38, the edge label is rate, and sortKey is 3 or 4.

POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/edges/action?action_id=batch-add
{
    "edges": [
        {
            "source": "46",
            "target": "39",
            "label": "rate",
            "sortKey": 3,
            "properties": {
                "Rating": [
                    5
                ],
                "Datetime": [
                    "2018-01-0120:30:05"
                ]
            }
        },
        {
            "source": "46",
            "target": "38",
            "label": "rate",
            "sortKey": 4,
            "properties": {
                "Rating": [
                    4
                ],
                "Datetime": [
                    "2018-01-0120:30:05"
                ]
            }
        }
    ],
    "parallelEdge": {
        "action": "override",
        "ignoreLabel": false
    },
    "createNotExists": false
}

SERVER_URL: Address for accessing a graph. For details about its value, see Using Service Plane APIs.

Example Response

Status code: 200

Example response for a successful request

Http Status Code: 200
{
 "result":"success",
 "data": {
     "edges": [
         {
             "index": "7",
             "source": "46",
             "target": "39"
         },
         {
             "index": "0",
             "source": "46",
             "target": "38"
         }
     ]
 }
}

Status code: 400

Example response for a failed request

Http Status Code: 400
{
    "errorMessage": "Parameter [source] cannot be empty.",
    "errorCode": "GES.8000",
    "result": "failed"
}

Status Codes

Return Value

Description

400 Bad Request

Request error.

401 Unauthorized

Authorization failed.

403 Forbidden

No operation permissions.

404 Not Found

No resources found.

500 Internal Server Error

Internal server error.

503 Service Unavailable

Service unavailable.

Error Codes

See Error Codes.