Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

HugeGraph RESTful API

HugeGraph RESTful API reference for graph, schema, vertex, and edge operations.

This section documents the REST API on current master. For historical APIs, switch to the versioned HugeGraph 1.7 RESTful API documentation or HugeGraph 1.5 RESTful API documentation.

The default graph space is DEFAULT.

After starting Server, open http://localhost:8080/swagger-ui/index.html to view the OpenAPI page for the current version. See the usage example.

1 - Graphspace API

Graphspace REST API: Multi-tenancy and resource isolation for creating, viewing, updating, and deleting graph spaces with prerequisites and constraints.

2.0 Graphspace

HugeGraph implements multi-tenancy through graph spaces, which isolate compute/storage resources per tenant.

Prerequisites

  1. Graphspace currently only works in HStore mode.
  2. In non-HStore mode you can only use the default graphspace DEFAULT; creating/deleting/updating other graphspaces is not supported.
  3. Set usePD=true in rest-server.properties and backend=hstore in hugegraph.properties.
  4. Production requires Server authentication and authorization, and auth=true for new graph spaces. Replace the public default administrator password pa configured by auth.admin_pa.
  5. Every endpoint on this page requires PD mode. In standalone mode they answer 400 with the message GraphSpace management is not supported in standalone mode.
Warning

Restrict graph-space listing and detail endpoints

GET /graphspaces and GET /graphspaces/{graphspace} have no @RolesAllowed annotation. They are anonymous when Server authentication is disabled and lack method-level administrator checks when it is enabled. Detail responses contain dp_username and dp_password. In production, set white_ip.status=enable and maintain the IP allowlist. A gateway must restrict both paths by caller identity or role to administrators and trusted operators; restricting only source IPs still lets ordinary authenticated accounts on that network read DP credentials. Server network policy must allow only trusted gateway egress addresses to the API port, blocking direct client bypass. Record caller identity, source, and outcome at the gateway. Server audit-*.log files record authentication and authorization but do not replace gateway access auditing for these paths. Grant business accounts minimum permissions.

2.0.1 Create a graphspace

Method & Url
1POST http://localhost:8080/graphspaces
Request Body

Note: CPU/memory and Kubernetes-related capabilities are not publicly available yet.

NameRequiredTypeDefaultRange/NoteDescription
nameYesStringLowercase letters, digits, underscore; must start with a letter; max length 48Graphspace name
nicknameNoStringnameMust be unique among graphspacesDisplay name of the graphspace
descriptionNoStringDescription
cpu_limitYesInt> 0CPU cores for the graphspace
memory_limitYesInt> 0 (GB)Memory quota in GB
storage_limitYesInt> 0Maximum disk usage, in GB
compute_cpu_limitNoInt0>= 0Extra HugeGraph-Computer CPU cores; falls back to cpu_limit if unset or 0
compute_memory_limitNoInt0>= 0Extra HugeGraph-Computer memory in GB; falls back to memory_limit if unset or 0
oltp_namespaceNoString""Kubernetes namespace for OLTP HugeGraph-Server
olap_namespaceNoString""Resources are merged when identical to oltp_namespaceKubernetes namespace for OLAP / HugeGraph-Computer
storage_namespaceNoString""Kubernetes namespace for HugeGraph-Store
operator_image_pathNoString""HugeGraph-Computer operator image registry
internal_algorithm_image_urlNoString""HugeGraph-Computer algorithm image registry
max_graph_numberYesInt> 0Maximum number of graphs that can be created inside the graphspace
max_role_numberNoInt0Maximum number of roles that can be created inside the graphspace
authNoBooleanfalsetrue / falseWhether to enable authentication for the graphspace
configsNoMapAdditional configuration
 1{
 2  "name": "gs1",
 3  "description": "1st graph space",
 4  "max_graph_number": 100,
 5  "cpu_limit": 1000,
 6  "memory_limit": 8192,
 7  "storage_limit": 1000000,
 8  "max_role_number": 10,
 9  "auth": true,
10  "configs": {}
11}
Response Status
1201
Response Body
 1{
 2  "name": "gs1",
 3  "nickname": "gs1",
 4  "description": "1st graph space",
 5  "cpu_limit": 1000,
 6  "memory_limit": 8192,
 7  "storage_limit": 1000000,
 8  "compute_cpu_limit": 0,
 9  "compute_memory_limit": 0,
10  "oltp_namespace": "hugegraph-server",
11  "olap_namespace": "hugegraph-server",
12  "storage_namespace": "hugegraph-server",
13  "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1",
14  "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1",
15  "max_graph_number": 100,
16  "max_role_number": 10,
17  "cpu_used": 0,
18  "memory_used": 0,
19  "storage_used": 0,
20  "storage_percent": 0.0,
21  "graph_number_used": 0,
22  "role_number_used": 0,
23  "auth": true,
24  "creator": "admin",
25  "create_time": "2024-05-01 12:00:00",
26  "update_time": "2024-05-01 12:00:00"
27}

2.0.2 List all graphspaces

Method & Url
1GET http://localhost:8080/graphspaces
Response Status
1200
Response Body
1{
2  "graphSpaces": [
3    "gs1",
4    "DEFAULT"
5  ]
6}

2.0.3 Get graphspace details

Params

Path parameters

  • graphspace: Graphspace name
Method & Url
1GET http://localhost:8080/graphspaces/gs1
Response Status
1200
Response Body
 1{
 2  "name": "gs1",
 3  "nickname": "gs1",
 4  "description": "1st graph space",
 5  "cpu_limit": 1000,
 6  "memory_limit": 8192,
 7  "storage_limit": 1000000,
 8  "oltp_namespace": "hugegraph-server",
 9  "olap_namespace": "hugegraph-server",
10  "storage_namespace": "hugegraph-server",
11  "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1",
12  "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1",
13  "compute_cpu_limit": 0,
14  "compute_memory_limit": 0,
15  "max_graph_number": 100,
16  "max_role_number": 10,
17  "cpu_used": 0,
18  "memory_used": 0,
19  "storage_used": 0,
20  "storage_percent": 0.0,
21  "graph_number_used": 0,
22  "role_number_used": 0,
23  "auth": true,
24  "creator": "admin",
25  "create_time": "2024-05-01 12:00:00",
26  "update_time": "2024-05-01 12:00:00",
27  "dp_username": "gs1_dp",
28  "dp_password": "a1b2c3d4e5f60718"
29}

The dp_username and dp_password values above are documentation examples. Real detail responses contain the graph space’s DP credentials and must be protected as sensitive credentials.

2.0.4 Update a graphspace

auth cannot be changed once a graphspace is created.

Params

Path parameter

  • graphspace: Graphspace name

Request parameters

  • action: Must be "update"
  • update: Container for the actual fields to update (see table below)
NameRequiredTypeRange/NoteDescription
nameYesStringMust match the graphspace name in the pathGraphspace name
nicknameNoStringMust be unique among graphspacesDisplay name of the graphspace
descriptionNoStringDescription
cpu_limitYesInt> 0CPU cores for OLTP HugeGraph-Server
memory_limitYesInt> 0 (GB)Memory quota (GB) for OLTP HugeGraph-Server
storage_limitYesInt> 0Maximum disk usage, in GB
compute_cpu_limitNoInt>= 0Extra HugeGraph-Computer CPU cores; falls back to cpu_limit if unset or 0
compute_memory_limitNoInt>= 0Extra HugeGraph-Computer memory in GB; falls back to memory_limit if unset or 0
oltp_namespaceYesStringKubernetes namespace for OLTP HugeGraph-Server
olap_namespaceYesStringResources are merged when identical to oltp_namespaceKubernetes namespace for OLAP
storage_namespaceYesStringKubernetes namespace for HugeGraph-Store
operator_image_pathNoStringHugeGraph-Computer operator image registry
internal_algorithm_image_urlNoStringHugeGraph-Computer algorithm image registry
max_graph_numberYesInt> 0Maximum number of graphs
max_role_numberYesInt> 0Maximum number of roles
Method & Url
1PUT http://localhost:8080/graphspaces/gs1
Request Body
 1{
 2  "action": "update",
 3  "update": {
 4    "name": "gs1",
 5    "description": "1st graph space",
 6    "cpu_limit": 2000,
 7    "memory_limit": 40960,
 8    "storage_limit": 2048,
 9    "oltp_namespace": "hugegraph-server",
10    "olap_namespace": "hugegraph-server",
11    "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1",
12    "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1",
13    "max_graph_number": 1000,
14    "max_role_number": 100
15  }
16}
Response Status
1200
Response Body
 1{
 2  "name": "gs1",
 3  "nickname": "gs1",
 4  "description": "1st graph space",
 5  "cpu_limit": 2000,
 6  "memory_limit": 40960,
 7  "storage_limit": 2048,
 8  "oltp_namespace": "hugegraph-server",
 9  "olap_namespace": "hugegraph-server",
10  "storage_namespace": "hugegraph-server",
11  "operator_image_path": "127.0.0.1/hugegraph-registry/hugegraph-computer-operator:3.1.1",
12  "internal_algorithm_image_url": "127.0.0.1/hugegraph-registry/hugegraph-computer-algorithm:3.1.1",
13  "compute_cpu_limit": 0,
14  "compute_memory_limit": 0,
15  "max_graph_number": 1000,
16  "max_role_number": 100,
17  "cpu_used": 0,
18  "memory_used": 0,
19  "storage_used": 0,
20  "storage_percent": 0.0,
21  "graph_number_used": 0,
22  "role_number_used": 0,
23  "auth": true,
24  "creator": "admin",
25  "create_time": "2024-05-01 12:00:00",
26  "update_time": "2024-05-01 12:30:00"
27}

2.0.5 Delete a graphspace

Params

Path parameter

  • graphspace: Graphspace name
Method & Url
1DELETE http://localhost:8080/graphspaces/gs1
Response Status
1204

Warning: deleting a graphspace releases all resources that belong to it.

2.0.6 List all graphspaces with their details

Params

Query parameters

  • prefix: Return only the graphspaces whose name or nickname starts with this prefix
Method & Url
1GET http://localhost:8080/graphspaces/profile
Response Status
1200
Response Body

Each entry carries the same fields as GET /graphspaces/{graphspace} plus authed, default, create_time and update_time. authed says whether the current user may enter the graphspace: it is false when the graphspace has authentication on and the user is neither an administrator, nor a manager, nor a member of it. default is always false for now, the default-graphspace feature is not implemented yet.

 1[
 2  {
 3    "name": "gs1",
 4    "nickname": "gs1",
 5    "description": "1st graph space",
 6    "cpu_limit": 1000,
 7    "memory_limit": 8192,
 8    "storage_limit": 1000000,
 9    "compute_cpu_limit": 0,
10    "compute_memory_limit": 0,
11    "oltp_namespace": "hugegraph-server",
12    "olap_namespace": "hugegraph-server",
13    "storage_namespace": "hugegraph-server",
14    "max_graph_number": 100,
15    "max_role_number": 10,
16    "cpu_used": 0,
17    "memory_used": 0,
18    "storage_used": 0,
19    "storage_percent": 0.0,
20    "graph_number_used": 0,
21    "role_number_used": 0,
22    "auth": true,
23    "creator": "admin",
24    "authed": true,
25    "default": false,
26    "create_time": "2024-05-01 12:00:00",
27    "update_time": "2024-05-01 12:30:00"
28  }
29]

Default roles

Every graphspace carries four built-in roles, so that a user or a group can be given a whole set of permissions at once:

  • space: manager of the graphspace, only an administrator may grant it
  • space_member: member of the graphspace
  • analyst: analyst of the graphspace
  • observer: read-only role, it can be narrowed to a single graph by passing graph

user accepts either a user name or a group name. Whether the current user holds a default role can also be checked with GET /graphspaces/{graphspace}/auth/managers/default, see Authentication API.

2.0.7 Grant a default role

Params

Path parameter

  • graphspace: Graphspace name

Request parameters

  • user: User or group name, required
  • role: One of space, space_member, analyst, observer, required
  • graph: Graph name, optional, only taken into account with role=observer
Method & Url
1POST http://localhost:8080/graphspaces/gs1/role
Request Body
1{
2  "user": "boss",
3  "role": "analyst"
4}
Response Status
1201
Response Body

graph is echoed back only when the role was granted on a single graph.

1{
2  "user": "boss",
3  "role": "analyst",
4  "graphSpace": "gs1"
5}

2.0.8 Check a default role

Params

Path parameter

  • graphspace: Graphspace name

Query parameters

  • user: User or group name, required
  • role: Default role name, required
  • graph: Graph name, optional, only taken into account with role=observer
Method & Url
1GET http://localhost:8080/graphspaces/gs1/role?user=boss&role=analyst
Response Status
1200
Response Body
1{
2  "check": true
3}

2.0.9 Revoke a default role

Params

Path parameter

  • graphspace: Graphspace name

Query parameters

  • user: User or group name, required
  • role: Default role name, required
  • graph: Graph name, optional, only taken into account with role=observer
Method & Url
1DELETE http://localhost:8080/graphspaces/gs1/role?user=boss&role=analyst
Response Status
1204

Schema templates

A schema template stores a Gremlin schema script under a name, so that a new graph can be initialized with it by passing schema when the graph is created, see Graphs API. A template can be updated or deleted by its creator, by a manager of the graphspace, or by an administrator.

2.0.10 Create a schema template

Params

Path parameter

  • graphspace: Graphspace name

Request parameters

  • name: Template name, required
  • schema: Gremlin schema script, required
Method & Url
1POST http://localhost:8080/graphspaces/gs1/schematemplates
Request Body
1{
2  "name": "template1",
3  "schema": "schema.propertyKey('name').asText().ifNotExist().create();"
4}
Response Status
1201
Response Body
1{
2  "name": "template1",
3  "schema": "schema.propertyKey('name').asText().ifNotExist().create();",
4  "creator": "admin",
5  "create": "2024-05-01 12:00:00.000",
6  "create_time": "2024-05-01 12:00:00.000",
7  "update": "2024-05-01 12:00:00.000",
8  "update_time": "2024-05-01 12:00:00.000"
9}

2.0.11 List the schema templates of a graphspace

Method & Url
1GET http://localhost:8080/graphspaces/gs1/schematemplates
Response Status
1200
Response Body
1{
2  "schema_templates": [
3    "template1"
4  ]
5}

2.0.12 Get a schema template

Method & Url
1GET http://localhost:8080/graphspaces/gs1/schematemplates/template1
Response Status
1200

2.0.13 Update a schema template

Only schema can be updated, the name of a template is fixed.

Method & Url
1PUT http://localhost:8080/graphspaces/gs1/schematemplates/template1
Request Body
1{
2  "schema": "schema.propertyKey('age').asInt().ifNotExist().create();"
3}
Response Status
1200

2.0.14 Delete a schema template

Method & Url
1DELETE http://localhost:8080/graphspaces/gs1/schematemplates/template1
Response Status
1204

2 - Schema API

Schema REST API: Query the complete schema definition of a graph, including property keys, vertex labels, edge labels, and index labels.

1.1 Schema

HugeGraph provides a single interface to get all Schema information of a graph, including: PropertyKey, VertexLabel, EdgeLabel and IndexLabel.

Method & Url
1GET http://localhost:8080/graphspaces/{graphspace}/graphs/{graph_name}/schema
2
3e.g: GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema
Response Status
1200
Response Body
  1{
  2    "propertykeys": [
  3        {
  4            "id": 7,
  5            "name": "price",
  6            "data_type": "DOUBLE",
  7            "cardinality": "SINGLE",
  8            "aggregate_type": "NONE",
  9            "write_type": "OLTP",
 10            "properties": [],
 11            "status": "CREATED",
 12            "user_data": {
 13                "~create_time": "2023-05-08 17:49:05.316"
 14            }
 15        },
 16        {
 17            "id": 6,
 18            "name": "date",
 19            "data_type": "TEXT",
 20            "cardinality": "SINGLE",
 21            "aggregate_type": "NONE",
 22            "write_type": "OLTP",
 23            "properties": [],
 24            "status": "CREATED",
 25            "user_data": {
 26                "~create_time": "2023-05-08 17:49:05.309"
 27            }
 28        },
 29        {
 30            "id": 3,
 31            "name": "city",
 32            "data_type": "TEXT",
 33            "cardinality": "SINGLE",
 34            "aggregate_type": "NONE",
 35            "write_type": "OLTP",
 36            "properties": [],
 37            "status": "CREATED",
 38            "user_data": {
 39                "~create_time": "2023-05-08 17:49:05.287"
 40            }
 41        },
 42        {
 43            "id": 2,
 44            "name": "age",
 45            "data_type": "INT",
 46            "cardinality": "SINGLE",
 47            "aggregate_type": "NONE",
 48            "write_type": "OLTP",
 49            "properties": [],
 50            "status": "CREATED",
 51            "user_data": {
 52                "~create_time": "2023-05-08 17:49:05.280"
 53            }
 54        },
 55        {
 56            "id": 5,
 57            "name": "lang",
 58            "data_type": "TEXT",
 59            "cardinality": "SINGLE",
 60            "aggregate_type": "NONE",
 61            "write_type": "OLTP",
 62            "properties": [],
 63            "status": "CREATED",
 64            "user_data": {
 65                "~create_time": "2023-05-08 17:49:05.301"
 66            }
 67        },
 68        {
 69            "id": 4,
 70            "name": "weight",
 71            "data_type": "DOUBLE",
 72            "cardinality": "SINGLE",
 73            "aggregate_type": "NONE",
 74            "write_type": "OLTP",
 75            "properties": [],
 76            "status": "CREATED",
 77            "user_data": {
 78                "~create_time": "2023-05-08 17:49:05.294"
 79            }
 80        },
 81        {
 82            "id": 1,
 83            "name": "name",
 84            "data_type": "TEXT",
 85            "cardinality": "SINGLE",
 86            "aggregate_type": "NONE",
 87            "write_type": "OLTP",
 88            "properties": [],
 89            "status": "CREATED",
 90            "user_data": {
 91                "~create_time": "2023-05-08 17:49:05.250"
 92            }
 93        }
 94    ],
 95    "vertexlabels": [
 96        {
 97            "id": 1,
 98            "name": "person",
 99            "id_strategy": "PRIMARY_KEY",
100            "primary_keys": [
101                "name"
102            ],
103            "nullable_keys": [
104                "age",
105                "city"
106            ],
107            "index_labels": [
108                "personByAge",
109                "personByCity",
110                "personByAgeAndCity"
111            ],
112            "properties": [
113                "name",
114                "age",
115                "city"
116            ],
117            "status": "CREATED",
118            "ttl": 0,
119            "enable_label_index": true,
120            "user_data": {
121                "~create_time": "2023-05-08 17:49:05.336"
122            }
123        },
124        {
125            "id": 2,
126            "name": "software",
127            "id_strategy": "CUSTOMIZE_NUMBER",
128            "primary_keys": [],
129            "nullable_keys": [],
130            "index_labels": [
131                "softwareByPrice"
132            ],
133            "properties": [
134                "name",
135                "lang",
136                "price"
137            ],
138            "status": "CREATED",
139            "ttl": 0,
140            "enable_label_index": true,
141            "user_data": {
142                "~create_time": "2023-05-08 17:49:05.347"
143            }
144        }
145    ],
146    "edgelabels": [
147        {
148            "id": 1,
149            "name": "knows",
150            "source_label": "person",
151            "target_label": "person",
152            "frequency": "SINGLE",
153            "sort_keys": [],
154            "nullable_keys": [],
155            "index_labels": [
156                "knowsByWeight"
157            ],
158            "properties": [
159                "weight",
160                "date"
161            ],
162            "status": "CREATED",
163            "ttl": 0,
164            "enable_label_index": true,
165            "user_data": {
166                "~create_time": "2023-05-08 17:49:08.437"
167            }
168        },
169        {
170            "id": 2,
171            "name": "created",
172            "source_label": "person",
173            "target_label": "software",
174            "frequency": "SINGLE",
175            "sort_keys": [],
176            "nullable_keys": [],
177            "index_labels": [
178                "createdByDate",
179                "createdByWeight"
180            ],
181            "properties": [
182                "weight",
183                "date"
184            ],
185            "status": "CREATED",
186            "ttl": 0,
187            "enable_label_index": true,
188            "user_data": {
189                "~create_time": "2023-05-08 17:49:08.446"
190            }
191        }
192    ],
193    "indexlabels": [
194        {
195            "id": 1,
196            "name": "personByAge",
197            "base_type": "VERTEX_LABEL",
198            "base_value": "person",
199            "index_type": "RANGE_INT",
200            "fields": [
201                "age"
202            ],
203            "status": "CREATED",
204            "user_data": {
205                "~create_time": "2023-05-08 17:49:05.375"
206            }
207        },
208        {
209            "id": 2,
210            "name": "personByCity",
211            "base_type": "VERTEX_LABEL",
212            "base_value": "person",
213            "index_type": "SECONDARY",
214            "fields": [
215                "city"
216            ],
217            "status": "CREATED",
218            "user_data": {
219                "~create_time": "2023-05-08 17:49:06.898"
220            }
221        },
222        {
223            "id": 3,
224            "name": "personByAgeAndCity",
225            "base_type": "VERTEX_LABEL",
226            "base_value": "person",
227            "index_type": "SECONDARY",
228            "fields": [
229                "age",
230                "city"
231            ],
232            "status": "CREATED",
233            "user_data": {
234                "~create_time": "2023-05-08 17:49:07.407"
235            }
236        },
237        {
238            "id": 4,
239            "name": "softwareByPrice",
240            "base_type": "VERTEX_LABEL",
241            "base_value": "software",
242            "index_type": "RANGE_DOUBLE",
243            "fields": [
244                "price"
245            ],
246            "status": "CREATED",
247            "user_data": {
248                "~create_time": "2023-05-08 17:49:07.916"
249            }
250        },
251        {
252            "id": 5,
253            "name": "createdByDate",
254            "base_type": "EDGE_LABEL",
255            "base_value": "created",
256            "index_type": "SECONDARY",
257            "fields": [
258                "date"
259            ],
260            "status": "CREATED",
261            "user_data": {
262                "~create_time": "2023-05-08 17:49:08.454"
263            }
264        },
265        {
266            "id": 6,
267            "name": "createdByWeight",
268            "base_type": "EDGE_LABEL",
269            "base_value": "created",
270            "index_type": "RANGE_DOUBLE",
271            "fields": [
272                "weight"
273            ],
274            "status": "CREATED",
275            "user_data": {
276                "~create_time": "2023-05-08 17:49:08.963"
277            }
278        },
279        {
280            "id": 7,
281            "name": "knowsByWeight",
282            "base_type": "EDGE_LABEL",
283            "base_value": "knows",
284            "index_type": "RANGE_DOUBLE",
285            "fields": [
286                "weight"
287            ],
288            "status": "CREATED",
289            "user_data": {
290                "~create_time": "2023-05-08 17:49:09.473"
291            }
292        }
293    ]
294}

3 - PropertyKey API

PropertyKey REST API: Define data types and cardinality constraints for all properties in the graph, serving as fundamental schema elements.

1.2 PropertyKey

Params Description:

  • name: The name of the property type, required.
  • data_type: The data type of the property type, including: bool, byte, int, long, float, double, text, blob, date, uuid. The default data type is text (Represent a string type)
  • cardinality: The cardinality of the property type, including: single, list, set. The default cardinality is single.

Request Body Field Description:

  • id: The ID value of the property type.
  • properties: The properties of the property type. For properties, this field is empty.
  • user_data: Setting the common information of the property type, such as setting the value range of the age property from 0 to 100. Currently, no validation is performed on this field, and it is only a reserved entry for future expansion.

1.2.1 Create a PropertyKey

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys
Request Body
1{
2    "name": "age",
3    "data_type": "INT",
4    "cardinality": "SINGLE"
5}
Response Status
1202
Response Body
 1{
 2    "property_key": {
 3        "id": 1,
 4        "name": "age",
 5        "data_type": "INT",
 6        "cardinality": "SINGLE",
 7        "aggregate_type": "NONE",
 8        "write_type": "OLTP",
 9        "properties": [],
10        "status": "CREATED",
11        "user_data": {
12            "~create_time": "2022-05-13 13:47:23.745"
13        }
14    },
15    "task_id": 0
16}

1.2.2 Add or Remove userdata for an existing PropertyKey

Params
  • action: Indicates whether the current action is to add or remove userdata. Possible values are append (add) and eliminate (remove).
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age?action=append
Request Body
1{
2    "name": "age",
3    "user_data": {
4        "min": 0,
5        "max": 100
6    }
7}
Response Status
1202
Response Body
 1{
 2    "property_key": {
 3        "id": 1,
 4        "name": "age",
 5        "data_type": "INT",
 6        "cardinality": "SINGLE",
 7        "aggregate_type": "NONE",
 8        "write_type": "OLTP",
 9        "properties": [],
10        "status": "CREATED",
11        "user_data": {
12            "min": 0,
13            "max": 100,
14            "~create_time": "2022-05-13 13:47:23.745"
15        }
16    },
17    "task_id": 0
18}

1.2.3 Get all PropertyKeys

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys
Response Status
1200
Response Body
 1{
 2    "propertykeys": [
 3        {
 4            "id": 3,
 5            "name": "city",
 6            "data_type": "TEXT",
 7            "cardinality": "SINGLE",
 8            "properties": [],
 9            "user_data": {}
10        },
11        {
12            "id": 2,
13            "name": "age",
14            "data_type": "INT",
15            "cardinality": "SINGLE",
16            "properties": [],
17            "user_data": {}
18        },
19        {
20            "id": 5,
21            "name": "lang",
22            "data_type": "TEXT",
23            "cardinality": "SINGLE",
24            "properties": [],
25            "user_data": {}
26        },
27        {
28            "id": 4,
29            "name": "weight",
30            "data_type": "DOUBLE",
31            "cardinality": "SINGLE",
32            "properties": [],
33            "user_data": {}
34        },
35        {
36            "id": 6,
37            "name": "date",
38            "data_type": "TEXT",
39            "cardinality": "SINGLE",
40            "properties": [],
41            "user_data": {}
42        },
43        {
44            "id": 1,
45            "name": "name",
46            "data_type": "TEXT",
47            "cardinality": "SINGLE",
48            "properties": [],
49            "user_data": {}
50        },
51        {
52            "id": 7,
53            "name": "price",
54            "data_type": "INT",
55            "cardinality": "SINGLE",
56            "properties": [],
57            "user_data": {}
58        }
59    ]
60}

1.2.4 Get PropertyKey according to name

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age

Where age is the name of the PropertyKey to be retrieved.

Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "name": "age",
 4    "data_type": "INT",
 5    "cardinality": "SINGLE",
 6    "aggregate_type": "NONE",
 7    "write_type": "OLTP",
 8    "properties": [],
 9    "status": "CREATED",
10    "user_data": {
11        "min": 0,
12        "max": 100,
13        "~create_time": "2022-05-13 13:47:23.745"
14    }
15}

1.2.5 Delete PropertyKey according to name

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys/age

Where age is the name of the PropertyKey to be deleted.

Response Status
1202
Response Body
1{
2    "task_id" : 0
3}

4 - VertexLabel API

VertexLabel REST API: Define vertex types, ID strategies, and associated properties that determine vertex structure and constraints.

1.3 VertexLabel

Assuming that the PropertyKeys listed in 1.1.3 have already been created.

Params Description:

  • id: The ID value of the vertex type.
  • name: The name of the vertex type, required.
  • id_strategy: The ID strategy for the vertex type, including primary key ID, auto-generated, custom string, custom number, custom UUID. The default strategy is primary key ID.
  • properties: The property types associated with the vertex type.
  • primary_keys: The primary key properties. This field must have a value when the ID strategy is PRIMARY_KEY, and must be empty for other ID strategies.
  • enable_label_index: Whether to enable label indexing. It is disabled by default.
  • index_names: The indexes created for the vertex type. See details in section 3.4.
  • nullable_keys: Nullable properties.
  • user_data: Setting the common information of the vertex type, similar to the property type.

1.3.1 Create a VertexLabel

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels
Request Body
 1{
 2    "name": "person",
 3    "id_strategy": "DEFAULT",
 4    "properties": [
 5        "name",
 6        "age"
 7    ],
 8    "primary_keys": [
 9        "name"
10    ],
11    "nullable_keys": [],
12    "enable_label_index": true
13}
Response Status
1201
Response Body
 1{
 2    "id": 1,
 3    "primary_keys": [
 4        "name"
 5    ],
 6    "id_strategy": "PRIMARY_KEY",
 7    "name": "person2",
 8    "index_names": [
 9    ],
10    "properties": [
11        "name",
12        "age"
13    ],
14    "nullable_keys": [
15    ],
16    "enable_label_index": true,
17    "user_data": {}
18}

Starting from version v0.11.2, hugegraph-server supports Time-to-Live (TTL) functionality for vertices. The TTL for vertices is set through VertexLabel. For example, if you want the vertices of type “person” to have a lifespan of one day, you need to set the TTL field to 86400000 (in milliseconds) when creating the “person” VertexLabel.

 1{
 2    "name": "person",
 3    "id_strategy": "DEFAULT",
 4    "properties": [
 5        "name",
 6        "age"
 7    ],
 8    "primary_keys": [
 9        "name"
10    ],
11    "nullable_keys": [],
12    "ttl": 86400000,
13    "enable_label_index": true
14}

Additionally, if the vertex has a property called “createdTime” and you want to use it as the starting point for calculating the vertex’s lifespan, you can set the ttl_start_time field in the VertexLabel. For example, if the “person” VertexLabel has a property called “createdTime” of type Date, and you want the vertices of type “person” to live for one day starting from the creation time, the Request Body for creating the “person” VertexLabel would be as follows:

 1{
 2    "name": "person",
 3    "id_strategy": "DEFAULT",
 4    "properties": [
 5        "name",
 6        "age",
 7        "createdTime"
 8    ],
 9    "primary_keys": [
10        "name"
11    ],
12    "nullable_keys": [],
13    "ttl": 86400000,
14    "ttl_start_time": "createdTime",
15    "enable_label_index": true
16}

1.3.2 Add properties or userdata to an existing VertexLabel, or remove userdata (removing properties is currently not supported)

Params
  • action: Indicates whether the current action is to add or remove. Possible values are append (add) and eliminate (remove).
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person?action=append
Request Body
 1{
 2    "name": "person",
 3    "properties": [
 4        "city"
 5    ],
 6    "nullable_keys": ["city"],
 7    "user_data": {
 8        "super": "animal"
 9    }
10}
Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "primary_keys": [
 4        "name"
 5    ],
 6    "id_strategy": "PRIMARY_KEY",
 7    "name": "person",
 8    "index_names": [
 9    ],
10    "properties": [
11        "city",
12        "name",
13        "age"
14    ],
15    "nullable_keys": [
16        "city"
17    ],
18    "enable_label_index": true,
19    "user_data": {
20        "super": "animal"
21    }
22}

1.3.3 Get all VertexLabels

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels
Response Status
1200
Response Body
 1{
 2    "vertexlabels": [
 3        {
 4            "id": 1,
 5            "primary_keys": [
 6                "name"
 7            ],
 8            "id_strategy": "PRIMARY_KEY",
 9            "name": "person",
10            "index_names": [
11            ],
12            "properties": [
13                "city",
14                "name",
15                "age"
16            ],
17            "nullable_keys": [
18                "city"
19            ],
20            "enable_label_index": true,
21            "user_data": {
22                "super": "animal"
23            }
24        },
25        {
26            "id": 2,
27            "primary_keys": [
28                "name"
29            ],
30            "id_strategy": "PRIMARY_KEY",
31            "name": "software",
32            "index_names": [
33            ],
34            "properties": [
35                "price",
36                "name",
37                "lang"
38            ],
39            "nullable_keys": [
40                "price"
41            ],
42            "enable_label_index": false,
43            "user_data": {}
44        }
45    ]
46}

1.3.4 Get VertexLabel by name

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person
Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "primary_keys": [
 4        "name"
 5    ],
 6    "id_strategy": "PRIMARY_KEY",
 7    "name": "person",
 8    "index_names": [
 9    ],
10    "properties": [
11        "city",
12        "name",
13        "age"
14    ],
15    "nullable_keys": [
16        "city"
17    ],
18    "enable_label_index": true,
19    "user_data": {
20        "super": "animal"
21    }
22}

1.3.5 Delete VertexLabel by name

Deleting a VertexLabel will result in the removal of corresponding vertices and related index data. This operation will generate an asynchronous task.

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels/person
Response Status
1202
Response Body
1{
2    "task_id": 1
3}

Note:

You can use GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1 (where “1” is the task_id) to query the execution status of the asynchronous task. For more information, refer to the Asynchronous Task RESTful API.

5 - EdgeLabel API

EdgeLabel REST API: Define edge types and relationship constraints between source and target vertices to construct graph connection rules.

1.4 EdgeLabel

Assuming PropertyKeys from version 1.2.3 and VertexLabels from version 1.3.3 have already been created.

Params Explanation

  • name: Name of the vertex type, required.
  • source_label: Name of the source vertex type, required.
  • target_label: Name of the target vertex type, required.
  • frequency: Whether there can be multiple edges between two points, can have values SINGLE or MULTIPLE, optional (default value: SINGLE).
  • properties: Property types associated with the edge type, optional.
  • sort_keys: Specifies a list of differentiating key properties when multiple associations are allowed.
  • nullable_keys: Nullable properties, optional (default: nullable).
  • enable_label_index: Whether to enable type indexing, disabled by default.

1.4.1 Create an EdgeLabel

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels
Request Body
 1{
 2    "name": "created",
 3    "source_label": "person",
 4    "target_label": "software",
 5    "frequency": "SINGLE",
 6    "properties": [
 7        "date"
 8    ],
 9    "sort_keys": [],
10    "nullable_keys": [],
11    "enable_label_index": true
12}
Response Status
1201
Response Body
 1{
 2    "id": 1,
 3    "sort_keys": [
 4    ],
 5    "source_label": "person",
 6    "name": "created",
 7    "index_names": [
 8    ],
 9    "properties": [
10        "date"
11    ],
12    "target_label": "software",
13    "frequency": "SINGLE",
14    "nullable_keys": [
15    ],
16    "enable_label_index": true,
17    "user_data": {}
18}

Starting from version 0.11.2 of hugegraph-server, the TTL (Time to Live) feature for edges is supported. The TTL for edges is set through EdgeLabel. For example, if you want the “knows” type of edge to have a lifespan of one day, you need to set the TTL field to 86400000 when creating the “knows” EdgeLabel, where the unit is milliseconds.

 1{
 2    "id": 1,
 3    "sort_keys": [
 4    ],
 5    "source_label": "person",
 6    "name": "knows",
 7    "index_names": [
 8    ],
 9    "properties": [
10        "date",
11        "createdTime"
12    ],
13    "target_label": "person",
14    "frequency": "SINGLE",
15    "nullable_keys": [
16    ],
17    "enable_label_index": true,
18    "ttl": 86400000,
19    "user_data": {}
20}

Additionally, when the edge has a property called “createdTime” and you want to use the “createdTime” property as the starting point for calculating the edge’s lifespan, you can set the ttl_start_time field in the EdgeLabel. For example, if the knows EdgeLabel has a property called “createdTime” which is of type Date, and you want the “knows” type of edge to live for one day from the time of creation, the Request Body for creating the knows EdgeLabel would be as follows:

 1{
 2    "id": 1,
 3    "sort_keys": [
 4    ],
 5    "source_label": "person",
 6    "name": "knows",
 7    "index_names": [
 8    ],
 9    "properties": [
10        "date",
11        "createdTime"
12    ],
13    "target_label": "person",
14    "frequency": "SINGLE",
15    "nullable_keys": [
16    ],
17    "enable_label_index": true,
18    "ttl": 86400000,
19    "ttl_start_time": "createdTime",
20    "user_data": {}
21}

1.4.2 Add properties or userdata to an existing EdgeLabel, or remove userdata (removing properties is currently not supported)

Params
  • action: Indicates whether the current action is to add or remove, with values append (add) and eliminate (remove).
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created?action=append
Request Body
1{
2    "name": "created",
3    "properties": [
4        "weight"
5    ],
6    "nullable_keys": [
7        "weight"
8    ]
9}
Response Status
1200
Response Body
 1{
 2    "id": 2,
 3    "sort_keys": [
 4    ],
 5    "source_label": "person",
 6    "name": "created",
 7    "index_names": [
 8    ],
 9    "properties": [
10        "date",
11        "weight"
12    ],
13    "target_label": "software",
14    "frequency": "SINGLE",
15    "nullable_keys": [
16        "weight"
17    ],
18    "enable_label_index": true,
19    "user_data": {}
20}

1.4.3 Get all EdgeLabels

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels
Response Status
1200
Response Body
 1{
 2    "edgelabels": [
 3        {
 4            "id": 1,
 5            "sort_keys": [
 6            ],
 7            "source_label": "person",
 8            "name": "created",
 9            "index_names": [
10            ],
11            "properties": [
12                "date",
13                "weight"
14            ],
15            "target_label": "software",
16            "frequency": "SINGLE",
17            "nullable_keys": [
18                "weight"
19            ],
20            "enable_label_index": true,
21            "user_data": {}
22        },
23        {
24            "id": 2,
25            "sort_keys": [
26            ],
27            "source_label": "person",
28            "name": "knows",
29            "index_names": [
30            ],
31            "properties": [
32                "date",
33                "weight"
34            ],
35            "target_label": "person",
36            "frequency": "SINGLE",
37            "nullable_keys": [
38            ],
39            "enable_label_index": false,
40            "user_data": {}
41        }
42    ]
43}

1.4.4 Get EdgeLabel by name

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created
Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "sort_keys": [
 4    ],
 5    "source_label": "person",
 6    "name": "created",
 7    "index_names": [
 8    ],
 9    "properties": [
10        "date",
11        "city",
12        "weight"
13    ],
14    "target_label": "software",
15    "frequency": "SINGLE",
16    "nullable_keys": [
17        "city",
18        "weight"
19    ],
20    "enable_label_index": true,
21    "user_data": {}
22}

1.4.5 Delete EdgeLabel by name

Deleting an EdgeLabel will result in the deletion of corresponding edges and related index data. This operation will generate an asynchronous task.

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels/created
Response Status
1202
Response Body
1{
2    "task_id": 1
3}

Note:

You can query the execution status of an asynchronous task by using GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1 (where “1” is the task_id). For more information, refer to the Asynchronous Task RESTful API.

6 - IndexLabel API

IndexLabel REST API: Create indexes on vertex and edge properties to accelerate property-based queries and filtering operations.

1.5 IndexLabel

Assuming PropertyKeys from version 1.1.3, VertexLabels from version 1.2.3, and EdgeLabels from version 1.3.3 have already been created.

1.5.1 Create an IndexLabel

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels
Request Body
1{
2    "name": "personByCity",
3    "base_type": "VERTEX_LABEL",
4    "base_value": "person",
5    "index_type": "SECONDARY",
6    "fields": [
7        "city"
8    ]
9}
Response Status
1202
Response Body
 1{
 2    "index_label": {
 3        "id": 1,
 4        "base_type": "VERTEX_LABEL",
 5        "base_value": "person",
 6        "name": "personByCity",
 7        "fields": [
 8            "city"
 9        ],
10        "index_type": "SECONDARY"
11    },
12    "task_id": 2
13}

1.5.2 Get all IndexLabels

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels
Response Status
1200
Response Body
 1{
 2    "indexlabels": [
 3        {
 4            "id": 3,
 5            "base_type": "VERTEX_LABEL",
 6            "base_value": "software",
 7            "name": "softwareByPrice",
 8            "fields": [
 9                "price"
10            ],
11            "index_type": "RANGE"
12        },
13        {
14            "id": 4,
15            "base_type": "EDGE_LABEL",
16            "base_value": "created",
17            "name": "createdByDate",
18            "fields": [
19                "date"
20            ],
21            "index_type": "SECONDARY"
22        },
23        {
24            "id": 1,
25            "base_type": "VERTEX_LABEL",
26            "base_value": "person",
27            "name": "personByCity",
28            "fields": [
29                "city"
30            ],
31            "index_type": "SECONDARY"
32        },
33        {
34            "id": 3,
35            "base_type": "VERTEX_LABEL",
36            "base_value": "person",
37            "name": "personByAgeAndCity",
38            "fields": [
39                "age",
40                "city"
41            ],
42            "index_type": "SECONDARY"
43        }
44    ]
45}

1.5.3 Get IndexLabel by name

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity
Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "base_type": "VERTEX_LABEL",
 4    "base_value": "person",
 5    "name": "personByCity",
 6    "fields": [
 7        "city"
 8    ],
 9    "index_type": "SECONDARY"
10}

1.5.4 Delete IndexLabel by name

Deleting an IndexLabel will result in the deletion of related index data. This operation will generate an asynchronous task.

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity
Response Status
1202
Response Body
1{
2    "task_id": 1
3}

Note:

You can query the execution status of an asynchronous task by using GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1 (where “1” is the task_id). For more information, refer to the Asynchronous Task RESTful API.

1.5.5 Add or remove userdata for an existing IndexLabel

Only user_data can be changed this way, base_type, base_value and index_type must be left out of the request body.

Params
  • action: Indicates whether the current action is to add or remove userdata. Possible values are append (add) and eliminate (remove).
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/indexlabels/personByCity?action=append
Request Body
1{
2    "name": "personByCity",
3    "user_data": {
4        "comment": "index on city"
5    }
6}
Response Status
1200
Response Body
 1{
 2    "id": 1,
 3    "base_type": "VERTEX_LABEL",
 4    "base_value": "person",
 5    "name": "personByCity",
 6    "fields": [
 7        "city"
 8    ],
 9    "index_type": "SECONDARY",
10    "user_data": {
11        "comment": "index on city",
12        "~create_time": "2022-05-13 13:47:23.745"
13    }
14}

7 - Rebuild API

Rebuild REST API: Rebuild graph schema indexes to ensure consistency between index data and graph data.

1.6 Rebuild

1.6.1 Rebuild IndexLabel

Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/indexlabels/personByCity
Response Status
1202
Response Body
1{
2    "task_id": 1
3}

Note:

You can get the asynchronous job status by GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/${task_id} (the task_id here should be 1). See More AsyncJob RESTfull API

1.6.2 Rebulid all Indexs of VertexLabel

Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/vertexlabels/person
Response Status
1202
Response Body
1{
2    "task_id": 2
3}

Note:

You can get the asynchronous job status by GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/${task_id} (the task_id here should be 2). See More AsyncJob RESTfull API

1.6.3 Rebulid all Indexs of EdgeLabel

Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/rebuild/edgelabels/created
Response Status
1202
Response Body
1{
2    "task_id": 3
3}

Note:

You can get the asynchronous job status by GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/${task_id} (the task_id here should be 3). See More AsyncJob RESTfull API

8 - Vertex API

Vertex REST API: Create, query, update, and delete vertex data in the graph with support for batch operations and conditional filtering.

2.1 Vertex

In vertex types, the Id strategy determines the type of the vertex Id, with the corresponding relationships as follows:

Vertex ID strategies
Id_Strategyid type
AUTOMATICnumber
PRIMARY_KEYstring
CUSTOMIZE_STRINGstring
CUSTOMIZE_NUMBERnumber
CUSTOMIZE_UUIDuuid

For the GET/PUT/DELETE API of a vertex, the id part in the URL should be passed as the id value with type information. This type information is indicated by whether the JSON string is enclosed in quotes, meaning:

  • When the id type is number, the id in the URL is without quotes, for example: xxx/vertices/123456.
  • When the id type is string, the id in the URL is enclosed in quotes, for example: xxx/vertices/"123456".

The next example requires first creating the graph schema from the following groovy script

 1schema.propertyKey("name").asText().ifNotExist().create();
 2schema.propertyKey("age").asInt().ifNotExist().create();
 3schema.propertyKey("city").asText().ifNotExist().create();
 4schema.propertyKey("weight").asDouble().ifNotExist().create();
 5schema.propertyKey("lang").asText().ifNotExist().create();
 6schema.propertyKey("price").asDouble().ifNotExist().create();
 7schema.propertyKey("hobby").asText().valueList().ifNotExist().create();
 8
 9schema.vertexLabel("person").properties("name", "age", "city", "weight", "hobby").primaryKeys("name").nullableKeys("age", "city", "weight", "hobby").ifNotExist().create();
10schema.vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").nullableKeys("lang", "price").ifNotExist().create();
11
12schema.indexLabel("personByAge").onV("person").by("age").range().ifNotExist().create();

2.1.1 Create a vertex

Method & Url

1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices

Request Body

1{
2    "label": "person",
3    "properties": {
4        "name": "marko",
5        "age": 29
6    }
7}

Response Status

1201

Response Body

1{
2    "id": "1:marko",
3    "label": "person",
4    "type": "vertex",
5    "properties": {
6        "name": "marko",
7        "age": 29
8    }
9}

2.1.2 Create multiple vertices

Method & Url

1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch

Request Body

 1[
 2    {
 3        "label": "person",
 4        "properties": {
 5            "name": "marko",
 6            "age": 29
 7        }
 8    },
 9    {
10        "label": "software",
11        "properties": {
12            "name": "ripple",
13            "lang": "java",
14            "price": 199
15        }
16    }
17]

Response Status

1201

Response Body

1[
2    "1:marko",
3    "2:ripple"
4]

2.1.3 Update vertex properties

Method & Url

1PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?action=append

Request Body

1{
2    "label": "person",
3    "properties": {
4        "age": 30,
5        "city": "Beijing"
6    }
7}

Note: There are three categories for property values: single, set, and list. If it is single, it means adding or updating the property value. If it is set or list, it means appending the property value.

Response Status

1200

Response Body

 1{
 2    "id": "1:marko",
 3    "label": "person",
 4    "type": "vertex",
 5    "properties": {
 6        "name": "marko",
 7        "age": 30,
 8        "city": "Beijing"
 9    }
10}

2.1.4 Batch Update Vertex Properties

Function Description

Batch update properties of vertices and support various update strategies, including:

  • SUM: Numeric accumulation
  • BIGGER: Take the larger value between two numbers/dates
  • SMALLER: Take the smaller value between two numbers/dates
  • UNION: Take the union of set properties
  • INTERSECTION: Take the intersection of set properties
  • APPEND: Append elements to list properties
  • ELIMINATE: Remove elements from list/set properties
  • OVERRIDE: Override existing properties, if the new property is null, the old property is still used

Assuming the original vertex and properties are:

 1{
 2    "vertices": [
 3        {
 4            "id": "2:lop",
 5            "label": "software",
 6            "type": "vertex",
 7            "properties": {
 8                "name": "lop",
 9                "lang": "java",
10                "price": 328
11            }
12        },
13        {
14            "id": "1:josh",
15            "label": "person",
16            "type": "vertex",
17            "properties": {
18                "name": "josh",
19                "age": 32,
20                "city": "Beijing",
21                "weight": 0.1,
22                "hobby": [
23                    "reading",
24                    "football"
25                ]
26            }
27        }
28    ]
29}

Add vertices with the following command:

1curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"josh","age":32,"city":"Beijing","weight":0.1,"hobby":["reading","football"]}},{"label":"software","properties":{"name":"lop","lang":"java","price":328}}]' http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch

Method & Url

1PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch

Request Body

 1{
 2    "vertices": [
 3        {
 4            "label": "software",
 5            "type": "vertex",
 6            "properties": {
 7                "name": "lop",
 8                "lang": "c++",
 9                "price": 299
10            }
11        },
12        {
13            "label": "person",
14            "type": "vertex",
15            "properties": {
16                "name": "josh",
17                "city": "Shanghai",
18                "weight": 0.2,
19                "hobby": [
20                    "swimming"
21                ]
22            }
23        }
24    ],
25    "update_strategies": {
26        "price": "BIGGER",
27        "age": "OVERRIDE",
28        "city": "OVERRIDE",
29        "weight": "SUM",
30        "hobby": "UNION"
31    },
32    "create_if_not_exist": true
33}

Response Status

1200

Response Body

 1{
 2    "vertices": [
 3        {
 4            "id": "2:lop",
 5            "label": "software",
 6            "type": "vertex",
 7            "properties": {
 8                "name": "lop",
 9                "lang": "c++",
10                "price": 328
11            }
12        },
13        {
14            "id": "1:josh",
15            "label": "person",
16            "type": "vertex",
17            "properties": {
18                "name": "josh",
19                "age": 32,
20                "city": "Shanghai",
21                "weight": 0.3,
22                "hobby": [
23                    "reading",
24                    "football",
25                    "swimming"
26                ]
27            }
28        }
29    ]
30}

Result Analysis:

  • The lang property does not specify an update strategy and is directly overwritten by the new value, regardless of whether the new value is null.
  • The price property specifies the BIGGER update strategy. The old property value is 328, and the new property value is 299, so the old property value of 328 is retained.
  • The age property specifies the OVERRIDE update strategy, but the new property value does not include age, which is equivalent to age being null. Therefore, the original property value of 32 is still retained.
  • The city property also specifies the OVERRIDE update strategy, and the new property value is not null, so it overrides the old value.
  • The weight property specifies the SUM update strategy. The old property value is 0.1, and the new property value is 0.2. The final value is 0.3.
  • The hobby property (cardinality is Set) specifies the UNION update strategy, so the new value is taken as the union with the old value.

The usage of other update strategies can be inferred in a similar manner and will not be further elaborated.

2.1.5 Delete Vertex Properties

Method & Url

1PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?action=eliminate

Request Body

1{
2    "label": "person",
3    "properties": {
4        "city": "Beijing"
5    }
6}

Note: Here, the properties (keys and all values) will be directly deleted, regardless of whether the property values are single, set, or list.

Response Status

1200

Response Body

1{
2    "id": "1:marko",
3    "label": "person",
4    "type": "vertex",
5    "properties": {
6        "name": "marko",
7        "age": 30
8    }
9}

2.1.6 Get Vertices that Meet the Criteria

Params

  • label: Vertex type
  • properties: Property key-value pairs (precondition: indexes are created for property queries)
  • keep_start_p: Default is false. When set to true, the range matching input expression will not be automatically escaped. For example, properties={"age":"P.gt(18)"} will be interpreted as an exact match, i.e., the age property is equal to the string “P.gt(18)”
  • offset: Offset, default is 0
  • limit: Maximum number of results, default is 100
  • page: Page number

All of the above parameters are optional. page can not be combined with a non-zero offset, everything else can be combined in any way.

Property key-value pairs consist of the property name and value in JSON format. Multiple property key-value pairs are allowed as query conditions. The property value supports exact matching, range matching, and fuzzy matching. For exact matching, use the format properties={"age":29}, for range matching, use the format properties={"age":"P.gt(29)"}, and for fuzzy matching, use the format properties={"city": "P.textcontains("ChengDu China")}. The following expressions are supported for range matching:

ExpressionExplanation
P.eq(number)Vertices with property value equal to number
P.neq(number)Vertices with property value not equal to number
P.lt(number)Vertices with property value less than number
P.lte(number)Vertices with property value less than or equal to number
P.gt(number)Vertices with property value greater than number
P.gte(number)Vertices with property value greater than or equal to number
P.between(number1,number2)Vertices with property value greater than or equal to number1 and less than number2
P.inside(number1,number2)Vertices with property value greater than number1 and less than number2
P.outside(number1,number2)Vertices with property value less than number1 and greater than number2
P.within(value1,value2,value3,…)Vertices with property value equal to any of the given values

Query all vertices with age 29 and label person

Method & Url

1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?label=person&properties={"age":29}&limit=1

Response Status

1200

Response Body

 1{
 2    "vertices": [
 3        {
 4            "id": "1:marko",
 5            "label": "person",
 6            "type": "vertex",
 7            "properties": {
 8                "name": "marko",
 9                "age": 30
10            }
11        }
12    ]
13}

Paginate through all vertices, retrieve the first page (page without parameter value), limited to 3 records

Add vertices with the following command:

1curl -H "Content-Type: application/json" -d '[{"label":"person","properties":{"name":"peter","age":29,"city":"Shanghai"}},{"label":"person","properties":{"name":"vadas","age":27,"city":"Hongkong"}}]' http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/batch

Method & Url

1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?page&limit=3

Response Status

1200

Response Body

 1{
 2    "vertices": [
 3        {
 4            "id": "2:lop",
 5            "label": "software",
 6            "type": "vertex",
 7            "properties": {
 8                "name": "lop",
 9                "lang": "c++",
10                "price": 328
11            }
12        },
13        {
14            "id": "1:josh",
15            "label": "person",
16            "type": "vertex",
17            "properties": {
18                "name": "josh",
19                "age": 32,
20                "city": "Shanghai",
21                "weight": 0.3,
22                "hobby": [
23                    "reading",
24                    "football",
25                    "swimming"
26                ]
27            }
28        },
29        {
30            "id": "1:marko",
31            "label": "person",
32            "type": "vertex",
33            "properties": {
34                "name": "marko",
35                "age": 30
36            }
37        }
38    ],
39    "page": "CIYxOnBldGVyAAAAAAAAAAM="
40}

The returned body contains information about the page number of the next page, "page": "CIYxOnBldGVyAAAAAAAAAAM". When querying the next page, assign this value to the page parameter.

Paginate and retrieve all vertices, including the next page (passing the page value returned from the previous page), limited to 3 items.

Method & Url

1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices?page=CIYxOnBldGVyAAAAAAAAAAM=&limit=3

Response Status

1200

Response Body

 1{
 2    "vertices": [
 3        {
 4            "id": "1:peter",
 5            "label": "person",
 6            "type": "vertex",
 7            "properties": {
 8                "name": "peter",
 9                "age": 29,
10                "city": "Shanghai"
11            }
12        },
13        {
14            "id": "1:vadas",
15            "label": "person",
16            "type": "vertex",
17            "properties": {
18                "name": "vadas",
19                "age": 27,
20                "city": "Hongkong"
21            }
22        },
23        {
24            "id": "2:ripple",
25            "label": "software",
26            "type": "vertex",
27            "properties": {
28                "name": "ripple",
29                "lang": "java",
30                "price": 199
31            }
32        }
33    ],
34    "page": null
35}

At this point, "page": null indicates that there are no more pages available. (Note: When using Cassandra as the backend for performance reasons, if the returned page happens to be the last page, the page value may not be empty. When requesting the next page using that page value, it will return empty data and page = null. The same applies to other similar situations.)

2.1.7 Retrieve Vertex by ID

Method & Url

1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"

Response Status

1200

Response Body

1{
2    "id": "1:marko",
3    "label": "person",
4    "type": "vertex",
5    "properties": {
6        "name": "marko",
7        "age": 30
8    }
9}

2.1.8 Delete Vertex by ID

Params

  • label: Vertex type, optional parameter

Delete the vertex based on ID only.

Method & Url

1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"

Response Status

1204

Delete Vertex by Label+ID

When deleting a vertex by specifying both the Label parameter and the ID, it generally offers better performance compared to deleting by ID alone.

Method & Url

1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/"1:marko"?label=person

Response Status

1204

9 - Edge API

Edge REST API: Create, query, update, and delete relationship data between vertices with support for batch operations and directional queries.

2.2 Edge

The modification of the vertex ID format also affects the ID of the edge, as well as the formats of the source vertex and target vertex IDs.

The EdgeId is formed by concatenating src-vertex-id + direction + label + sort-values + tgt-vertex-id, but the vertex ID types are not distinguished by quotation marks here. Instead, they are distinguished by prefixes:

  • When the ID type is number, the vertex ID in the EdgeId has a prefix L, like “L123456>1»L987654”.
  • When the ID type is string, the vertex ID in the EdgeId has a prefix S, like “S1:peter>1»S2:lop”.

The following example requires creating a graph schema based on the following groovy script:

 1import org.apache.hugegraph.HugeFactory
 2import org.apache.tinkerpop.gremlin.structure.T
 3
 4conf = "conf/graphs/hugegraph.properties"
 5graph = HugeFactory.open(conf)
 6schema = graph.schema()
 7
 8schema.propertyKey("name").asText().ifNotExist().create()
 9schema.propertyKey("age").asInt().ifNotExist().create()
10schema.propertyKey("city").asText().ifNotExist().create()
11schema.propertyKey("weight").asDouble().ifNotExist().create()
12schema.propertyKey("lang").asText().ifNotExist().create()
13schema.propertyKey("date").asText().ifNotExist().create()
14schema.propertyKey("price").asInt().ifNotExist().create()
15
16schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create()
17schema.vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create()
18schema.indexLabel("personByCity").onV("person").by("city").secondary().ifNotExist().create()
19schema.indexLabel("personByAgeAndCity").onV("person").by("age", "city").secondary().ifNotExist().create()
20schema.indexLabel("softwareByPrice").onV("software").by("price").range().ifNotExist().create()
21schema.edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date", "weight").ifNotExist().create()
22schema.edgeLabel("created").sourceLabel("person").targetLabel("software").properties("date", "weight").ifNotExist().create()
23schema.indexLabel("createdByDate").onE("created").by("date").secondary().ifNotExist().create()
24schema.indexLabel("createdByWeight").onE("created").by("weight").range().ifNotExist().create()
25schema.indexLabel("knowsByWeight").onE("knows").by("weight").range().ifNotExist().create()
26
27marko = graph.addVertex(T.label, "person", "name", "marko", "age", 29, "city", "Beijing")
28vadas = graph.addVertex(T.label, "person", "name", "vadas", "age", 27, "city", "Hongkong")
29lop = graph.addVertex(T.label, "software", "name", "lop", "lang", "java", "price", 328)
30josh = graph.addVertex(T.label, "person", "name", "josh", "age", 32, "city", "Beijing")
31ripple = graph.addVertex(T.label, "software", "name", "ripple", "lang", "java", "price", 199)
32peter = graph.addVertex(T.label, "person", "name", "peter", "age", 35, "city", "Shanghai")
33
34graph.tx().commit()
35g = graph.traversal()

2.2.1 Creating an Edge

Params

Path Parameter Description:

  • graph: The graph to operate on

Request Body Description:

  • label: The edge type name (required)
  • outV: The source vertex id (required)
  • inV: The target vertex id (required)
  • outVLabel: The source vertex type (required)
  • inVLabel: The target vertex type (required)
  • properties: The properties associated with the edge. The internal structure of the object is as follows:
    1. name: The property name
    2. value: The property value
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges
Request Body
 1{
 2    "label": "created",
 3    "outV": "1:marko",
 4    "inV": "2:lop",
 5    "outVLabel": "person",
 6    "inVLabel": "software",
 7    "properties": {
 8        "date": "20171210",
 9        "weight": 0.4
10    }
11}
Response Status
1201
Response Body
 1{
 2    "id": "S1:marko>2>>S2:lop",
 3    "label": "created",
 4    "type": "edge",
 5    "outV": "1:marko",
 6    "outVLabel": "person",
 7    "inV": "2:lop",
 8    "inVLabel": "software",
 9    "properties": {
10        "weight": 0.4,
11        "date": "20171210"
12    }
13}

2.2.2 Creating Multiple Edges

Params

Path Parameter Description:

  • graph: The graph to operate on

Request Parameter Description:

  • check_vertex: Whether to check the existence of vertices (true | false). When set to true, an error will be thrown if the source or target vertices of the edge to be inserted do not exist. Default is true.

Request Body Description:

  • List of edge information
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/batch
Request Body
 1[
 2    {
 3        "label": "knows",
 4        "outV": "1:marko",
 5        "inV": "1:vadas",
 6        "outVLabel": "person",
 7        "inVLabel": "person",
 8        "properties": {
 9            "date": "20160110",
10            "weight": 0.5
11        }
12    },
13    {
14        "label": "knows",
15        "outV": "1:marko",
16        "inV": "1:josh",
17        "outVLabel": "person",
18        "inVLabel": "person",
19        "properties": {
20            "date": "20130220",
21            "weight": 1.0
22        }
23    }
24]
Response Status
1201
Response Body
1[
2    "S1:marko>1>>S1:vadas",
3    "S1:marko>1>>S1:josh"
4]

2.2.3 Updating Edge Properties

Params

Path Parameter Description:

  • graph: The graph to operate on
  • id: The ID of the edge to be operated on

Request Parameter Description:

  • action: The append action

Request Body Description:

  • Edge information
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=append
Request Body
1{
2    "properties": {
3        "weight": 1.0
4    }
5}

NOTE: There are three categories of property values: single, set, and list. If it is single, it means adding or updating the property value. If it is set or list, it means appending the property value.

Response Status
1200
Response Body
 1{
 2    "id": "S1:marko>2>>S2:lop",
 3    "label": "created",
 4    "type": "edge",
 5    "outV": "1:marko",
 6    "outVLabel": "person",
 7    "inV": "2:lop",
 8    "inVLabel": "software",
 9    "properties": {
10        "weight": 1.0,
11        "date": "20171210"
12    }
13}

2.2.4 Batch Updating Edge Properties

Params

Path Parameter Description:

  • graph: The graph to operate on

Request Body Description:

  • edges: List of edge information
  • update_strategies: For each property, you can set its update strategy individually, including:
    • SUM: Only supports number type
    • BIGGER/SMALLER: Only supports date/number type
    • UNION/INTERSECTION: Only supports set type
    • APPEND/ELIMINATE: Only supports collection type
    • OVERRIDE
  • check_vertex: Whether to check the existence of vertices (true | false). When set to true, an error will be thrown if the source or target vertices of the edge to be inserted do not exist. Default is true.
  • create_if_not_exist: Currently only supports setting to true
Method & Url
1PUT http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/batch
Request Body
 1{
 2    "edges": [
 3        {
 4            "label": "knows",
 5            "outV": "1:marko",
 6            "inV": "1:vadas",
 7            "outVLabel": "person",
 8            "inVLabel": "person",
 9            "properties": {
10                "date": "20160111",
11                "weight": 1.0
12            }
13        },
14        {
15            "label": "knows",
16            "outV": "1:marko",
17            "inV": "1:josh",
18            "outVLabel": "person",
19            "inVLabel": "person",
20            "properties": {
21                "date": "20130221",
22                "weight": 0.5
23            }
24        }
25    ],
26    "update_strategies": {
27        "weight": "SUM",
28        "date": "OVERRIDE"
29    },
30    "check_vertex": false,
31    "create_if_not_exist": true
32}
Response Status
1200
Response Body
 1{
 2    "edges": [
 3        {
 4            "id": "S1:marko>1>>S1:vadas",
 5            "label": "knows",
 6            "type": "edge",
 7            "outV": "1:marko",
 8            "outVLabel": "person",
 9            "inV": "1:vadas",
10            "inVLabel": "person",
11            "properties": {
12                "weight": 1.5,
13                "date": "20160111"
14            }
15        },
16        {
17            "id": "S1:marko>1>>S1:josh",
18            "label": "knows",
19            "type": "edge",
20            "outV": "1:marko",
21            "outVLabel": "person",
22            "inV": "1:josh",
23            "inVLabel": "person",
24            "properties": {
25                "weight": 1.5,
26                "date": "20130221"
27            }
28        }
29    ]
30}

2.2.5 Deleting Edge Properties

Params

Path Parameter Description:

  • graph: The graph to operate on
  • id: The ID of the edge to be operated on

Request Parameter Description:

  • action: The eliminate action

Request Body Description:

  • Edge information
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop?action=eliminate
Request Body
1{
2    "properties": {
3        "weight": 1.0
4    }
5}

NOTE: This will directly delete the properties (removing the key and all values), regardless of whether the property values are single, set, or list.

Response Status
1400
Response Body

It is not possible to delete an attribute that is not set as nullable.

1{
2    "exception": "class java.lang.IllegalArgumentException",
3    "message": "Can't remove non-null edge property 'p[weight->1.0]'",
4    "cause": ""
5}

2.2.6 Fetching Edges that Match the Criteria

Params

Path Parameter:

  • graph: The graph to operate on

Request Parameters:

  • vertex_id: Vertex ID
  • direction: Edge direction (OUT | IN | BOTH), default is BOTH
  • label: Edge label
  • properties: Key-value pairs of properties (requires pre-built indexes for property queries)
  • keep_start_p: Default is false. When set to true, the range matching input expression will not be automatically escaped. For example, properties={"age":"P.gt(0.8)"} will be interpreted as an exact match, i.e., the age property is equal to “P.gt(0.8)”
  • offset: Offset, default is 0
  • limit: Number of queries, default is 100
  • page: Page number

Key-value pairs of properties consist of the property name and value in JSON format. Multiple key-value pairs are allowed as query conditions. Property values support exact matching and range matching. For exact matching, it is in the form properties={"weight":0.8}. For range matching, it is in the form properties={"age":"P.gt(0.8)"}. The expressions supported by range matching are as follows:

ExpressionDescription
P.eq(number)Edges with property value equal to number
P.neq(number)Edges with property value not equal to number
P.lt(number)Edges with property value less than number
P.lte(number)Edges with property value less than or equal to number
P.gt(number)Edges with property value greater than number
P.gte(number)Edges with property value greater than or equal to number
P.between(number1,number2)Edges with property value greater than or equal to number1 and less than number2
P.inside(number1,number2)Edges with property value greater than number1 and less than number2
P.outside(number1,number2)Edges with property value less than number1 and greater than number2
P.within(value1,value2,value3,…)Edges with property value equal to any of the given values
P.textcontains(value)Edges with property value containing the given value (string type)
P.contains(value)Edges with property value containing the given value (collection type)

Edges connected to the vertex person:marko(vertex_id=“1:marko”) with label knows and date property equal to “20160111”

Method & Url
1GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?vertex_id="1:marko"&label=knows&properties={"date":"P.within(\"20160111\")"}
Response Status
1200
Response Body
 1{
 2    "edges": [
 3        {
 4            "id": "S1:marko>1>>S1:vadas",
 5            "label": "knows",
 6            "type": "edge",
 7            "outV": "1:marko",
 8            "outVLabel": "person",
 9            "inV": "1:vadas",
10            "inVLabel": "person",
11            "properties": {
12                "weight": 1.5,
13                "date": "20160111"
14            }
15        }
16    ]
17}

Paginate and retrieve all edges, get the first page (page without parameter value), limit to 2 entries

Method & Url
1GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?page&limit=2
Response Status
1200
Response Body
 1{
 2    "edges": [
 3        {
 4            "id": "S1:marko>1>>S1:josh",
 5            "label": "knows",
 6            "type": "edge",
 7            "outV": "1:marko",
 8            "outVLabel": "person",
 9            "inV": "1:josh",
10            "inVLabel": "person",
11            "properties": {
12                "weight": 1.5,
13                "date": "20130221"
14            }
15        },
16        {
17            "id": "S1:marko>1>>S1:vadas",
18            "label": "knows",
19            "type": "edge",
20            "outV": "1:marko",
21            "outVLabel": "person",
22            "inV": "1:vadas",
23            "inVLabel": "person",
24            "properties": {
25                "weight": 1.5,
26                "date": "20160111"
27            }
28        }
29    ],
30    "page": "EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC"
31}

The returned body contains the page number information for the next page, "page": "EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC". When querying the next page, assign this value to the page parameter.

Paginate and retrieve all edges, get the next page (include the page value returned from the previous page), limit to 2 entries

Method & Url
1GET http://127.0.0.1:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges?page=EoYxOm1hcmtvgggCAIQyOmxvcAAAAAAAAAAC&limit=2
Response Status
1200
Response Body
 1{
 2    "edges": [
 3        {
 4            "id": "S1:marko>2>>S2:lop",
 5            "label": "created",
 6            "type": "edge",
 7            "outV": "1:marko",
 8            "outVLabel": "person",
 9            "inV": "2:lop",
10            "inVLabel": "software",
11            "properties": {
12                "weight": 1.0,
13                "date": "20171210"
14            }
15        }
16    ],
17    "page": null
18}

When "page": null is returned, it indicates that there are no more pages available.

NOTE: When the backend is Cassandra, for performance considerations, if the returned page happens to be the last page, the page value may not be empty. When requesting the next page data using that page value, it will return empty data and page = null. Similar situations apply for other cases.

2.2.7 Fetching Edge by ID

Params

Path parameter description:

  • graph: The graph to be operated on.
  • id: The ID of the edge to be operated on.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop
Response Status
1200
Response Body
 1{
 2    "id": "S1:marko>2>>S2:lop",
 3    "label": "created",
 4    "type": "edge",
 5    "outV": "1:marko",
 6    "outVLabel": "person",
 7    "inV": "2:lop",
 8    "inVLabel": "software",
 9    "properties": {
10        "weight": 1.0,
11        "date": "20171210"
12    }
13}

2.2.8 Deleting Edge by ID

Params

Path parameter description:

  • graph: The graph to be operated on.
  • id: The ID of the edge to be operated on.

Request parameter description:

  • label: The label of the edge.

Deleting Edge by ID only

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>2>>S2:lop
Response Status
1204

Deleting Edge by Label + ID

In general, specifying the Label parameter along with the ID to delete an edge will provide better performance compared to deleting by ID only.

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges/S1:marko>1>>S1:vadas?label=knows
Response Status
1204

10 - Traverser API

Traverser REST API: Execute complex graph algorithms and path queries including shortest path, k-neighbors, similarity computation, and advanced analytics.

3.1 Overview of Traverser API

HugeGraphServer provides a RESTful API interface for the HugeGraph graph database. In addition to the basic CRUD operations for vertices and edges, it also offers several traversal methods, which we refer to as the traverser API. These traversal methods implement various complex graph algorithms, making it convenient for users to analyze and explore the graph.

The Traverser API supported by HugeGraph includes:

  • K-out API: It finds neighbors that are exactly N steps away from a given starting vertex. There are two versions:
    • The basic version uses the GET method to find neighbors that are exactly N steps away from a given starting vertex.
    • The advanced version uses the POST method to find neighbors that are exactly N steps away from a given starting vertex. The advanced version differs from the basic version in the following ways:
      • Supports counting the number of neighbors only
      • Supports filtering by edge and vertex properties
      • Supports returning the shortest path to reach the neighbor
  • K-neighbor API: It finds all neighbors that are within N steps of a given starting vertex. There are two versions:
    • The basic version uses the GET method to find all neighbors that are within N steps of a given starting vertex.
    • The advanced version uses the POST method to find all neighbors that are within N steps of a given starting vertex. The advanced version differs from the basic version in the following ways:
      • Supports counting the number of neighbors only
      • Supports filtering by edge and vertex properties
      • Supports returning the shortest path to reach the neighbor
  • Same Neighbors: It queries the common neighbors of two vertices.
  • Jaccard Similarity API: It calculates the Jaccard similarity, which includes two types:
    • One type uses the GET method to calculate the similarity (intersection over union) of neighbors between two vertices.
    • The other type uses the POST method to find the top N vertices with the highest Jaccard similarity to a given starting vertex in the entire graph.
  • Shortest Path API: It finds the shortest path between two vertices.
  • All Shortest Paths: It finds all shortest paths between two vertices.
  • Weighted Shortest Path: It finds the shortest weighted path from a starting vertex to a target vertex.
  • Single Source Shortest Path: It finds the weighted shortest path from a single source vertex to all other vertices.
  • Multi Node Shortest Path: It finds the shortest path between every pair of specified vertices.
  • Paths API: It finds all paths between two vertices. There are two versions:
    • The basic version uses the GET method to find all paths between a given starting vertex and an ending vertex.
    • The advanced version uses the POST method to find all paths that meet certain conditions between a set of starting vertices and a set of ending vertices.
  • Customized Paths API: It traverses all paths that pass through a batch of vertices according to a specific pattern.
  • Template Path API: It specifies a starting point, an ending point, and the path information between them to find matching paths.
  • Crosspoints API: It finds the intersection (common ancestors or common descendants) between two vertices.
  • Customized Crosspoints API: It traverses multiple patterns starting from a batch of vertices and finds the intersections with the vertices reached in the final step.
  • Rings API: It finds the cyclic paths that can be reached from a starting vertex.
  • Rays API: It finds the paths from a starting vertex that reach the boundaries (i.e., paths without cycles).
  • Fusiform Similarity API: It finds the fusiform similar vertices to a given vertex.
  • Adamic-Adar API: It computes the Adamic-Adar index of two vertices.
  • Resource Allocation API: It computes the resource allocation index of two vertices.
  • Edge Existence API: It returns the edges that exist between two given vertices.
  • Count API: It counts the vertices reached after a series of traversal steps, without returning them.
  • Vertices API:
    • Batch querying vertices by ID.
    • Getting the partitions of vertices.
    • Querying vertices by partition.
  • Edges API:
    • Batch querying edges by ID.
    • Getting the partitions of edges.
    • Querying edges by partition.

3.2 Detailed Explanation of Traverser API

The usage examples provided in this section are based on the graph presented on the TinkerPop official website:

TinkerPop example graph

The data import program is as follows:

  1public class Loader {
  2    public static void main(String[] args) {
  3        HugeClient client = new HugeClient("http://127.0.0.1:8080", "hugegraph");
  4        SchemaManager schema = client.schema();
  5        schema.propertyKey("name").asText().ifNotExist().create();
  6        schema.propertyKey("age").asInt().ifNotExist().create();
  7        schema.propertyKey("city").asText().ifNotExist().create();
  8        schema.propertyKey("weight").asDouble().ifNotExist().create();
  9        schema.propertyKey("lang").asText().ifNotExist().create();
 10        schema.propertyKey("date").asText().ifNotExist().create();
 11        schema.propertyKey("price").asInt().ifNotExist().create();
 12
 13        schema.vertexLabel("person")
 14              .properties("name", "age", "city")
 15              .primaryKeys("name")
 16              .nullableKeys("age")
 17              .ifNotExist()
 18              .create();
 19
 20        schema.vertexLabel("software")
 21              .properties("name", "lang", "price")
 22              .primaryKeys("name")
 23              .nullableKeys("price")
 24              .ifNotExist()
 25              .create();
 26
 27        schema.indexLabel("personByCity")
 28              .onV("person")
 29              .by("city")
 30              .secondary()
 31              .ifNotExist()
 32              .create();
 33
 34        schema.indexLabel("personByAgeAndCity")
 35              .onV("person")
 36              .by("age", "city")
 37              .secondary()
 38              .ifNotExist()
 39              .create();
 40
 41        schema.indexLabel("softwareByPrice")
 42              .onV("software")
 43              .by("price")
 44              .range()
 45              .ifNotExist()
 46              .create();
 47
 48        schema.edgeLabel("knows")
 49              .multiTimes()
 50              .sourceLabel("person")
 51              .targetLabel("person")
 52              .properties("date", "weight")
 53              .sortKeys("date")
 54              .nullableKeys("weight")
 55              .ifNotExist()
 56              .create();
 57
 58        schema.edgeLabel("created")
 59              .sourceLabel("person").targetLabel("software")
 60              .properties("date", "weight")
 61              .nullableKeys("weight")
 62              .ifNotExist()
 63              .create();
 64
 65        schema.indexLabel("createdByDate")
 66              .onE("created")
 67              .by("date")
 68              .secondary()
 69              .ifNotExist()
 70              .create();
 71
 72        schema.indexLabel("createdByWeight")
 73              .onE("created")
 74              .by("weight")
 75              .range()
 76              .ifNotExist()
 77              .create();
 78
 79        schema.indexLabel("knowsByWeight")
 80              .onE("knows")
 81              .by("weight")
 82              .range()
 83              .ifNotExist()
 84              .create();
 85
 86        GraphManager graph = client.graph();
 87        Vertex marko = graph.addVertex(T.label, "person", "name", "marko",
 88                                       "age", 29, "city", "Beijing");
 89        Vertex vadas = graph.addVertex(T.label, "person", "name", "vadas",
 90                                       "age", 27, "city", "Hongkong");
 91        Vertex lop = graph.addVertex(T.label, "software", "name", "lop",
 92                                     "lang", "java", "price", 328);
 93        Vertex josh = graph.addVertex(T.label, "person", "name", "josh",
 94                                      "age", 32, "city", "Beijing");
 95        Vertex ripple = graph.addVertex(T.label, "software", "name", "ripple",
 96                                        "lang", "java", "price", 199);
 97        Vertex peter = graph.addVertex(T.label, "person", "name", "peter",
 98                                       "age", 35, "city", "Shanghai");
 99
100        marko.addEdge("knows", vadas, "date", "20160110", "weight", 0.5);
101        marko.addEdge("knows", josh, "date", "20130220", "weight", 1.0);
102        marko.addEdge("created", lop, "date", "20171210", "weight", 0.4);
103        josh.addEdge("created", lop, "date", "20091111", "weight", 0.4);
104        josh.addEdge("created", ripple, "date", "20171210", "weight", 1.0);
105        peter.addEdge("created", lop, "date", "20170324", "weight", 0.2);
106    }
107}

The vertex IDs are:

1"2:ripple",
2"1:vadas",
3"1:peter",
4"1:josh",
5"1:marko",
6"2:lop"

The edge IDs are:

1"S1:peter>2>>S2:lop",
2"S1:josh>2>>S2:lop",
3"S1:josh>2>>S2:ripple",
4"S1:marko>1>20130220>S1:josh",
5"S1:marko>1>20160110>S1:vadas",
6"S1:marko>2>>S2:lop"

3.2.1 K-out API (GET, Basic Version)

3.2.1.1 Functionality Overview

The K-out API allows you to find vertices that are exactly “depth” steps away from a given starting vertex, considering the specified direction, edge type (optional), and depth.

Params
  • source: ID of the starting vertex (required)
  • direction: Direction of traversal from the starting vertex (OUT, IN, BOTH). Optional, default is BOTH.
  • max_depth: Number of steps (required)
  • label: Edge type (optional), represents all edge labels by default
  • nearest: When nearest is set to true, it means the shortest path length from the starting vertex to the result vertices is equal to the depth, and there is no shorter path. When nearest is set to false, it means there is at least one path of length depth from the starting vertex to the result vertices (not necessarily the shortest and may contain cycles). Optional, default is true.
  • max_degree: Maximum number of adjacent edges to traverse per vertex during the query. Optional, default is 10000.
  • capacity: Maximum number of vertices to be visited during the traversal. Optional, default is 10000000.
  • limit: Maximum number of vertices to be returned. Optional, default is 10000000.
3.2.1.2 Usage Example
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kout?source="1:marko"&max_depth=2
Response Status
1200
Response Body
1{
2    "vertices":[
3        "2:ripple",
4        "1:peter"
5    ]
6}
3.2.1.3 Use Cases

Finding vertices that are exactly N steps away in a relationship. Two examples:

  • In a family relationship, finding all grandchildren of a person. The set of vertices that can be reached by person A through two consecutive “son” edges.
  • Discovering potential friends in a social network. For example, finding users who are two degrees of friendship away from the target user, reachable through two consecutive “friend” edges.

3.2.2 K-out API (POST, Advanced Version)

3.2.2.1 Functionality Overview

The K-out API allows you to find vertices that are exactly “depth” steps away from a given starting vertex, considering the specified steps (including direction, edge type, and attribute filtering).

The advanced version differs from the basic version of K-out API in the following aspects:

  • Supports counting the number of neighbors only
  • Supports edge attribute filtering
  • Supports returning the shortest path to the neighbor
Params
  • source: The ID of the starting vertex, required.
  • steps: Steps from the starting point, required, with the following structure:
    • direction: Represents the direction of the edges (OUT, IN, BOTH), default is BOTH.
    • edge_steps: The step set of edges, supporting label and properties filtering for the edge. If edge_steps is empty, the edge is not filtered.
      • label: Edge types.
      • properties: Filter edges based on property values.
    • vertex_steps: The step set of vertices, supporting label and properties filtering for the vertex. If vertex_steps is empty, the vertex is not filtered.
      • label: Vertex types.
      • properties: Filter vertices based on property values.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: Sets the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional. If enabled, it should satisfy the constraint skip_degree >= max_degree. Default is 0 (not enabled), indicating no skipping of any vertices (Note: Enabling this configuration means that during traversal, an attempt will be made to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it only after understanding the implications).
  • max_depth: Number of steps, required.
  • nearest: When nearest is true, it means the shortest path length from the starting vertex to the result vertex is equal to depth, and there is no shorter path. When nearest is false, it means there is a path of length depth from the starting vertex to the result vertex (not necessarily the shortest and can contain cycles). Optional, default is true.
  • count_only: Boolean value, true indicates only counting the number of results without returning specific results, false indicates returning specific results. Default is false.
  • with_path: When true, it returns the shortest path from the starting vertex to each neighbor. When false, it does not return the shortest path. Optional, default is false.
  • with_edge: Optional parameter, default is false:
    • When true, the result will include complete edge information (all edges in the path):
      • When with_path is true, it returns complete information of all edges in all paths.
      • When with_path is false, no information is returned.
    • When false, it only returns edge IDs.
  • with_vertex: Optional parameter, default is false:
    • When true, the result will include complete vertex information (all vertices in the path):
      • When with_path is true, it returns complete information of all vertices in all paths.
      • When with_path is false, it returns complete information of all neighbors.
    • When false, it only returns vertex IDs.
  • capacity: Maximum number of vertices to visit during traversal. Optional, default is 10000000.
  • limit: Maximum number of vertices to return. Optional, default is 10000000.
  • traverse_mode: Traversal mode. There are two options: “breadth_first_search” and “depth_first_search”, default is “breadth_first_search”.
3.2.2.2 Usage
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kout
Request Body
 1{
 2    "source": "1:marko",
 3    "steps": {
 4        "direction": "BOTH",
 5        "edge_steps": [
 6            {
 7                "label": "knows",
 8                "properties": {
 9                    "weight": "P.gt(0.1)"
10                }
11            },
12            {
13                "label": "created",
14                "properties": {
15                    "weight": "P.gt(0.1)"
16                }
17            }
18        ],
19        "vertex_steps": [
20            {
21                "label": "person",
22                "properties": {
23                    "age": "P.lt(32)"
24                }
25            },
26            {
27                "label": "software",
28                "properties": {}
29            }
30        ],
31        "max_degree": 10000,
32        "skip_degree": 100000
33    },
34    "max_depth": 1,
35    "nearest": true,
36    "limit": 10000,
37    "with_vertex": true,
38    "with_path": true,
39    "with_edge": true
40}
Response Status
1200
Response Body
 1{
 2    "size": 2,
 3    "kout": [
 4        "1:vadas",
 5        "2:lop"
 6    ],
 7    "paths": [
 8        {
 9            "objects": [
10                "1:marko",
11                "2:lop"
12            ]
13        },
14        {
15            "objects": [
16                "1:marko",
17                "1:vadas"
18            ]
19        }
20    ],
21    "vertices": [
22        {
23            "id": "1:marko",
24            "label": "person",
25            "type": "vertex",
26            "properties": {
27                "name": "marko",
28                "age": 29,
29                "city": "Beijing"
30            }
31        },
32        {
33            "id": "1:vadas",
34            "label": "person",
35            "type": "vertex",
36            "properties": {
37                "name": "vadas",
38                "age": 27,
39                "city": "Hongkong"
40            }
41        },
42        {
43            "id": "2:lop",
44            "label": "software",
45            "type": "vertex",
46            "properties": {
47                "name": "lop",
48                "lang": "java",
49                "price": 328
50            }
51        }
52    ],
53    "edges": [
54        {
55            "id": "S1:marko>1>20160110>S1:vadas",
56            "label": "knows",
57            "type": "edge",
58            "outV": "1:marko",
59            "outVLabel": "person",
60            "inV": "1:vadas",
61            "inVLabel": "person",
62            "properties": {
63                "weight": 0.5,
64                "date": "20160110"
65            }
66        },
67        {
68            "id": "S1:marko>2>>S2:lop",
69            "label": "created",
70            "type": "edge",
71            "outV": "1:marko",
72            "outVLabel": "person",
73            "inV": "2:lop",
74            "inVLabel": "software",
75            "properties": {
76                "weight": 0.4,
77                "date": "20171210"
78            }
79        }
80    ]
81}
3.2.2.3 Use Cases

Refer to 3.2.1.3.

3.2.3 K-neighbor (GET, Basic Version)

3.2.3.1 Function Introduction

Find all vertices that are reachable within depth steps, including the starting vertex, based on the starting vertex, direction, edge type (optional), and depth.

Equivalent to the union of: starting vertex, K-out(1), K-out(2), …, K-out(max_depth).

Params
  • source: ID of the starting vertex, required.
  • direction: Direction in which the starting vertex’s edges extend (OUT, IN, BOTH). Optional, default is BOTH.
  • max_depth: Number of steps, required.
  • label: Edge type, optional, default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for a single vertex during the query process. Optional, default is 10000.
  • limit: Maximum number of vertices to return, also represents the maximum number of vertices to visit during traversal. Optional, default is 10000000.
3.2.3.2 Usage
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kneighbor?source=%221:marko%22&max_depth=2
Response Status
1200
Response Body
 1{
 2    "vertices":[
 3        "2:ripple",
 4        "1:marko",
 5        "1:josh",
 6        "1:vadas",
 7        "1:peter",
 8        "2:lop"
 9    ]
10}
3.2.3.3 Use Cases

Find all vertices reachable within N steps, for example:

  • In a family relationship, find all descendants within five generations of a person. This can be achieved by traversing five consecutive “parent-child” edges from person A.
  • In a social network, discover friend circles. For example, users who can be reached by 1, 2, or 3 “friend” edges from the target user can form the target user’s friend circle.

3.2.4 K-neighbor API (POST, Advanced Version)

3.2.4.1 Function Introduction

Find all vertices that are reachable within depth steps from the starting vertex, based on the starting vertex, steps (including direction, edge type, and filter properties), and depth.

The difference from the Basic Version of K-neighbor API is that:

  • It supports counting the number of neighbors only.
  • It supports filtering edges based on their properties.
  • It supports returning the shortest path to reach the neighbors.
Params
  • source: Starting vertex ID, required.
  • steps: Steps from the starting point, required, with the following structure:
    • direction: Represents the direction of the edges (OUT, IN, BOTH), default is BOTH.
    • edge_steps: The step set of edges, supporting label and properties filtering for the edge. If edge_steps is empty, the edge is not filtered.
      • label: Edge types.
      • properties: Filter edges based on property values.
    • vertex_steps: The step set of vertices, supporting label and properties filtering for the vertex. If vertex_steps is empty, the vertex is not filtered.
      • label: Vertex types.
      • properties: Filter vertices based on property values.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: Used to set the minimum number of edges to discard super vertices during the query process. When the number of adjacent edges for a vertex exceeds skip_degree, the vertex is completely discarded. This is an optional parameter. If enabled, it should satisfy the constraint skip_degree >= max_degree. Default is 0 (not enabled), which means no vertices are skipped. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges for each vertex, not just max_degree edges. This incurs additional traversal overhead and may significantly impact query performance. Please make sure to understand this before enabling.)
  • max_depth: Number of steps, required.
  • count_only: Boolean value. If true, only the count of results is returned without the actual results. If false, the specific results are returned. Default is false.
  • with_path: If true, the shortest path from the starting point to each neighbor is returned. If false, the shortest path from the starting point to each neighbor is not returned. This is an optional parameter. Default is false.
  • with_edge: Optional parameter, default is false:
    • When true, the result will include complete edge information (all edges in the path):
      • When with_path is true, it returns complete information of all edges in all paths.
      • When with_path is false, no information is returned.
    • When false, it only returns edge IDs.
  • with_vertex: Optional parameter, default is false:
    • When true, the result will include complete vertex information (all vertices in the path):
      • When with_path is true, it returns complete information of all vertices in all paths.
      • When with_path is false, it returns complete information of all neighbors.
    • When false, it only returns vertex IDs.
  • limit: Maximum number of vertices to be returned. Also, the maximum number of vertices visited during the traversal process. This is an optional parameter. Default is 10000000.
3.2.4.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/kneighbor
Request Body
 1{
 2    "source": "1:marko",
 3    "steps": {
 4        "direction": "BOTH",
 5        "edge_steps": [
 6            {
 7                "label": "knows",
 8                "properties": {
 9                    "weight": "P.gt(0.1)"
10                }
11            },
12            {
13                "label": "created",
14                "properties": {
15                    "weight": "P.gt(0.1)"
16                }
17            }
18        ],
19        "vertex_steps": [
20            {
21                "label": "person",
22                "properties": {
23                    "age": "P.lt(32)"
24                }
25            },
26            {
27                "label": "software",
28                "properties": {}
29            }
30        ],
31        "max_degree": 10000,
32        "skip_degree": 100000
33    },
34    "max_depth": 1,
35    "nearest": true,
36    "limit": 10000,
37    "with_vertex": true,
38    "with_path": true,
39    "with_edge": true
40}
Response Status
1200
Response Body
  1{
  2    "size": 4,
  3    "kneighbor": [
  4        "1:josh",
  5        "2:lop",
  6        "1:peter",
  7        "2:ripple"
  8    ],
  9    "paths": [
 10        {
 11            "objects": [
 12                "1:marko",
 13                "2:lop"
 14            ]
 15        },
 16        {
 17            "objects": [
 18                "1:marko",
 19                "2:lop",
 20                "1:peter"
 21            ]
 22        },
 23        {
 24            "objects": [
 25                "1:marko",
 26                "1:josh"
 27            ]
 28        },
 29        {
 30            "objects": [
 31                "1:marko",
 32                "1:josh",
 33                "2:ripple"
 34            ]
 35        }
 36    ],
 37    "vertices": [
 38        {
 39            "id": "2:ripple",
 40            "label": "software",
 41            "type": "vertex",
 42            "properties": {
 43                "name": "ripple",
 44                "lang": "java",
 45                "price": 199
 46            }
 47        },
 48        {
 49            "id": "1:marko",
 50            "label": "person",
 51            "type": "vertex",
 52            "properties": {
 53                "name": "marko",
 54                "age": 29,
 55                "city": "Beijing"
 56            }
 57        },
 58        {
 59            "id": "1:josh",
 60            "label": "person",
 61            "type": "vertex",
 62            "properties": {
 63                "name": "josh",
 64                "age": 32,
 65                "city": "Beijing"
 66            }
 67        },
 68        {
 69            "id": "1:peter",
 70            "label": "person",
 71            "type": "vertex",
 72            "properties": {
 73                "name": "peter",
 74                "age": 35,
 75                "city": "Shanghai"
 76            }
 77        },
 78        {
 79            "id": "2:lop",
 80            "label": "software",
 81            "type": "vertex",
 82            "properties": {
 83                "name": "lop",
 84                "lang": "java",
 85                "price": 328
 86            }
 87        }
 88    ],
 89    "edges": [
 90        {
 91            "id": "S1:josh>2>>S2:ripple",
 92            "label": "created",
 93            "type": "edge",
 94            "outV": "1:josh",
 95            "outVLabel": "person",
 96            "inV": "2:ripple",
 97            "inVLabel": "software",
 98            "properties": {
 99                "weight": 1.0,
100                "date": "20171210"
101            }
102        },
103        {
104            "id": "S1:marko>2>>S2:lop",
105            "label": "created",
106            "type": "edge",
107            "outV": "1:marko",
108            "outVLabel": "person",
109            "inV": "2:lop",
110            "inVLabel": "software",
111            "properties": {
112                "weight": 0.4,
113                "date": "20171210"
114            }
115        },
116        {
117            "id": "S1:marko>1>20130220>S1:josh",
118            "label": "knows",
119            "type": "edge",
120            "outV": "1:marko",
121            "outVLabel": "person",
122            "inV": "1:josh",
123            "inVLabel": "person",
124            "properties": {
125                "weight": 1.0,
126                "date": "20130220"
127            }
128        },
129        {
130            "id": "S1:peter>2>>S2:lop",
131            "label": "created",
132            "type": "edge",
133            "outV": "1:peter",
134            "outVLabel": "person",
135            "inV": "2:lop",
136            "inVLabel": "software",
137            "properties": {
138                "weight": 0.2,
139                "date": "20170324"
140            }
141        }
142    ]
143}
3.2.4.3 Use Cases

See 3.2.3.3

3.2.5 Same Neighbors

3.2.5.1 Function Introduction

Retrieve the common neighbors of two vertices.

Params
  • vertex: ID of one vertex, required.
  • other: ID of another vertex, required.
  • direction: Direction in which the vertex expands outward (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type. Optional, default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • limit: Maximum number of common neighbors to be returned. Optional, default is 10000000.
3.2.5.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/sameneighbors?vertex=%221:marko%22&other=%221:josh%22
Response Status
1200
Response Body
1{
2    "same_neighbors":[
3        "2:lop"
4    ]
5}
3.2.5.3 Use Cases

Find the common neighbors of two vertices:

  • In a social network, find the common followers or users both users are following.

3.2.6 Jaccard Similarity (GET)

3.2.6.1 Function Introduction

Compute the Jaccard similarity between two vertices (the intersection of the neighbors of the two vertices divided by the union of the neighbors of the two vertices).

For neighbor sets N(u) and N(v) with a nonempty union, the definition above is:

J(u,v)=∣N(u)∩N(v)∣∣N(u)∪N(v)∣J(u,v) = \frac{|N(u) \cap N(v)|}{|N(u) \cup N(v)|}
Params
  • vertex: ID of one vertex, required.
  • other: ID of another vertex, required.
  • direction: Direction in which the vertex expands outward (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type. Optional, default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
3.2.6.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/jaccardsimilarity?vertex="1:marko"&other="1:josh"
Response Status
1200
Response Body
1{
2    "jaccard_similarity": 0.2
3}
3.2.6.3 Use Cases

Used to evaluate the similarity or closeness between two vertices.

3.2.7 Jaccard Similarity (POST)

3.2.7.1 Function Introduction

Compute the N vertices with the highest Jaccard similarity to a specified vertex.

The Jaccard similarity is calculated as the intersection of the neighbors of the two vertices divided by the union of the neighbors of the two vertices.

Params
  • vertex: ID of a vertex, required.
  • Steps from the starting point, required. The structure is as follows:
    • direction: Direction of the edges (OUT, IN, BOTH). Optional, default is BOTH.
    • labels: List of edge types.
    • properties: Filter edges based on property values.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: Used to set the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional, default is 0 (not enabled), which means no skipping. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it after understanding and confirming.)
  • top: Return the top N vertices with the highest Jaccard similarity for a starting vertex. Optional, default is 100.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
3.2.7.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/jaccardsimilarity
Request Body
 1{
 2  "vertex": "1:marko",
 3  "step": {
 4    "direction": "BOTH",
 5    "labels": [],
 6    "max_degree": 10000,
 7    "skip_degree": 100000
 8  },
 9  "top": 3
10}
Response Status
1200
Response Body
1{
2    "2:ripple": 0.3333333333333333,
3    "1:peter": 0.3333333333333333,
4    "1:josh": 0.2
5}
3.2.7.3 Use Cases

Used to find the vertices in the graph that have the highest similarity to a specified vertex.

3.2.8 Shortest Path

3.2.8.1 Function Introduction

Find the shortest path between a starting vertex and a target vertex based on the direction, edge type (optional), and maximum depth.

Params
  • source: ID of the starting vertex, required.
  • target: ID of the target vertex, required.
  • direction: Direction in which the starting vertex expands (OUT, IN, BOTH). Optional, default is BOTH.
  • max_depth: Maximum number of steps, required.
  • label: Edge type, optional. Default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • skip_degree: Used to set the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional, default is 0 (not enabled), which means no skipping. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it after understanding and confirming.)
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
3.2.8.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/shortestpath?source="1:marko"&target="2:ripple"&max_depth=3
Response Status
1200
Response Body
1{
2    "path":[
3        "1:marko",
4        "1:josh",
5        "2:ripple"
6    ]
7}
3.2.8.3 Use Cases

Used to find the shortest path between two vertices, for example:

  • In a social network, finding the shortest path between two users, representing the closest friend relationship chain.
  • In a device association network, finding the shortest association relationship between two devices.

3.2.9 All Shortest Paths

3.2.9.1 Function Introduction

Find all shortest paths between a starting vertex and a target vertex based on the direction, edge type (optional), and maximum depth.

Params
  • source: ID of the starting vertex, required.
  • target: ID of the target vertex, required.
  • direction: Direction in which the starting vertex expands (OUT, IN, BOTH). Optional, default is BOTH.
  • max_depth: Maximum number of steps, required.
  • label: Edge type, optional. Default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • skip_degree: Used to set the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional, default is 0 (not enabled), which means no skipping. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it after understanding and confirming.)
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
3.2.9.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/allshortestpaths?source="A"&target="Z"&max_depth=10
Response Status
1200
Response Body
 1{
 2    "paths":[
 3        {
 4            "objects": [
 5                "A",
 6                "B",
 7                "C",
 8                "Z"
 9            ]
10        },
11        {
12            "objects": [
13                "A",
14                "M",
15                "N",
16                "Z"
17            ]
18        }
19    ]
20}
3.2.9.3 Use Cases

Used to find all shortest paths between two vertices, for example:

  • In a social network, finding all shortest paths between two users, representing all the closest friend relationship chains.
  • In a device association network, finding all shortest association relationships between two devices.

3.2.10 Weighted Shortest Path

3.2.10.1 Function Introduction

Find a weighted shortest path between a starting vertex and a target vertex based on the direction, edge type (optional), maximum depth, and edge weight property.

Params
  • source: ID of the starting vertex, required.
  • target: ID of the target vertex, required.
  • direction: Direction in which the starting vertex expands (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type, optional. Default represents all edge labels.
  • weight: Edge weight property, required. It must be a numeric property.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • skip_degree: Used to set the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional, default is 0 (not enabled), which means no skipping. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it after understanding and confirming.)
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • with_vertex: true to include complete vertex information (all vertices in the path) in the result, false to only return vertex IDs. Optional, default is false.
3.2.10.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/weightedshortestpath?source="1:marko"&target="2:ripple"&weight="weight"&with_vertex=true
Response Status
1200
Response Body
 1{
 2    "path": {
 3        "weight": 2.0,
 4        "vertices": [
 5            "1:marko",
 6            "1:josh",
 7            "2:ripple"
 8        ]
 9    },
10    "vertices": [
11        {
12            "id": "1:marko",
13            "label": "person",
14            "type": "vertex",
15            "properties": {
16                "name": "marko",
17                "age": 29,
18                "city": "Beijing"
19            }
20        },
21        {
22            "id": "1:josh",
23            "label": "person",
24            "type": "vertex",
25            "properties": {
26                "name": "josh",
27                "age": 32,
28                "city": "Beijing"
29            }
30        },
31        {
32            "id": "2:ripple",
33            "label": "software",
34            "type": "vertex",
35            "properties": {
36                "name": "ripple",
37                "lang": "java",
38                "price": 199
39            }
40        }
41    ]
42}
3.2.10.3 Use Cases

Used to find the weighted shortest path between two vertices, for example:

  • In a transportation network, finding the transportation method that requires the least cost from city A to city B.

3.2.11 Single Source Shortest Path

3.2.11.1 Function Introduction

Starting from a vertex, find the shortest paths from that vertex to other vertices in the graph (optional with weight).

Params
  • source: ID of the starting vertex, required.
  • direction: Direction in which the starting vertex expands (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type, optional. Default represents all edge labels.
  • weight: Edge weight property, optional. It must be a numeric property. If not provided or the edges don’t have this property, the weight is considered as 1.0.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • skip_degree: Used to set the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional, default is 0 (not enabled), which means no skipping. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it after understanding and confirming.)
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • limit: Number of target vertices to be queried and the number of shortest paths to be returned. Optional, default is 10.
  • with_vertex: true to include complete vertex information (all vertices in the path) in the result, false to only return vertex IDs. Optional, default is false.
3.2.11.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/singlesourceshortestpath?source="1:marko"&with_vertex=true
Response Status
1200
Response Body
  1{
  2    "paths": {
  3        "2:ripple": {
  4            "weight": 2.0,
  5            "vertices": [
  6                "1:marko",
  7                "1:josh",
  8                "2:ripple"
  9            ]
 10        },
 11        "1:josh": {
 12            "weight": 1.0,
 13            "vertices": [
 14                "1:marko",
 15                "1:josh"
 16            ]
 17        },
 18        "1:vadas": {
 19            "weight": 1.0,
 20            "vertices": [
 21                "1:marko",
 22                "1:vadas"
 23            ]
 24        },
 25        "1:peter": {
 26            "weight": 2.0,
 27            "vertices": [
 28                "1:marko",
 29                "2:lop",
 30                "1:peter"
 31            ]
 32        },
 33        "2:lop": {
 34            "weight": 1.0,
 35            "vertices": [
 36                "1:marko",
 37                "2:lop"
 38            ]
 39        }
 40    },
 41    "vertices": [
 42        {
 43            "id": "2:ripple",
 44            "label": "software",
 45            "type": "vertex",
 46            "properties": {
 47                "name": "ripple",
 48                "lang": "java",
 49                "price": 199
 50            }
 51        },
 52        {
 53            "id": "1:marko",
 54            "label": "person",
 55            "type": "vertex",
 56            "properties": {
 57                "name": "marko",
 58                "age": 29,
 59                "city": "Beijing"
 60            }
 61        },
 62        {
 63            "id": "1:josh",
 64            "label": "person",
 65            "type": "vertex",
 66            "properties": {
 67                "name": "josh",
 68                "age": 32,
 69                "city": "Beijing"
 70            }
 71        },
 72        {
 73            "id": "1:vadas",
 74            "label": "person",
 75            "type": "vertex",
 76            "properties": {
 77                "name": "vadas",
 78                "age": 27,
 79                "city": "Hongkong"
 80            }
 81        },
 82        {
 83            "id": "1:peter",
 84            "label": "person",
 85            "type": "vertex",
 86            "properties": {
 87                "name": "peter",
 88                "age": 35,
 89                "city": "Shanghai"
 90            }
 91        },
 92        {
 93            "id": "2:lop",
 94            "label": "software",
 95            "type": "vertex",
 96            "properties": {
 97                "name": "lop",
 98                "lang": "java",
 99                "price": 328
100            }
101        }
102    ]
103}
3.2.11.3 Use Cases

Used to find the weighted shortest path from one vertex to other vertices, for example:

  • Finding the shortest travel time by bus from Beijing to all other cities in the country.

3.2.12 Multi Node Shortest Path

3.2.12.1 Function Introduction

Finds the shortest paths between pairs of specified vertices.

Params
  • vertices: Defines the starting vertices, required. It can be specified in the following ways:
    • ids: Provide a list of vertex IDs as starting vertices.
    • label and properties: If no IDs are specified, use the combined conditions of label and properties to query the starting vertices.
      • label: Vertex type.
      • properties: Query the starting vertices based on property values.

      Note: Property values in properties can be a list, indicating that the value of the key can be any value in the list.

  • step: Represents the path from the starting vertices to the destination vertices, required. The structure of the step is as follows:
    • direction: Represents the direction of the edges (OUT, IN, BOTH). Default is BOTH.
    • labels: List of edge types.
    • properties: Filters the edges based on property values.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: Used to set the minimum number of edges to skip super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely skipped. Optional, default is 0 (not enabled), which means no skipping. (Note: When this configuration is enabled, the traversal will attempt to access skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please enable it after understanding and confirming.)
  • max_depth: Number of steps, required.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • with_vertex: true to include complete vertex information (all vertices in the path) in the result, false to only return vertex IDs. Optional, default is false.
3.2.12.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/multinodeshortestpath
Request Body
 1{
 2    "vertices": {
 3        "ids": ["382:marko", "382:josh", "382:vadas", "382:peter", "383:lop", "383:ripple"]
 4    },
 5    "step": {
 6        "direction": "BOTH",
 7        "properties": {
 8        }
 9    },
10    "max_depth": 10,
11    "capacity": 100000000,
12    "with_vertex": true
13}
Response Status
1200
Response Body
  1{
  2    "paths": [
  3        {
  4            "objects": [
  5                "382:peter",
  6                "383:lop"
  7            ]
  8        },
  9        {
 10            "objects": [
 11                "382:peter",
 12                "383:lop",
 13                "382:marko"
 14            ]
 15        },
 16        {
 17            "objects": [
 18                "382:peter",
 19                "383:lop",
 20                "382:josh"
 21            ]
 22        },
 23        {
 24            "objects": [
 25                "382:peter",
 26                "383:lop",
 27                "382:marko",
 28                "382:vadas"
 29            ]
 30        },
 31        {
 32            "objects": [
 33                "383:lop",
 34                "382:marko"
 35            ]
 36        },
 37        {
 38            "objects": [
 39                "383:lop",
 40                "382:josh"
 41            ]
 42        },
 43        {
 44            "objects": [
 45                "383:lop",
 46                "382:marko",
 47                "382:vadas"
 48            ]
 49        },
 50        {
 51            "objects": [
 52                "382:peter",
 53                "383:lop",
 54                "382:josh",
 55                "383:ripple"
 56            ]
 57        },
 58        {
 59            "objects": [
 60                "382:marko",
 61                "382:josh"
 62            ]
 63        },
 64        {
 65            "objects": [
 66                "383:lop",
 67                "382:josh",
 68                "383:ripple"
 69            ]
 70        },
 71        {
 72            "objects": [
 73                "382:marko",
 74                "382:vadas"
 75            ]
 76        },
 77        {
 78            "objects": [
 79                "382:marko",
 80                "382:josh",
 81                "383:ripple"
 82            ]
 83        },
 84        {
 85            "objects": [
 86                "382:josh",
 87                "383:ripple"
 88            ]
 89        },
 90        {
 91            "objects": [
 92                "382:josh",
 93                "382:marko",
 94                "382:vadas"
 95            ]
 96        },
 97        {
 98            "objects": [
 99                "382:vadas",
100                "382:marko",
101                "382:josh",
102                "383:ripple"
103            ]
104        }
105    ],
106    "vertices": [
107        {
108            "id": "382:peter",
109            "label": "person",
110            "type": "vertex",
111            "properties": {
112                "name": "peter",
113                "age": 29,
114                "city": "Shanghai"
115            }
116        },
117        {
118            "id": "383:lop",
119            "label": "software",
120            "type": "vertex",
121            "properties": {
122                "name": "lop",
123                "lang": "java",
124                "price": 328
125            }
126        },
127        {
128            "id": "382:marko",
129            "label": "person",
130            "type": "vertex",
131            "properties": {
132                "name": "marko",
133                "age": 29,
134                "city": "Beijing"
135            }
136        },
137        {
138            "id": "382:josh",
139            "label": "person",
140            "type": "vertex",
141            "properties": {
142                "name": "josh",
143                "age": 32,
144                "city": "Beijing"
145            }
146        },
147        {
148            "id": "382:vadas",
149            "label": "person",
150            "type": "vertex",
151            "properties": {
152                "name": "vadas",
153                "age": 27,
154                "city": "Hongkong"
155            }
156        },
157        {
158            "id": "383:ripple",
159            "label": "software",
160            "type": "vertex",
161            "properties": {
162                "name": "ripple",
163                "lang": "java",
164                "price": 199
165            }
166        }
167    ]
168}
3.2.12.3 Use Cases

Used to find the shortest paths between multiple vertices, for example:

  • Finding the shortest paths between multiple companies and their legal representatives.

3.2.13 Paths (GET, Basic Version)

3.2.13.1 Function Introduction

Finds all paths based on conditions such as the starting vertex, destination vertex, direction, edge types (optional), and maximum depth.

Params
  • source: ID of the starting vertex, required.
  • target: ID of the destination vertex, required.
  • direction: Direction in which the starting vertex expands (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type. Optional, default represents all edge labels.
  • max_depth: Number of steps, required.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • limit: Maximum number of paths to be returned. Optional, default is 10.
3.2.13.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/paths?source="1:marko"&target="1:josh"&max_depth=5
Response Status
1200
Response Body
 1{
 2    "paths":[
 3        {
 4            "objects":[
 5                "1:marko",
 6                "1:josh"
 7            ]
 8        },
 9        {
10            "objects":[
11                "1:marko",
12                "2:lop",
13                "1:josh"
14            ]
15        }
16    ]
17}
3.2.13.3 Use Cases

Used to find all paths between two vertices, for example:

  • In a social network, finding all possible relationship paths between two users.
  • In a device association network, finding all associated paths between two devices.

3.2.14 Paths (POST, Advanced Version)

3.2.14.1 Function Introduction

Finds all paths based on conditions such as the starting vertex, destination vertex, steps (step), and maximum depth.

Params
  • sources: Defines the starting vertices, required. The specification methods include:
    • ids: Provide the starting vertices through a list of vertex IDs.
    • label and properties: If no IDs are specified, use the label and properties as combined conditions to query the starting vertices.
      • label: Vertex type.
      • properties: Query the starting vertices based on the values of their properties.

      Note: The property values in properties can be a list, indicating that any value corresponding to the key is acceptable.

  • targets: Defines the destination vertices, required. The specification methods include:
    • ids: Provide the destination vertices through a list of vertex IDs.
    • label and properties: If no IDs are specified, use the label and properties as combined conditions to query the destination vertices.
      • label: Vertex type.
      • properties: Query the destination vertices based on the values of their properties.

      Note: The property values in properties can be a list, indicating that any value corresponding to the key is acceptable.

  • step: Represents the path from the starting vertex to the destination vertex, required. The structure of Step is as follows:
    • direction: Represents the direction of edges (OUT, IN, BOTH). The default is BOTH.
    • labels: List of edge types.
    • properties: Filters edges based on property values.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: Used to set the minimum number of edges to be discarded for super vertices during the query process. When the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely discarded. Optional, if enabled, it must satisfy the constraint skip_degree >= max_degree. Default is 0 (not enabled), which means no points are skipped. (Note: When this configuration is enabled, the traversal will attempt to visit skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please make sure to understand before enabling it.)
  • max_depth: Number of steps, required.
  • nearest: When nearest is true, it means the shortest path length from the starting vertex to the result vertex is depth, and there is no shorter path. When nearest is false, it means there is a path of length depth from the starting vertex to the result vertex (not necessarily the shortest path and can have cycles). Optional, default is true.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • limit: Maximum number of paths to be returned. Optional, default is 10.
  • with_vertex: When true, the results include complete vertex information (all vertices in the path). When false, only the vertex IDs are returned. Optional, default is false.
3.2.14.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/paths
Request Body
 1{
 2"sources": {
 3  "ids": ["1:marko"]
 4},
 5"targets": {
 6  "ids": ["1:peter"]
 7},
 8"step": {
 9"direction": "BOTH",
10  "properties": {
11    "weight": "P.gt(0.01)"
12  }
13},
14"max_depth": 10,
15"capacity": 100000000,
16"limit": 10000000,
17"with_vertex": false
18}
Response Status
1200
Response Body
 1{
 2    "paths": [
 3        {
 4            "objects": [
 5                "1:marko",
 6                "1:josh",
 7                "2:lop",
 8                "1:peter"
 9            ]
10        },
11        {
12            "objects": [
13                "1:marko",
14                "2:lop",
15                "1:peter"
16            ]
17        }
18    ]
19}
3.2.14.3 Use Cases

Used to find all paths between two vertices, for example:

  • In a social network, finding all possible relationship paths between two users.
  • In a device association network, finding all associated paths between two devices.

3.2.15 Customized Paths

3.2.15.1 Function Introduction

Finds all paths that meet the specified conditions based on a batch of starting vertices, edge rules (including direction, edge types, and property filters), and maximum depth.

Params
  • sources: Defines the starting vertices, required. The specification methods include:
    • ids: Provide the starting vertices through a list of vertex IDs.
    • label and properties: If no IDs are specified, use the label and properties as combined conditions to query the starting vertices.
      • label: Vertex type.
      • properties: Query the starting vertices based on the values of their properties.

      Note: The property values in properties can be a list, indicating that any value corresponding to the key is acceptable.

  • steps: Represents the path rules traversed from the starting vertices and is a list of Steps. Required. The structure of each Step is as follows:
    • direction: Represents the direction of edges (OUT, IN, BOTH). The default is BOTH.
    • labels: List of edge types.
    • properties: Filters edges based on property values.
    • weight_by: Calculates the weight of edges based on the specified property. It is effective when sort_by is not NONE and is mutually exclusive with default_weight.
    • default_weight: The default weight to be used when there is no property to calculate the weight of edges. It is effective when sort_by is not NONE and is mutually exclusive with weight_by.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • sample: Used when sampling is needed for the edges that meet the conditions of a specific step. -1 means no sampling, and the default is to sample 100 edges.
  • sort_by: Sorts the paths based on their weights. Optional, default is NONE:
    • NONE: No sorting, default value.
    • INCR: Sorts in ascending order based on path weights.
    • DECR: Sorts in descending order based on path weights.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • limit: Maximum number of paths to be returned. Optional, default is 10.
  • with_vertex: When true, the results include complete vertex information (all vertices in the path). When false, only the vertex IDs are returned. Optional, default is false.
3.2.15.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/customizedpaths
Request Body
 1{
 2    "sources":{
 3        "ids":[
 4
 5        ],
 6        "label":"person",
 7        "properties":{
 8            "name":"marko"
 9        }
10    },
11    "steps":[
12        {
13            "direction":"OUT",
14            "labels":[
15                "knows"
16            ],
17            "weight_by":"weight",
18            "max_degree":-1
19        },
20        {
21            "direction":"OUT",
22            "labels":[
23                "created"
24            ],
25            "default_weight":8,
26            "max_degree":-1,
27            "sample":1
28        }
29    ],
30    "sort_by":"INCR",
31    "with_vertex":true,
32    "capacity":-1,
33    "limit":-1
34}
Response Status
1200
Response Body
 1{
 2    "paths":[
 3        {
 4            "objects":[
 5                "1:marko",
 6                "1:josh",
 7                "2:lop"
 8            ],
 9            "weights":[
10                1,
11                8
12            ]
13        }
14    ],
15    "vertices":[
16        {
17            "id":"1:marko",
18            "label":"person",
19            "type":"vertex",
20            "properties":{
21                "city":[
22                    {
23                        "id":"1:marko>city",
24                        "value":"Beijing"
25                    }
26                ],
27                "name":[
28                    {
29                        "id":"1:marko>name",
30                        "value":"marko"
31                    }
32                ],
33                "age":[
34                    {
35                        "id":"1:marko>age",
36                        "value":29
37                    }
38                ]
39            }
40        },
41        {
42            "id":"1:josh",
43            "label":"person",
44            "type":"vertex",
45            "properties":{
46                "city":[
47                    {
48                        "id":"1:josh>city",
49                        "value":"Beijing"
50                    }
51                ],
52                "name":[
53                    {
54                        "id":"1:josh>name",
55                        "value":"josh"
56                    }
57                ],
58                "age":[
59                    {
60                        "id":"1:josh>age",
61                        "value":32
62                    }
63                ]
64            }
65        },
66        {
67            "id":"2:lop",
68            "label":"software",
69            "type":"vertex",
70            "properties":{
71                "price":[
72                    {
73                        "id":"2:lop>price",
74                        "value":328
75                    }
76                ],
77                "name":[
78                    {
79                        "id":"2:lop>name",
80                        "value":"lop"
81                    }
82                ],
83                "lang":[
84                    {
85                        "id":"2:lop>lang",
86                        "value":"java"
87                    }
88                ]
89            }
90        }
91    ]
92}
3.2.15.3 Use Cases

Suitable for finding various complex sets of paths, for example:

  • In a social network, finding the paths from users who have watched movies directed by Zhang Yimou to the influencers they follow (Zhang Yimou —> Movie —> User —> Influencer).
  • In a risk control network, finding the paths from multiple high-risk users to the friends of their direct relatives (High-risk user —> Direct relative —> Friend).

3.2.16 Template Paths

3.2.16.1 Function Introduction

Finds all paths that meet the specified conditions based on a batch of starting vertices, edge rules (including direction, edge types, and property filters), and maximum depth.

Params
  • sources: Defines the starting vertices, required. The specification methods include:
    • ids: Provide the starting vertices through a list of vertex IDs.
    • label and properties: If no IDs are specified, use the label and properties as combined conditions to query the starting vertices.
      • label: Vertex type.
      • properties: Query the starting vertices based on the values of their properties.

      Note: The property values in properties can be a list, indicating that any value corresponding to the key is acceptable.

  • targets: Defines the ending vertices, required. The specification methods include:
    • ids: Provide the ending vertices through a list of vertex IDs.
    • label and properties: If no IDs are specified, use the label and properties as combined conditions to query the ending vertices.
      • label: Vertex type.
      • properties: Query the ending vertices based on the values of their properties.

      Note: The property values in properties can be a list, indicating that any value corresponding to the key is acceptable.

  • steps: Represents the path rules traversed from the starting vertices and is a list of Steps. Required. The structure of each Step is as follows:
    • direction: Represents the direction of edges (OUT, IN, BOTH). The default is BOTH.
    • labels: List of edge types.
    • properties: Filters edges based on property values.
    • max_times: The number of times the current step can be repeated. When set to N, it means the starting vertices can pass through the current step 1-N times.
    • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: Used to set the minimum number of edges to discard super vertices during the query process. When the number of adjacent edges of a vertex is greater than skip_degree, the vertex is completely discarded. Optional. If enabled, it must satisfy the skip_degree >= max_degree constraint. Default is 0 (not enabled), which means no points are skipped. (Note: After enabling this configuration, traversing will attempt to access a vertex’s skip_degree edges, not just max_degree edges. This incurs additional traversal overhead and may have a significant impact on query performance. Please ensure understanding before enabling.)
  • with_ring: Boolean value, true to include cycles; false to exclude cycles. Default is false.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • limit: Maximum number of paths to be returned. Optional, default is 10.
  • with_vertex: When true, the results include complete vertex information (all vertices in the path). When false, only the vertex IDs are returned. Optional, default is

false.

3.2.16.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/templatepaths
Request Body
 1{
 2  "sources": {
 3    "ids": [],
 4    "label": "person",
 5    "properties": {
 6      "name": "vadas"
 7    }
 8  },
 9  "targets": {
10    "ids": [],
11    "label": "software",
12    "properties": {
13      "name": "ripple"
14    }
15  },
16  "steps": [
17    {
18      "direction": "IN",
19      "labels": ["knows"],
20      "properties": {
21      },
22      "max_degree": 10000,
23      "skip_degree": 100000
24    },
25    {
26      "direction": "OUT",
27      "labels": ["created"],
28      "properties": {
29      },
30      "max_degree": 10000,
31      "skip_degree": 100000
32    },
33    {
34      "direction": "IN",
35      "labels": ["created"],
36      "properties": {
37      },
38      "max_degree": 10000,
39      "skip_degree": 100000
40    },
41    {
42      "direction": "OUT",
43      "labels": ["created"],
44      "properties": {
45      },
46      "max_degree": 10000,
47      "skip_degree": 100000
48    }
49  ],
50  "capacity": 10000,
51  "limit": 10,
52  "with_vertex": true
53}
Response Status
1200
Response Body
 1{
 2    "paths": [
 3        {
 4            "objects": [
 5                "1:vadas",
 6                "1:marko",
 7                "2:lop",
 8                "1:josh",
 9                "2:ripple"
10            ]
11        }
12    ],
13    "vertices": [
14        {
15            "id": "2:ripple",
16            "label": "software",
17            "type": "vertex",
18            "properties": {
19                "name": "ripple",
20                "lang": "java",
21                "price": 199
22            }
23        },
24        {
25            "id": "1:marko",
26            "label": "person",
27            "type": "vertex",
28            "properties": {
29                "name": "marko",
30                "age": 29,
31                "city": "Beijing"
32            }
33        },
34        {
35            "id": "1:josh",
36            "label": "person",
37            "type": "vertex",
38            "properties": {
39                "name": "josh",
40                "age": 32,
41                "city": "Beijing"
42            }
43        },
44        {
45            "id": "1:vadas",
46            "label": "person",
47            "type": "vertex",
48            "properties": {
49                "name": "vadas",
50                "age": 27,
51                "city": "Hongkong"
52            }
53        },
54        {
55            "id": "2:lop",
56            "label": "software",
57            "type": "vertex",
58            "properties": {
59                "name": "lop",
60                "lang": "java",
61                "price": 328
62            }
63        }
64    ]
65}
3.2.16.3 Use Cases

Suitable for finding various complex template paths, such as personA -(Friend)-> personB -(Classmate)-> personC, where the “Friend” and “Classmate” edges can have a maximum depth of 3 and 4 layers, respectively.

3.2.17 Crosspoints

3.2.17.1 Function Introduction

Finds the intersection points based on the specified conditions, including starting vertices, destination vertices, direction, edge types (optional), and maximum depth.

Params
  • source: ID of the starting vertex, required.
  • target: ID of the destination vertex, required.
  • direction: The direction from the starting vertex to the destination vertex. The reverse direction is used from the destination vertex to the starting vertex. When set to BOTH, the direction is not considered (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type, optional. Default represents all edge labels.
  • max_depth: Number of steps, required.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional, default is 10000000.
  • limit: Maximum number of intersection points to be returned. Optional, default is 10.
3.2.17.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/crosspoints?source="2:lop"&target="2:ripple"&max_depth=5&direction=IN
Response Status
1200
Response Body
 1{
 2    "crosspoints":[
 3        {
 4            "crosspoint":"1:josh",
 5            "objects":[
 6                "2:lop",
 7                "1:josh",
 8                "2:ripple"
 9            ]
10        }
11    ]
12}
3.2.17.3 Use Cases

Used to find the intersection points and their paths between two vertices, such as:

  • In a social network, finding the topics or influencers that two users have in common.
  • In a family relationship, finding common ancestors.

3.2.18 Customized Crosspoints

3.2.18.1 Function Introduction

Finds the intersection of destination vertices that satisfy the specified conditions, including starting vertices, multiple edge rules (including direction, edge type, and property filters), and maximum depth.

Params
  • sources: Defines the starting vertices, required. The specified options include:

    • ids: Provides a list of vertex IDs as starting vertices.
    • label and properties: If no IDs are specified, uses the combined conditions of label and properties to query the starting vertices.
      • label: Type of the vertex.
      • properties: Queries the starting vertices based on property values.

      Note: Property values in properties can be a list, indicating that the value of the key can be any item in the list.

  • path_patterns: Represents the path rules to be followed from the starting vertices. It is a list of rules. Required. Each rule is a PathPattern.

    • Each PathPattern consists of a list of steps, where each step has the following structure:
      • direction: Indicates the direction of the edge (OUT, IN, BOTH). Default is BOTH.
      • labels: List of edge types.
      • properties: Filters the edges based on property values.
      • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Default is 10000.
      • skip_degree: Sets the minimum number of edges to discard super vertices during the query process. If the number of adjacent edges for a vertex is greater than skip_degree, the vertex is completely discarded. Optional. If enabled, it must satisfy the constraint skip_degree >= max_degree. Default is 0 (not enabled), which means no vertices are skipped. Note: When this configuration is enabled, the traversal process will attempt to visit skip_degree edges of a vertex, not just max_degree edges. This incurs additional traversal overhead and may significantly impact query performance. Please make sure you understand it before enabling.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional. Default is 10000000.

  • limit: Maximum number of paths to be returned. Optional. Default is 10.

  • with_path: When set to true, returns the paths where the intersection points are located. When set to false, does not return the paths. Optional. Default is false.

  • with_vertex: Optional. Default is false.

    • When set to true, the result includes complete vertex information (all vertices in the paths):
      • When with_path is true, it returns complete information of all vertices in the paths.
      • When with_path is false, it returns complete information of all intersection points.
    • When set to false, only the vertex IDs are returned.
3.2.18.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/customizedcrosspoints
Request Body
 1{
 2    "sources":{
 3        "ids":[
 4            "2:lop",
 5            "2:ripple"
 6        ]
 7    },
 8    "path_patterns":[
 9        {
10            "steps":[
11                {
12                    "direction":"IN",
13                    "labels":[
14                        "created"
15                    ],
16                    "max_degree":-1
17                }
18            ]
19        }
20    ],
21    "with_path":true,
22    "with_vertex":true,
23    "capacity":-1,
24    "limit":-1
25}
Response Status
1200
Response Body
 1{
 2    "crosspoints":[
 3        "1:josh"
 4    ],
 5    "paths":[
 6        {
 7            "objects":[
 8                "2:ripple",
 9                "1:josh"
10            ]
11        },
12        {
13            "objects":[
14                "2:lop",
15                "1:josh"
16            ]
17        }
18    ],
19    "vertices":[
20        {
21            "id":"2:ripple",
22            "label":"software",
23            "type":"vertex",
24            "properties":{
25                "price":[
26                    {
27                        "id":"2:ripple>price",
28                        "value":199
29                    }
30                ],
31                "name":[
32                    {
33                        "id":"2:ripple>name",
34                        "value":"ripple"
35                    }
36                ],
37                "lang":[
38                    {
39                        "id":"2:ripple>lang",
40                        "value":"java"
41                    }
42                ]
43            }
44        },
45        {
46            "id":"1:josh",
47            "label":"person",
48            "type":"vertex",
49            "properties":{
50                "city":[
51                    {
52                        "id":"1:josh>city",
53                        "value":"Beijing"
54                    }
55                ],
56                "name":[
57                    {
58                        "id":"1:josh>name",
59                        "value":"josh"
60                    }
61                ],
62                "age":[
63                    {
64                        "id":"1:josh>age",
65                        "value":32
66                    }
67                ]
68            }
69        },
70        {
71            "id":"2:lop",
72            "label":"software",
73            "type":"vertex",
74            "properties":{
75                "price":[
76                    {
77                        "id":"2:lop>price",
78                        "value":328
79                    }
80                ],
81                "name":[
82                    {
83                        "id":"2:lop>name",
84                        "value":"lop"
85                    }
86                ],
87                "lang":[
88                    {
89                        "id":"2:lop>lang",
90                        "value":"java"
91                    }
92                ]
93            }
94        }
95    ]
96}
3.2.18.3 Use Cases

Used to query a group of vertices that have intersections at the destination through multiple paths. For example:

  • In a product knowledge graph, multiple models of smartphones, learning devices, and gaming devices belong to the top-level category of electronic devices through different lower-level category paths.

3.2.19 Rings

3.2.19.1 Function Introduction

Finds reachable cycles based on the specified conditions, including starting vertices, direction, edge types (optional), and maximum depth.

For example: 1 -> 25 -> 775 -> 14690 -> 25, where the cycle is 25 -> 775 -> 14690 -> 25.

Params
  • source: Starting vertex ID, required.
  • direction: Direction of edges emitted from the starting vertex (OUT, IN, BOTH). Optional. Default is BOTH.
  • label: Edge type. Optional. Default represents all edge labels.
  • max_depth: Number of steps. Required.
  • source_in_ring: Whether the starting point is included in the cycle. Optional. Default is true.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional. Default is 10000.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional. Default is 10000000.
  • limit: Maximum number of reachable cycles to be returned. Optional. Default is 10.
3.2.19.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/rings?source="1:marko"&max_depth=2
Response Status
1200
Response Body
 1{
 2    "rings":[
 3        {
 4            "objects":[
 5                "1:marko",
 6                "1:josh",
 7                "1:marko"
 8            ]
 9        },
10        {
11            "objects":[
12                "1:marko",
13                "1:vadas",
14                "1:marko"
15            ]
16        },
17        {
18            "objects":[
19                "1:marko",
20                "2:lop",
21                "1:marko"
22            ]
23        }
24    ]
25}
3.2.19.3 Use Cases

Used to query cycles reachable from the starting vertex, for example:

  • In a risk control project, querying individuals or devices involved in a circular guarantee that a user is connected to.
  • In a device network, discovering devices that have circular references around a specific device.

3.2.20 Rays

3.2.20.1 Function Introduction

Finds paths that diverge from the starting vertex and reach boundary vertices based on the specified conditions, including starting vertices, direction, edge types (optional), and maximum depth.

For example: 1 -> 25 -> 775 -> 14690 -> 2289 -> 18379, where 18379 is the boundary vertex, meaning there are no edges emitted from 18379.

Params
  • source: Starting vertex ID, required.
  • direction: Direction of edges emitted from the starting vertex (OUT, IN, BOTH). Optional. Default is BOTH.
  • label: Edge type. Optional. Default represents all edge labels.
  • max_depth: Number of steps. Required.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional. Default is 10000.
  • capacity: Maximum number of vertices to be visited during the traversal process. Optional. Default is 10000000.
  • limit: Maximum number of non-cycle paths to be returned. Optional. Default is 10.
3.2.20.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/rays?source="1:marko"&max_depth=2&direction=OUT
Response Status
1200
Response Body
 1{
 2    "rays":[
 3        {
 4            "objects":[
 5                "1:marko",
 6                "1:vadas"
 7            ]
 8        },
 9        {
10            "objects":[
11                "1:marko",
12                "2:lop"
13            ]
14        },
15        {
16            "objects":[
17                "1:marko",
18                "1:josh",
19                "2:ripple"
20            ]
21        },
22        {
23            "objects":[
24                "1:marko",
25                "1:josh",
26                "2:lop"
27            ]
28        }
29    ]
30}
3.2.20.3 Use Cases

Used to find paths from the starting vertex to boundary vertices based on a specific relationship, for example:

  • In a family relationship, finding paths from a person to all descendants who do not have children.
  • In a device network, discovering paths from a specific device to terminal devices.

3.2.21 Fusiform Similarity

3.2.21.1 Function Introduction

Queries a batch of “fusiform similar vertices” based on specified conditions. When two vertices share a certain relationship with many common vertices, they are considered “fusiform similar vertices.” For example, if “Reader A” has read 100 books, readers who have read 80 or more of these 100 books can be defined as “fusiform similar vertices” of “Reader A.”

Params
  • sources: Starting vertices, required. Specify using:

    • ids: Provide a list of vertex IDs as starting vertices.
    • label and properties: If ids are not specified, use the combined conditions of label and properties to query the starting vertices.
      • label: Vertex type.
      • properties: Query the starting vertices based on the values of their properties.

      Note: Property values in properties can be a list, indicating that the value of the key can be any value in the list.

  • label: Edge type. Optional. Default represents all edge labels.

  • direction: Direction in which the starting vertex diverges (OUT, IN, BOTH). Optional. Default is BOTH.

  • min_neighbors: Minimum number of neighbors. If the number of neighbors is less than this threshold, the starting vertex is not considered a “fusiform similar vertex.” For example, if you want to find “fusiform similar vertices” of books read by “Reader A,” and min_neighbors is set to 100, it means that “Reader A” must have read at least 100 books to have “fusiform similar vertices.” Required.

  • alpha: Similarity, representing the proportion of common neighbors between the starting vertex and “fusiform similar vertices” to all neighbors of the starting vertex. Required.

  • min_similars: Minimum number of “fusiform similar vertices.” Only when the number of “fusiform similar vertices” of the starting vertex is greater than or equal to this value, the starting vertex and its “fusiform similar vertices” will be returned. Optional. Default is 1.

  • top: Returns the top highest similarity “fusiform similar vertices” of a starting vertex. Required. 0 means all.

  • group_property: Used together with min_groups. Returns the starting vertex and its “fusiform similar vertices” only if there are at least min_groups different values for a certain attribute of the starting vertex and its “fusiform similar vertices.” For example, when recommending “out-of-town” book buddies for “Reader A,” set group_property to the “city” attribute of readers and min_group to at least 2. Optional. If not specified, no filtering based on attributes is needed.

  • min_groups: Used together with group_property. Only meaningful when group_property is set.

  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional. Default is 10000.

  • capacity: Maximum number of vertices to be visited during the traversal process. Optional. Default is 10000000.

  • limit: Maximum number of results to be returned (one starting vertex and its “fusiform similar vertices” count as one result). Optional. Default is 10.

  • with_intermediary: Whether to return the starting vertex and the intermediate vertices that are commonly related to the “fusiform

similar vertices.” Default is false.

  • with_vertex: Optional. Default is false.
    • true: Returns complete vertex information in the results.
    • false: Only returns vertex IDs.
3.2.21.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/fusiformsimilarity
Request Body
 1{
 2    "sources":{
 3        "ids":[],
 4        "label": "person",
 5        "properties": {
 6            "name":"p1"
 7        }
 8    },
 9    "label":"read",
10    "direction":"OUT",
11    "min_neighbors":8,
12    "alpha":0.75,
13    "min_similars":1,
14    "top":0,
15    "group_property":"city",
16    "min_group":2,
17    "max_degree": 10000,
18    "capacity": -1,
19    "limit": -1,
20    "with_intermediary": false,
21    "with_vertex":true
22}
Response Status
1200
Response Body
 1{
 2    "similars": {
 3        "3:p1": [
 4            {
 5                "id": "3:p2",
 6                "score": 0.8888888888888888,
 7                "intermediaries": [
 8                ]
 9            },
10            {
11                "id": "3:p3",
12                "score": 0.7777777777777778,
13                "intermediaries": [
14                ]
15            }
16        ]
17    },
18    "vertices": [
19        {
20            "id": "3:p1",
21            "label": "person",
22            "type": "vertex",
23            "properties": {
24                "name": "p1",
25                "city": "Beijing"
26            }
27        },
28        {
29            "id": "3:p2",
30            "label": "person",
31            "type": "vertex",
32            "properties": {
33                "name": "p2",
34                "city": "Shanghai"
35            }
36        },
37        {
38            "id": "3:p3",
39            "label": "person",
40            "type": "vertex",
41            "properties": {
42                "name": "p3",
43                "city": "Beijing"
44            }
45        }
46    ]
47}
3.2.21.3 Use Cases

Used to query vertices that have high similarity with a group of vertices. For example:

  • Readers with similar book lists to a specific reader.
  • Players who play similar games to a specific player.

3.2.22 Vertices

3.2.22.1 Batch Query Vertices by Vertex IDs
Params
  • ids: List of vertex IDs to be queried.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices?ids="1:marko"&ids="2:lop"
Response Status
1200
Response Body
 1{
 2    "vertices":[
 3        {
 4            "id":"1:marko",
 5            "label":"person",
 6            "type":"vertex",
 7            "properties":{
 8                "city":[
 9                    {
10                        "id":"1:marko>city",
11                        "value":"Beijing"
12                    }
13                ],
14                "name":[
15                    {
16                        "id":"1:marko>name",
17                        "value":"marko"
18                    }
19                ],
20                "age":[
21                    {
22                        "id":"1:marko>age",
23                        "value":29
24                    }
25                ]
26            }
27        },
28        {
29            "id":"2:lop",
30            "label":"software",
31            "type":"vertex",
32            "properties":{
33                "price":[
34                    {
35                        "id":"2:lop>price",
36                        "value":328
37                    }
38                ],
39                "name":[
40                    {
41                        "id":"2:lop>name",
42                        "value":"lop"
43                    }
44                ],
45                "lang":[
46                    {
47                        "id":"2:lop>lang",
48                        "value":"java"
49                    }
50                ]
51            }
52        }
53    ]
54}
3.2.22.2 Get Vertex Shard Information

Obtain vertex shard information by specifying the shard size split_size (can be used in conjunction with Scan in 3.2.21.3 to retrieve vertices).

Params
  • split_size: Shard size, required.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices/shards?split_size=67108864
Response Status
1200
Response Body
 1{
 2    "shards":[
 3        {
 4            "start": "0",
 5            "end": "2165893",
 6            "length": 0
 7        },
 8        {
 9            "start": "2165893",
10            "end": "4331786",
11            "length": 0
12        },
13        {
14            "start": "4331786",
15            "end": "6497679",
16            "length": 0
17        },
18        {
19            "start": "6497679",
20            "end": "8663572",
21            "length": 0
22        },
23        ......
24    ]
25}
3.2.22.3 Batch Retrieve Vertices Based on Shard Information

Retrieve vertices in batches based on the specified shard information (refer to 3.2.21.2 Shard for obtaining shard information).

Params
  • start: Shard start position, required.
  • end: Shard end position, required.
  • page: Page position for pagination, optional. Default is null, no pagination. When page is “”, it represents the first page of pagination starting from the position indicated by start.
  • page_limit: The upper limit of the number of vertices per page when retrieving vertices with pagination, optional. Default is 100000.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/vertices/scan?start=0&end=4294967295
Response Status
1200
Response Body
  1{
  2    "vertices":[
  3        {
  4            "id":"2:ripple",
  5            "label":"software",
  6            "type":"vertex",
  7            "properties":{
  8                "price":[
  9                    {
 10                        "id":"2:ripple>price",
 11                        "value":199
 12                    }
 13                ],
 14                "name":[
 15                    {
 16                        "id":"2:ripple>name",
 17                        "value":"ripple"
 18                    }
 19                ],
 20                "lang":[
 21                    {
 22                        "id":"2:ripple>lang",
 23                        "value":"java"
 24                    }
 25                ]
 26            }
 27        },
 28        {
 29            "id":"1:vadas",
 30            "label":"person",
 31            "type":"vertex",
 32            "properties":{
 33                "city":[
 34                    {
 35                        "id":"1:vadas>city",
 36                        "value":"Hongkong"
 37                    }
 38                ],
 39                "name":[
 40                    {
 41                        "id":"1:vadas>name",
 42                        "value":"vadas"
 43                    }
 44                ],
 45                "age":[
 46                    {
 47                        "id":"1:vadas>age",
 48                        "value":27
 49                    }
 50                ]
 51            }
 52        },
 53        {
 54            "id":"1:peter",
 55            "label":"person",
 56            "type":"vertex",
 57            "properties":{
 58                "city":[
 59                    {
 60                        "id":"1:peter>city",
 61                        "value":"Shanghai"
 62                    }
 63                ],
 64                "name":[
 65                    {
 66                        "id":"1:peter>name",
 67                        "value":"peter"
 68                    }
 69                ],
 70                "age":[
 71                    {
 72                        "id":"1:peter>age",
 73                        "value":35
 74                    }
 75                ]
 76            }
 77        },
 78        {
 79            "id":"1:josh",
 80            "label":"person",
 81            "type":"vertex",
 82            "properties":{
 83                "city":[
 84                    {
 85                        "id":"1:josh>city",
 86                        "value":"Beijing"
 87                    }
 88                ],
 89                "name":[
 90                    {
 91                        "id":"1:josh>name",
 92                        "value":"josh"
 93                    }
 94                ],
 95                "age":[
 96                    {
 97                        "id":"1:josh>age",
 98                        "value":32
 99                    }
100                ]
101            }
102        },
103        {
104            "id":"1:marko",
105            "label":"person",
106            "type":"vertex",
107            "properties":{
108                "city":[
109                    {
110                        "id":"1:marko>city",
111                        "value":"Beijing"
112                    }
113                ],
114                "name":[
115                    {
116                        "id":"1:marko>name",
117                        "value":"marko"
118                    }
119                ],
120                "age":[
121                    {
122                        "id":"1:marko>age",
123                        "value":29
124                    }
125                ]
126            }
127        },
128        {
129            "id":"2:lop",
130            "label":"software",
131            "type":"vertex",
132            "properties":{
133                "price":[
134                    {
135                        "id":"2:lop>price",
136                        "value":328
137                    }
138                ],
139                "name":[
140                    {
141                        "id":"2:lop>name",
142                        "value":"lop"
143                    }
144                ],
145                "lang":[
146                    {
147                        "id":"2:lop>lang",
148                        "value":"java"
149                    }
150                ]
151            }
152        }
153    ]
154}
3.2.22.4 Use Cases
  • Querying vertices by ID list, which can be used for batch vertex queries. For example, after querying multiple paths in a path search, you can further query all vertex properties of a specific path.
  • Retrieving shards and querying vertices by shard, which can be used to traverse all vertices.

3.2.23 Edges

3.2.23.1 Batch Retrieve Edges Based on Edge IDs
Params
  • ids: List of edge IDs to be queried.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges?ids="S1:josh>1>>S2:lop"&ids="S1:josh>1>>S2:ripple"
Response Status
1200
Response Body
 1{
 2    "edges": [
 3        {
 4            "id": "S1:josh>1>>S2:lop",
 5            "label": "created",
 6            "type": "edge",
 7            "inVLabel": "software",
 8            "outVLabel": "person",
 9            "inV": "2:lop",
10            "outV": "1:josh",
11            "properties": {
12                "date": "20091111",
13                "weight": 0.4
14            }
15        },
16        {
17            "id": "S1:josh>1>>S2:ripple",
18            "label": "created",
19            "type": "edge",
20            "inVLabel": "software",
21            "outVLabel": "person",
22            "inV": "2:ripple",
23            "outV": "1:josh",
24            "properties": {
25                "date": "20171210",
26                "weight": 1
27            }
28        }
29    ]
30}
3.2.23.2 Retrieve Edge Shard Information

Retrieve shard information for edges by specifying the shard size (split_size). This can be used in conjunction with the Scan operation described in section 3.2.22.3 to retrieve edges.

Params
  • split_size: Shard size, required field.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges/shards?split_size=4294967295
Response Status
1200
Response Body
 1{
 2    "shards":[
 3        {
 4            "start": "0",
 5            "end": "1073741823",
 6            "length": 0
 7        },
 8        {
 9            "start": "1073741823",
10            "end": "2147483646",
11            "length": 0
12        },
13        {
14            "start": "2147483646",
15            "end": "3221225469",
16            "length": 0
17        },
18        {
19            "start": "3221225469",
20            "end": "4294967292",
21            "length": 0
22        },
23        {
24            "start": "4294967292",
25            "end": "4294967295",
26            "length": 0
27        }
28    ]
29}
3.2.23.3 Batch Retrieve Edges Based on Shard Information

Batch retrieve edges by specifying shard information (refer to section 3.2.22.2 for shard retrieval).

Params
  • start: Shard starting position, required field.
  • end: Shard ending position, required field.
  • page: Page position for pagination, optional field. Default is null, which means no pagination. When page is empty, it indicates the first page of pagination starting from the position indicated by start.
  • page_limit: Upper limit of the number of edges per page for paginated retrieval, optional field. Default is 100000.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/edges/scan?start=0&end=3221225469
Response Status
1200
Response Body
 1{
 2    "edges":[
 3        {
 4            "id":"S1:peter>2>>S2:lop",
 5            "label":"created",
 6            "type":"edge",
 7            "inVLabel":"software",
 8            "outVLabel":"person",
 9            "inV":"2:lop",
10            "outV":"1:peter",
11            "properties":{
12                "weight":0.2,
13                "date":"20170324"
14            }
15        },
16        {
17            "id":"S1:josh>2>>S2:lop",
18            "label":"created",
19            "type":"edge",
20            "inVLabel":"software",
21            "outVLabel":"person",
22            "inV":"2:lop",
23            "outV":"1:josh",
24            "properties":{
25                "weight":0.4,
26                "date":"20091111"
27            }
28        },
29        {
30            "id":"S1:josh>2>>S2:ripple",
31            "label":"created",
32            "type":"edge",
33            "inVLabel":"software",
34            "outVLabel":"person",
35            "inV":"2:ripple",
36            "outV":"1:josh",
37            "properties":{
38                "weight":1,
39                "date":"20171210"
40            }
41        },
42        {
43            "id":"S1:marko>1>20130220>S1:josh",
44            "label":"knows",
45            "type":"edge",
46            "inVLabel":"person",
47            "outVLabel":"person",
48            "inV":"1:josh",
49            "outV":"1:marko",
50            "properties":{
51                "weight":1,
52                "date":"20130220"
53            }
54        },
55        {
56            "id":"S1:marko>1>20160110>S1:vadas",
57            "label":"knows",
58            "type":"edge",
59            "inVLabel":"person",
60            "outVLabel":"person",
61            "inV":"1:vadas",
62            "outV":"1:marko",
63            "properties":{
64                "weight":0.5,
65                "date":"20160110"
66            }
67        },
68        {
69            "id":"S1:marko>2>>S2:lop",
70            "label":"created",
71            "type":"edge",
72            "inVLabel":"software",
73            "outVLabel":"person",
74            "inV":"2:lop",
75            "outV":"1:marko",
76            "properties":{
77                "weight":0.4,
78                "date":"20171210"
79            }
80        }
81    ]
82}
3.2.23.4 Use Cases
  • Querying edges based on ID list, suitable for batch retrieval of edges.
  • Retrieving shard information and querying edges based on shards, useful for traversing all edges.

3.2.24 Adamic-Adar

3.2.24.1 Function Introduction

Compute the Adamic-Adar index of two vertices: the sum of the reciprocal of the logarithm of the degree of each common neighbor.

Params
  • vertex: ID of one vertex, required.
  • other: ID of another vertex, required. It must differ from vertex.
  • direction: Direction in which the vertex expands outward (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type. Optional, default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • limit: Maximum number of common neighbors taken into account. Optional, default is 10000000.
3.2.24.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/adamicadar?vertex="1:marko"&other="1:josh"
Response Status
1200
Response Body

Common neighbors with a degree of 0 are skipped, so the result is 0.0 when the two vertices share no neighbor.

1{
2    "adamic_adar": 0.9102392266268373
3}
3.2.24.3 Use Cases

Predict whether a link is likely to appear between two vertices, where rare common neighbors weigh more than popular ones.

3.2.25 Resource Allocation

3.2.25.1 Function Introduction

Compute the resource allocation index of two vertices: the sum of the reciprocal of the degree of each common neighbor.

Params
  • vertex: ID of one vertex, required.
  • other: ID of another vertex, required. It must differ from vertex.
  • direction: Direction in which the vertex expands outward (OUT, IN, BOTH). Optional, default is BOTH.
  • label: Edge type. Optional, default represents all edge labels.
  • max_degree: Maximum number of adjacent edges to traverse for each vertex during the query process. Optional, default is 10000.
  • limit: Maximum number of common neighbors taken into account. Optional, default is 10000000.
3.2.25.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/resourceallocation?vertex="1:marko"&other="1:josh"
Response Status
1200
Response Body
1{
2    "resource_allocation": 0.3333333333333333
3}
3.2.25.3 Use Cases

Link prediction, as an alternative to Adamic-Adar with a stronger penalty on high-degree common neighbors.

3.2.26 Edge Existence

3.2.26.1 Function Introduction

Return the edges that exist between a source vertex and a target vertex.

Params
  • source: ID of the source vertex, required.
  • target: ID of the target vertex, required.
  • label: Edge type. Optional, default represents all edge labels.
  • sort_values: Value of the sort keys, required for edge labels of the MULTIPLE frequency to pick one of several parallel edges. Optional, default is an empty string.
  • limit: Maximum number of edges to be returned. Optional, default is 100.
3.2.26.2 Usage Method
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/edgeexist?source="1:marko"&target="2:lop"
Response Status
1200
Response Body
 1{
 2    "edges":[
 3        {
 4            "id":"S1:marko>2>>S2:lop",
 5            "label":"created",
 6            "type":"edge",
 7            "inVLabel":"software",
 8            "outVLabel":"person",
 9            "inV":"2:lop",
10            "outV":"1:marko",
11            "properties":{
12                "weight":0.4,
13                "date":"20171210"
14            }
15        }
16    ]
17}
3.2.26.3 Use Cases

Check whether two vertices are directly connected, and get the properties of the connecting edges in one request.

3.2.27 Count

3.2.27.1 Function Introduction

Count the vertices reached from a starting vertex after a series of traversal steps, without returning the vertices themselves.

Params
  • source: ID of the starting vertex, required.
  • steps: Steps of the traversal, required. Each step accepts the following fields:
    • direction: Direction in which the vertex expands outward (OUT, IN, BOTH). Optional, default is BOTH.
    • labels: List of edge labels of the step. Optional, default represents all edge labels.
    • properties: Property filter of the edges of the step. Optional.
    • max_degree: Maximum number of adjacent edges to traverse for each vertex in this step. Optional, default is 10000.
    • skip_degree: Threshold above which a super vertex is skipped in this step. Optional, default is 100000.
  • contains_traversed: Whether to also count the vertices reached by the intermediate steps. Optional, default is false.
  • dedup_size: Maximum number of vertices kept for deduplication, -1 means no limit. Optional, default is 1000000.
3.2.27.2 Usage Method
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/{graph}/traversers/count
Request Body
 1{
 2    "source": "1:marko",
 3    "steps": [
 4        {
 5            "direction": "BOTH",
 6            "labels": [],
 7            "max_degree": 100,
 8            "skip_degree": 100
 9        },
10        {
11            "direction": "BOTH",
12            "labels": [],
13            "max_degree": 100,
14            "skip_degree": 100
15        },
16        {
17            "direction": "BOTH",
18            "labels": [],
19            "max_degree": 100,
20            "skip_degree": 100
21        }
22    ]
23}
Response Status
1200
Response Body
1{
2    "count": 3
3}
3.2.27.3 Use Cases

Get the size of a multi-step neighborhood when only the number matters, so the vertices do not have to be serialized and transferred.

11 - Rank API

Rank REST API: Execute graph node ranking algorithms such as PageRank and Personalized PageRank for centrality analysis.

4.1 Rank API overview

Not only the Graph iteration (traverser) method, HugeGraph-Server also provide Rank API for recommendation purpose. You can use it to recommend some vertexes much closer to a vertex.

4.2 Details of Rank API

4.2.1 Personal Rank API

A typical scenario for Personal Rank algorithm is in recommendation application. According to the out edges of a vertex, recommend some other vertices that having the same or similar edges.

Here is a use case: According to someone’s reading habit or reading history, we can recommend some books he may be interested or some book pal.

For Example:

  1. Suppose we have a vertex, Person type, and named tom.He like 5 books a,b,c,d,e. If we want to recommend some book pal and books for tom, an easier idea is let’s check whoever also liked these books (common hobby based).
  2. Now, we need someone else, like neo, he like three books b,d,f. And Jay, he like 4 books c,d,e,g, and Lee, he also like 4 books a,d,e,f.
  3. For we don’t need to recommend books tom already read, the recommend-list should only contain the books Tom’s book pal already read but tom haven’t read yet. Such as book “f” and “g”, and with priority f > g.
  4. Now, we recompute Tom’s personal rank value, we will get a sorted TopN book pal or book recommend-list. (Choose OTHER_LABEL,for Only Book purpose)
4.2.1.0 Data Preparation

The case above is simple. Here we also provide a public test dataset MovieLens for use case. You should download the dataset. The load it into HugeGraph with HugeGraph-Loader. To make it simple, we ignore all properties data of user and move. only field id is enough. we also ignore the value of edge rating.

The metadata for input file and mapping file as follows:

 1////////////////////////////////////////////////////////////
 2// UserID::Gender::Age::Occupation::Zip-code
 3// MovieID::Title::Genres
 4// UserID::MovieID::Rating::Timestamp
 5////////////////////////////////////////////////////////////
 6
 7// Define schema
 8schema.propertyKey("id").asInt().ifNotExist().create();
 9schema.propertyKey("rate").asInt().ifNotExist().create();
10
11schema.vertexLabel("user")
12      .properties("id")
13      .primaryKeys("id")
14      .ifNotExist()
15      .create();
16schema.vertexLabel("movie")
17      .properties("id")
18      .primaryKeys("id")
19      .ifNotExist()
20      .create();
21
22schema.edgeLabel("rating")
23      .sourceLabel("user")
24      .targetLabel("movie")
25      .properties("rate")
26      .ifNotExist()
27      .create();
 1{
 2  "vertices": [
 3    {
 4      "label": "user",
 5      "input": {
 6        "type": "file",
 7        "path": "users.dat",
 8        "format": "TEXT",
 9        "delimiter": "::",
10        "header": ["UserID", "Gender", "Age", "Occupation", "Zip-code"]
11      },
12      "ignored": ["Gender", "Age", "Occupation", "Zip-code"],
13      "mapping": {
14          "UserID": "id"
15      }
16    },
17    {
18      "label": "movie",
19      "input": {
20        "type": "file",
21        "path": "movies.dat",
22        "format": "TEXT",
23        "delimiter": "::",
24        "header": ["MovieID", "Title", "Genres"]
25      },
26      "ignored": ["Title", "Genres"],
27      "mapping": {
28          "MovieID": "id"
29      }
30    }
31  ],
32  "edges": [
33    {
34      "label": "rating",
35      "source": ["UserID"],
36      "target": ["MovieID"],
37      "input": {
38        "type": "file",
39        "path": "ratings.dat",
40        "format": "TEXT",
41        "delimiter": "::",
42        "header": ["UserID", "MovieID", "Rating", "Timestamp"]
43      },
44      "ignored": ["Timestamp"],
45      "mapping": {
46          "UserID": "id",
47          "MovieID": "id",
48          "Rating": "rate"
49      }
50    }
51  ]
52}

Note: modify the input.path to your local path.

4.2.1.1 Function Introduction

suitable for bipartite graph, will return all vertex or a list of its correlation which related to all source vertex.

Bipartite Graph is a special model in Graph Theory, as well as a special flow in network. The strongest feature is, it split all vertex in graph into two sets. The vertex in the set is not connected. However,the vertex in two sets may connect with each other.

Suppose we have one bipartite graph based on user and things. A random walk based PersonalRank algorithm should be likes this:

  1. Choose a user u as start vertex, let’s set the initial weight to be 1.0 . Go from Vu with probability alpha to a neighbor vertex, and (1-alpha) to stay.
  2. If we decide to go outside, we would like to choose an edge, such as rating, to find a common judge.
    1. Then choose the neighbors of current vertex randomly with uniform distribution, and reset the weights with uniform distribution.
    2. Compensate the source vertex’s weight with (1 - alpha)
    3. Repeat step 2;
  3. Convergence after reaching a certain number of steps or precision, then we got a recommend-list.
Params

Required:

  • source: the id of source vertex
  • label: edge label go from the source vertex, should connect two different type of vertex

Optional:

  • alpha: the probability of going out for one vertex in each iteration,similar to the alpha of PageRank,required, value range is (0, 1], default 0.85.
  • max_degree: in query process, the max iteration number of adjacency edge for a vertex, default 10000
  • max_depth: iteration number,range [2, 5000], default 5
  • with_label:result filter,default BOTH_LABEL,optional list as follows:
    • SAME_LABEL:Only keep vertex which has the same type as source vertex
    • OTHER_LABEL:Only keep vertex which has different type as source vertex (the another part in bipartite graph)
    • BOTH_LABEL:Keep both type vertex
  • limit: max return vertex number,default 100
  • max_diff: accuracy for convergence, default 0.0001 (will implement soon)
  • sorted: whether sort the result by rank or not, true for descending sort, false for none, default true
4.2.1.2 Usage
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/personalrank
Request Body
1{
2    "source": "1:1",
3    "label": "rating",
4    "alpha": 0.6,
5    "max_depth": 15,
6    "with_label": "OTHER_LABEL",
7    "sorted": true,
8    "limit": 10
9}
Response Status
1200
Response Body
 1{
 2    "2:2858": 0.0005014026017816927,
 3    "2:1196": 0.0004336708357653617,
 4    "2:1210": 0.0004128083140214213,
 5    "2:593": 0.00038117341069881513,
 6    "2:480": 0.00037005373269728036,
 7    "2:1198": 0.000366641614652057,
 8    "2:2396": 0.0003622362410538888,
 9    "2:2571": 0.0003593312457300953,
10    "2:589": 0.00035922123055598566,
11    "2:110": 0.0003466135844390885
12}
4.2.1.3 Suitable Scenario

In a bipartite graph build by two different type of vertex, recommend other most related vertex to one vertex. for example:

  • Reading recommendation: find out the books should be recommended to someone first, It is also possible to recommend book pal with the highest common preferences at the same time (just like: WeChat “your friend also read xx " function)
  • Social recommendation: find out other Poster who interested in same topics, or other News/Messages you may be interested with (Such as : “Hot News” function in Weibo)
  • Commodity recommendation: according to someone’s shopping habit,find out a commodity list should recommend first, some online salesman may also be good (Such as : “You May Like” function in TaoBao)

4.2.2 Neighbor Rank API

4.2.2.0 Data Preparation
 1public class Loader {
 2    public static void main(String[] args) {
 3        HugeClient client = new HugeClient("http://127.0.0.1:8080", "hugegraph");
 4        SchemaManager schema = client.schema();
 5
 6        schema.propertyKey("name").asText().ifNotExist().create();
 7
 8        schema.vertexLabel("person")
 9              .properties("name")
10              .useCustomizeStringId()
11              .ifNotExist()
12              .create();
13
14        schema.vertexLabel("movie")
15              .properties("name")
16              .useCustomizeStringId()
17              .ifNotExist()
18              .create();
19
20        schema.edgeLabel("follow")
21              .sourceLabel("person")
22              .targetLabel("person")
23              .ifNotExist()
24              .create();
25
26        schema.edgeLabel("like")
27              .sourceLabel("person")
28              .targetLabel("movie")
29              .ifNotExist()
30              .create();
31
32        schema.edgeLabel("directedBy")
33              .sourceLabel("movie")
34              .targetLabel("person")
35              .ifNotExist()
36              .create();
37
38        GraphManager graph = client.graph();
39
40        Vertex O = graph.addVertex(T.label, "person", T.id, "O", "name", "O");
41
42        Vertex A = graph.addVertex(T.label, "person", T.id, "A", "name", "A");
43        Vertex B = graph.addVertex(T.label, "person", T.id, "B", "name", "B");
44        Vertex C = graph.addVertex(T.label, "person", T.id, "C", "name", "C");
45        Vertex D = graph.addVertex(T.label, "person", T.id, "D", "name", "D");
46
47        Vertex E = graph.addVertex(T.label, "movie", T.id, "E", "name", "E");
48        Vertex F = graph.addVertex(T.label, "movie", T.id, "F", "name", "F");
49        Vertex G = graph.addVertex(T.label, "movie", T.id, "G", "name", "G");
50        Vertex H = graph.addVertex(T.label, "movie", T.id, "H", "name", "H");
51        Vertex I = graph.addVertex(T.label, "movie", T.id, "I", "name", "I");
52        Vertex J = graph.addVertex(T.label, "movie", T.id, "J", "name", "J");
53
54        Vertex K = graph.addVertex(T.label, "person", T.id, "K", "name", "K");
55        Vertex L = graph.addVertex(T.label, "person", T.id, "L", "name", "L");
56        Vertex M = graph.addVertex(T.label, "person", T.id, "M", "name", "M");
57
58        O.addEdge("follow", A);
59        O.addEdge("follow", B);
60        O.addEdge("follow", C);
61        D.addEdge("follow", O);
62
63        A.addEdge("follow", B);
64        A.addEdge("like", E);
65        A.addEdge("like", F);
66
67        B.addEdge("like", G);
68        B.addEdge("like", H);
69
70        C.addEdge("like", I);
71        C.addEdge("like", J);
72
73        E.addEdge("directedBy", K);
74        F.addEdge("directedBy", B);
75        F.addEdge("directedBy", L);
76
77        G.addEdge("directedBy", M);
78    }
79}
4.2.2.1 Function Introduction

In a general graph structure,find the first N vertices of each layer with the highest correlation with a given starting point and their relevance.

In graph words: to go out from the starting point, get the probability of going to each vertex of each layer.

Params
  • source: id of source vertex,required
  • alpha:the probability of going out for one vertex in each iteration,similar to the alpha of PageRank,required, value range is (0, 1]
  • steps: a path rule for source vertex visited,it’s a list of Step,each Step map to a layout in result,required.The structure of each Step as follows:
    • direction:the direction of edge(OUT, IN, BOTH), BOTH for default.
    • labels:a list of edge types, will union all edge types
    • max_degree:in query process, the max iteration number of adjacency edge for a vertex, default 10000
      • max_degree: Maximum adjacent edges traversed per vertex, defaulting to 10000; the parameter name degree is also accepted.
    • skip_degree: the threshold above which a super vertex is skipped in this layer, default 0 (no skipping)
    • top: retains only the top N results with the highest weight in each layer of the results, default 10, max 1000
  • capacity: the maximum number of vertexes visited during the traversal, optional, default 10000000
4.2.2.2 Usage
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/traversers/neighborrank
Request Body
 1{
 2    "source":"O",
 3    "steps":[
 4        {
 5            "direction":"OUT",
 6            "labels":[
 7                "follow"
 8            ],
 9            "max_degree":-1,
10            "top":100
11        },
12        {
13            "direction":"OUT",
14            "labels":[
15                "follow",
16                "like"
17            ],
18            "max_degree":-1,
19            "top":100
20        },
21        {
22            "direction":"OUT",
23            "labels":[
24                "directedBy"
25            ],
26            "max_degree":-1,
27            "top":100
28        }
29    ],
30    "alpha":0.9,
31    "capacity":-1
32}
Response Status
1200
Response Body
 1{
 2    "ranks": [
 3        {
 4            "O": 1
 5        },
 6        {
 7            "B": 0.4305,
 8            "A": 0.3,
 9            "C": 0.3
10        },
11        {
12            "G": 0.17550000000000002,
13            "H": 0.17550000000000002,
14            "I": 0.135,
15            "J": 0.135,
16            "E": 0.09000000000000001,
17            "F": 0.09000000000000001
18        },
19        {
20            "M": 0.15795,
21            "K": 0.08100000000000002,
22            "L": 0.04050000000000001
23        }
24    ]
25}
4.2.2.3 Suitable Scenario

Find the vertices in different layers for a given start point that should be most recommended

  • For example, in the four-layered structure of the audience, friends, movies, and directors, according to the movies that a certain audience’s friends like, recommend movies for that audience, or recommend directors for those movies based on who made them.

12 - Variable API

Variable REST API: Store and manage key-value pairs as global variables for graph-level configuration and state management.

5.1 Variables

Variables can be used to store data about the entire graph. The data is accessed and stored in the form of key-value pairs.

5.1.1 Creating or Updating a Key-Value Pair

Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name
Request Body
1{
2  "data": "tom"
3}
Response Status
1200
Response Body
1{
2    "name": "tom"
3}

5.1.2 Listing all key-value pairs

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables
Response Status
1200
Response Body
1{
2    "name": "tom"
3}

5.1.3 Listing a specific key-value pair

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name
Response Status
1200
Response Body
1{
2    "name": "tom"
3}

5.1.4 Deleting a specific key-value pair

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/variables/name
Response Status
1204

13 - Graphs API

Graphs REST API: Manage graph instance lifecycle including creating, querying, cloning, clearing, and deleting graph databases.

6.1 Graphs

Warning

In production, enable Server authentication and authorization, restrict graph management with an IP allowlist and minimum permissions, and retain audit-*.log audit records. Unauthenticated settings below are only for isolated local tests.

This page documents the Graphs API on current master. For historical paths and request bodies, use the 1.7 Graphs API or 1.5 Graphs API.

With authentication enabled, creation, cloning, deletion, clearing, display-name changes, graph-configuration reads, read-mode changes, and manual compaction require graph-space management permission (space); administrators can satisfy it through permission inheritance. Snapshot creation/restoration and data-mode changes allow graph-space managers or the graph owner. Listing, details, and data/read-mode queries use graph read permissions. Raft APIs additionally require graph-space membership.

6.1.1 List all graphs in the graphspace

Params

Path parameters

  • graphspace: Graphspace name
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs
Response Status
1200
Response Body
1{
2    "graphs": [
3        "hugegraph",
4        "hugegraph1"
5    ]
6}

6.1.2 Get details of the graph

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph
Response Status
1200
Response Body
1{
2    "name": "hugegraph",
3    "backend": "rocksdb"
4}

6.1.3 Clear all data of a graph, include: schema, vertex, edge and index

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name

Query parameters

Since emptying the graph is a dangerous operation, we have added parameters for confirmation to the API to avoid false calls by users:

  • confirm_message: default by I'm sure to delete all data
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/clear?confirm_message=I%27m+sure+to+delete+all+data
Response Status
1204

6.1.4 Clone graph

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Name of the new graph to create

Query parameters

  • clone_graph_name: name of an existed graph. To clone from an existing graph, the user can choose to transfer the configuration file, which will replace the configuration in the existing graph
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/cloneGraph?clone_graph_name=hugegraph
Request Body [Optional]

Clone a non-auth mode graph (set Content-Type: application/json)

1{
2  "gremlin.graph": "org.apache.hugegraph.HugeFactory",
3  "backend": "rocksdb",
4  "serializer": "binary",
5  "store": "cloneGraph",
6  "rocksdb.data_path": "./rks-data-xx",
7  "rocksdb.wal_path": "./rks-data-xx"
8}

Note:

  1. The data/wal_path can’t be the same as the existing graph (use separate directories)
  2. Replace “gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy” to enable auth mode
Response Status
1201
Response Body
1{
2    "name": "cloneGraph",
3    "nickname": "cloneGraph",
4    "backend": "rocksdb",
5    "description": ""
6}

6.1.5 Create graph

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph-xx
Request Body

Create a graph (set Content-Type: application/json)

gremlin.graph Configuration:

  • Auth mode: "gremlin.graph": "org.apache.hugegraph.auth.HugeFactoryAuthProxy" (required in production)
  • Non-auth mode: "gremlin.graph": "org.apache.hugegraph.HugeFactory"

Note: For HStore, configure PD correctly in HugeGraph Server; see HStore configuration. The backend selects the scheduler: HStore uses the distributed scheduler; other backends use the local scheduler.

1{
2  "gremlin.graph": "org.apache.hugegraph.auth.HugeFactoryAuthProxy",
3  "backend": "rocksdb",
4  "serializer": "binary",
5  "store": "hugegraph",
6  "rocksdb.data_path": "./rks-data-xx",
7  "rocksdb.wal_path": "./rks-data-xx"
8}
Response Status
1201
Response Body
1{
2    "name": "hugegraph2",
3    "nickname": "hugegraph2",
4    "backend": "rocksdb",
5    "description": ""
6}

6.1.6 Delete graph and its data

Graph-space management permission (space) is required when authentication is enabled.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name

Query parameters

Since deleting a graph is a dangerous operation, we have added parameters for confirmation to the API to avoid false calls by users:

  • confirm_message: default by I'm sure to drop the graph
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/graphA?confirm_message=I%27m%20sure%20to%20drop%20the%20graph
Response Status
1204

6.1.7 List the graphs of the graphspace with their configuration

Returns one entry per graph the current user can read, each carrying the graph configuration (keys that look like passwords, secrets, tokens, credentials or private keys are left out) plus the fields below. Graphs marked as default for the current user come first.

Params

Path parameters

  • graphspace: Graphspace name

Query parameters

  • prefix: Return only the graphs whose name or nickname starts with this prefix
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/profile
Response Status
1200
Response Body

default_update_time is only present when the graph is a default graph of the current user, and create_time only when the graph records one.

 1[
 2  {
 3    "backend": "rocksdb",
 4    "serializer": "binary",
 5    "store": "hugegraph",
 6    "name": "hugegraph",
 7    "nickname": "hugegraph",
 8    "graphspace_nickname": "DEFAULT",
 9    "default": true,
10    "default_update_time": "2024-05-01 12:30:00",
11    "create_time": "2024-05-01 12:00:00"
12  }
13]

6.1.8 Update the nickname of a graph

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name

Request parameters

  • action: Must be update
  • update: Container for the fields to update. name is required and must match the graph name in the path, nickname is the new display name and must be unique inside the graphspace.
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph
Request Body
1{
2  "action": "update",
3  "update": {
4    "name": "hugegraph",
5    "nickname": "MyGraph"
6  }
7}
Response Status
1200
Response Body
1{
2  "hugegraph": "updated"
3}

6.1.9 Manage the default graphs of the current user

A default graph is recorded per user, so the endpoints below act on behalf of the calling user. They need the authentication system, a server started in standalone mode without it answers 400 with GraphSpace management is not supported in standalone mode.

Set a graph as default
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/default
Response Status
1200
Response Body
1{
2  "default_graph": [
3    "hugegraph"
4  ]
5}
Unset a default graph
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/default
Response Status
1200
Response Body
1{
2  "default_graph": []
3}
Get the default graphs
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/default
Response Status
1200
Response Body
1{
2  "default_graph": [
3    "hugegraph"
4  ]
5}

6.1.10 Reload the graphs of the graphspace

Reloads the graphs the server holds, which is useful after the graph configuration has changed outside the server.

Params

Path parameters

  • graphspace: Graphspace name

Request parameters

  • action: Must be reload
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/manage
Request Body
1{
2  "action": "reload"
3}
Response Status
1200
Response Body
1{
2  "graphs": "reloaded"
3}

6.2 Conf

6.2.1 Get configuration for a graph

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1GET
2http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/conf
Response Status
1200
Response Body
 1# gremlin entrence to create graph
 2gremlin.graph=org.apache.hugegraph.HugeFactory
 3# cache config
 4#schema.cache_capacity=1048576
 5#graph.cache_capacity=10485760
 6#graph.cache_expire=600
 7
 8# schema illegal name template
 9#schema.illegal_name_regex=\s+|~.*
10
11#vertex.default_label=vertex
12
13backend=rocksdb
14serializer=binary
15
16store=hugegraph
17...=

6.3 Mode

Allowed graph mode values are: NONE, RESTORING, MERGING, LOADING

  • None mode is regular mode
    • Not allowed to create schema with specified id
    • Not support creating vertex with id for AUTOMATIC id strategy
  • LOADING mode used to load data via hugegraph-loader.
    • When adding vertices / edges, it is not checked whether the required attributes are passed in

Restore has two different modes: Restoring and Merging

  • Restoring mode is used to restore schema and graph data to a new graph.
    • Support create schema with specified id
    • Support create vertex with id for AUTOMATIC id strategy
  • Merging mode is used to merge schema and graph data to an existing graph.
    • Not allowed to create schema with specified id
    • Support create vertex with id for AUTOMATIC id strategy

Under normal circumstances, the graph mode is None. When you need to restore the graph, you need to temporarily modify the graph mode to Restoring or Merging as needed. When you complete the restore, change the graph mode to None.

6.3.1 Get graph mode

Graph read permission (space_member or the graph owner) is required when authentication is enabled.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/mode
Response Status
1200
Response Body
1{
2    "mode": "NONE"
3}

Allowed graph mode values are: NONE, RESTORING, MERGING, LOADING

6.3.2 Modify graph mode.

Graph-space management permission (space) or graph ownership is required when authentication is enabled; administrators can satisfy it through permission inheritance.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/mode
Request Body
1"RESTORING"

Allowed graph mode values are: NONE, RESTORING, MERGING, LOADING

Response Status
1200
Response Body
1{
2    "mode": "RESTORING"
3}

6.3.3 Get graph’s read mode

Graph read permission (space_member or the graph owner) is required when authentication is enabled.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph_read_mode
Response Status
1200
Response Body
1{
2    "graph_read_mode": "ALL"
3}

6.3.4 Modify graph’s read mode.

Graph-space management permission (space) is required when authentication is enabled; administrators can satisfy it through permission inheritance.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph_read_mode
Request Body
1"OLTP_ONLY"

Allowed read mode values are: ALL, OLTP_ONLY. The API rejects OLAP_ONLY with Graph-read-mode could be ALL or OLTP_ONLY.

Response Status
1200
Response Body
1{
2    "graph_read_mode": "OLTP_ONLY"
3}

6.4 Snapshot

6.4.1 Create a snapshot

Graph-space management permission (space) or graph ownership is required when authentication is enabled; administrators can satisfy it through permission inheritance.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/snapshot_create
Response Status
1200
Response Body
1{
2    "hugegraph": "snapshot_created"
3}

6.4.2 Resume a snapshot

Graph-space management permission (space) or graph ownership is required when authentication is enabled; administrators can satisfy it through permission inheritance.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/snapshot_resume
Response Status
1200
Response Body
1{
2    "hugegraph": "snapshot_resumed"
3}

6.5 Compact

6.5.1 Manually compact graph

Graph-space management permission (space) is required when authentication is enabled; administrators can satisfy it through permission inheritance.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/compact
Response Status
1200
Response Body
1{
2    "nodes": 1,
3    "cluster_id": "local",
4    "servers": {
5        "local": "OK"
6    }
7}

6.6 Raft

These endpoints only work when the graph runs in raft mode, see the raft.mode option in Config Options. On a graph that does not, they answer 400 with Allowed <operation> operation only when working on raft mode.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name

Query parameters

  • group: Raft group name, default is default
  • endpoint: Address of the peer, in the host:port form. Required by transfer_leader, set_leader, add_peer and remove_peer.

6.6.1 List the peers of a raft group

Graph-space membership (space_member) is required when authentication is enabled; administrators can satisfy it through permission inheritance.

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/raft/list_peers
Response Status
1200
Response Body

The key of the returned object is the raft group name.

1{
2  "default": [
3    "127.0.0.1:8281",
4    "127.0.0.1:8282",
5    "127.0.0.1:8283"
6  ]
7}

6.6.2 Get the leader of a raft group

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/raft/get_leader
Response Status
1200
Response Body
1{
2  "default": "127.0.0.1:8281"
3}

6.6.3 Transfer the leadership of a raft group

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/raft/transfer_leader?endpoint=127.0.0.1:8282
Response Status
1200
Response Body
1{
2  "default": "127.0.0.1:8282"
3}

6.6.4 Set the leader of a raft group

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/raft/set_leader?endpoint=127.0.0.1:8282
Response Status
1200
Response Body
1{
2  "default": "127.0.0.1:8282"
3}

6.6.5 Add a peer to a raft group

This schedules an asynchronous task, see Task API.

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/raft/add_peer?endpoint=127.0.0.1:8284
Response Status
1200
Response Body
1{
2  "task_id": 1
3}

6.6.6 Remove a peer from a raft group

This schedules an asynchronous task, see Task API.

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/raft/remove_peer?endpoint=127.0.0.1:8284
Response Status
1200
Response Body
1{
2  "task_id": 2
3}

14 - Task API

Task REST API: Query and manage asynchronous task execution status for long-running operations like index rebuilding and graph traversals.

7.1 Task

7.1.1 List all async tasks in graph

Params
  • status: the status of asyncTasks, one of NEW, SCHEDULING, SCHEDULED, QUEUED, RESTORING, RUNNING, SUCCESS, CANCELLING, CANCELLED, FAILED, HANGING, DELETING, case-insensitive
  • ids: task ids to query, can be repeated. It can not be combined with status or page, and it ignores limit.
  • limit: the max number of tasks to return, default is 100
  • page: page token for pagination. When it is passed, the response carries a page field with the token of the next page.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks?status=success
Response Status
1200
Response Body
 1{
 2	"tasks": [{
 3		"task_name": "hugegraph.traversal().V()",
 4		"task_progress": 0,
 5		"task_create": 1532943976585,
 6		"task_status": "success",
 7		"task_update": 1532943976736,
 8		"task_result": "0",
 9		"task_retries": 0,
10		"id": 2,
11		"task_type": "gremlin",
12		"task_callable": "org.apache.hugegraph.api.job.GremlinAPI$GremlinJob",
13		"task_input": "{\"gremlin\":\"hugegraph.traversal().V()\",\"bindings\":{},\"language\":\"gremlin-groovy\",\"aliases\":{\"hugegraph\":\"graph\"}}"
14	}]
15}

7.1.2 View the details of an async task

Params
  • with_result: whether to load the result of the task, default is true
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2
Response Status
1200
Response Body
 1{
 2	"task_name": "hugegraph.traversal().V()",
 3	"task_progress": 0,
 4	"task_create": 1532943976585,
 5	"task_status": "success",
 6	"task_update": 1532943976736,
 7	"task_result": "0",
 8	"task_retries": 0,
 9	"id": 2,
10	"task_type": "gremlin",
11	"task_callable": "org.apache.hugegraph.api.job.GremlinAPI$GremlinJob",
12	"task_input": "{\"gremlin\":\"hugegraph.traversal().V()\",\"bindings\":{},\"language\":\"gremlin-groovy\",\"aliases\":{\"hugegraph\":\"graph\"}}"
13}

7.1.3 Delete task information of an async task,won’t delete the task itself

Params
  • force: whether to delete the task even when it is still running, default is false
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2
Response Status
1204

7.1.4 Cancel an async task, the task should be able to be canceled

If you already created an async task via Gremlin API as follows:

1"for (int i = 0; i < 10; i++) {" +
2    "hugegraph.addVertex(T.label, 'man');" +
3    "hugegraph.tx().commit();" +
4    "try {" +
5        "sleep(1000);" +
6    "} catch (InterruptedException e) {" +
7        "break;" +
8    "}" +
9"}"
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2?action=cancel

cancel it in 10s. if more than 10s, the task may already be finished, then can’t be cancelled.

Response Status
1202

Cancelling a task that is already completed or already cancelling returns 400.

Response Body

The whole task object is returned, with task_status set to cancelling or cancelled:

 1{
 2	"task_name": "for (int i = 0; i < 10; i++) {...}",
 3	"task_progress": 0,
 4	"task_create": 1532943976585,
 5	"task_status": "cancelling",
 6	"task_update": 1532943977001,
 7	"task_retries": 0,
 8	"id": 2,
 9	"task_type": "gremlin",
10	"task_callable": "org.apache.hugegraph.api.job.GremlinAPI$GremlinJob"
11}

At this point, the number of vertices whose label is man must be less than 10.

7.2 Algorithm Job

Schedules an OLAP algorithm as an asynchronous task inside the server. The task id in the response can be followed with the Task API above.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
  • name: Algorithm name. The registered algorithms are count_vertex, count_edge, degree_centrality, stress_centrality, betweenness_centrality, closeness_centrality, eigenvector_centrality, triangle_count, cluster_coefficient, lpa, louvain, weak_connected_component, fusiform_similarity, rings, k_core, page_rank and subgraph_stat. An unknown name returns 404.
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/algorithm/page_rank
Request Body

The body is the parameter map of the algorithm, and each algorithm validates its own parameters. Pass {} to run with the defaults.

1{
2    "alpha": 0.15,
3    "times": 10
4}
Response Status
1201
Response Body
1{
2    "task_id": 1
3}

7.3 Computer Job

Schedules a HugeGraph-Computer job as an asynchronous task. The computer job runs outside the server, see HugeGraph-Computer.

Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
  • name: Computer name. The registered computers are page_rank, weak_connected_component, lpa, triangle_count and louvain. An unknown name returns 404.
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/computer/page_rank
Request Body

The body is the parameter map of the computer job. Pass {} to run with the defaults.

1{}
Response Status
1201
Response Body
1{
2    "task_id": 2
3}

15 - Gremlin API

Gremlin REST API: Execute Gremlin graph traversal language scripts via HTTP interface.

8.1 Gremlin

Warning

Use native query APIs safely in production

The flexibility of graph query languages such as Gremlin and Cypher can introduce security risks. Do not expose native query endpoints directly to the public network. In production, enable authentication and authorization, maintain an IP allowlist, and grant minimum permissions. Standard Server configuration writes authentication-proxy authorization records to audit-*.log; retain these files and restrict read access. auth.audit_log_rate limits per-user output rather than serving as a dedicated audit-log on/off switch.

8.1.1 Send a Gremlin statement to HugeGraphServer (GET), synchronously

Params
  • gremlin: The Gremlin statement to execute on HugeGraphServer.
  • bindings: Parameter bindings with string keys and string or numeric values, similar to MySQL prepared statements, to speed up execution.
  • language: Statement language, defaulting to gremlin-groovy.
  • aliases: Adds aliases for existing variables in a graph space.

This REST proxy cannot reliably carry a JSON-braced aliases parameter in GET queries. Current graph binding names contain hyphens and cannot be used directly as Groovy variables. This GET example uses a simple expression; use the POST example with aliases below to select a graph for traversal.

Method & Url
1curl --compressed --get \
2  --data-urlencode "gremlin=1+1" \
3  http://127.0.0.1:8080/gremlin
Response Status
1200
Response Body
1{
2	"requestId": "<request_id>",
3	"status": {"message": "", "code": 200, "attributes": {}},
4	"result": {"data": [2], "meta": {}}
5}

8.1.2 Send a Gremlin statement to HugeGraphServer (POST), synchronously

Count vertices

Runnable request
1curl --compressed -sS -X POST http://127.0.0.1:8080/gremlin \
2  -H 'Content-Type: application/json' \
3  --data-binary '{"gremlin":"g.V().count()","aliases":{"g":"__g_DEFAULT-hugegraph"}}'

/gremlin is a top-level endpoint. The traversal source for graph hugegraph in graph space DEFAULT is __g_DEFAULT-hugegraph; aliases maps it to script variable g. Adjust the alias to the Server binding name for another graph or graph space. Batch responses can use gzip; curl --compressed decompresses them automatically.

Response Status
1200
Response Body
1{
2	"requestId": "<request_id>",
3	"status": {"message": "", "code": 200, "attributes": {}},
4	"result": {"data": [6], "meta": {}}
5}

Vertex count depends on current graph data; 6 above is an example result.

The response structure differs from the Vertex and Edge REST APIs; clients may need to parse it explicitly.

Query edges

Request Body
1{
2	"gremlin": "g.E().hasLabel('created').limit(1)",
3	"bindings": {},
4	"language": "gremlin-groovy",
5	"aliases": {
6		"g": "__g_DEFAULT-hugegraph"
7	}
8}
Response Status
1200
Response Body
 1{
 2	"requestId": "<request_id>",
 3	"status": {
 4		"message": "",
 5		"code": 200,
 6		"attributes": {}
 7	},
 8	"result": {
 9		"data": [{
10			"id": "<edge_id>",
11			"label": "created",
12			"type": "edge",
13			"outVLabel": "person",
14			"inVLabel": "software",
15			"outV": "<source_vertex_id>",
16			"inV": "<target_vertex_id>",
17			"properties": {
18				"weight": 0.4,
19				"date": "<date>"
20			}
21		}],
22		"meta": {}
23	}
24}

Edge IDs, endpoints, and properties depend on current graph data.

8.1.3 Send a Gremlin statement to HugeGraphServer (POST), asynchronously

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/jobs/gremlin

Query vertices

Request Body
1{
2	"gremlin": "g.V('1:marko')",
3	"bindings": {},
4	"language": "gremlin-groovy",
5	"aliases": {}
6}

Note:

Asynchronous requests cannot supply aliases. Server automatically binds graph to the current graph and g to its traversal source, and adds the URL graph name as an alias for graph. Scripts can use graph, g, or that graph name.

Response Status
1201
Response Body
1{
2	"task_id": 1
3}

Note:

Query task status with GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/1, where 1 is the task ID. See the asynchronous task REST API.

Query edges

Request Body
1{
2	"gremlin": "g.E().hasLabel('created').limit(1)",
3	"bindings": {},
4	"language": "gremlin-groovy",
5	"aliases": {}
6}
Response Status
1201
Response Body
1{
2	"task_id": 2
3}

Note:

Query task status with GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/tasks/2, where 2 is the task ID. See the asynchronous task REST API.

16 - Cypher API

Cypher REST API: Execute OpenCypher declarative graph query language via HTTP interface.

9.1 Cypher

The Cypher API always needs an Authorization header, either Basic or Bearer. A request without one is rejected with 401, even when the server runs without authentication. The credentials are forwarded to the Gremlin Server through conf/remote-objects.yaml.

9.1.1 Sending a cypher statement (GET) to HugeGraphServer for synchronous execution

Method & Url
1GET /graphspaces/{graphspace}/graphs/{graph}/cypher?cypher={cypher}
Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name

Query parameters

  • cypher: Cypher statement
Example
1GET http://localhost:8080/graphspaces/DEFAULT/graphs/hugecypher1/cypher?cypher=match(n:person) return n.name as name order by n.name limit 1
Response Status
1200
Response Body
 1{
 2    "requestId": "766b9f48-2f10-40d9-951a-3027d0748ab7",
 3    "status": {
 4        "message": "",
 5        "code": 200,
 6        "attributes": {
 7        }
 8    },
 9    "result": {
10        "data": [
11            {
12                "name": "hello"
13            }
14        ],
15        "meta": {
16        }
17    }
18}

9.1.2 Sending a cypher statement (POST) to HugeGraphServer for synchronous execution

Method & Url
1POST /graphspaces/{graphspace}/graphs/{graph}/cypher
Params

Path parameters

  • graphspace: Graphspace name
  • graph: Graph name
Body

{cypher}

  • cypher: Cypher statement

Note:

It is not in JSON format, but a plain text Cypher statement.

Example
1POST http://localhost:8080/graphspaces/DEFAULT/graphs/hugecypher1/cypher
Request Body
1match(n:person) return n.name as name order by n.name limit 1
Response Status
1200
Response Body
 1{
 2    "requestId": "f096bee0-e249-498f-b5a3-ea684fc84f57",
 3    "status": {
 4        "message": "",
 5        "code": 200,
 6        "attributes": {
 7        }
 8    },
 9    "result": {
10        "data": [
11            {
12                "name": "hello"
13            }
14        ],
15        "meta": {
16        }
17    }
18}

17 - Authentication API

Authentication REST API: Manage users, roles, permissions, and access control to implement fine-grained graph data security.

Version notes: This page documents current master. For historical behavior, use the 1.7 Authentication API or 1.5 Authentication API.

Users, graph-space groups, resources, memberships, and permission grants use /graphspaces/{graphspace}/auth/.... Login, logout, and token verification remain at /auth/login, /auth/logout, and /auth/verify; default graph-space roles are under /graphspaces/{graphspace}/role. Source retains top-level /auth/groups; this page’s group examples use the graph-space API.

{group_id}, {target_id}, {another_target_id}, {belong_id}, and {access_id} are placeholders. Replace them with the corresponding response id, then encode IDs as URL path components before placing them in a path.

10.1 User Authentication and Access Control

To enable authentication and related configurations, please refer to the Authentication Configuration documentation.

Overview of User Authentication and Access Control:

HugeGraph supports multi-user authentication and fine-grained access control. It adopts a 4-tier design based on “User-User Group-Operation-Resource” to flexibly control user roles and permissions. Resources describe data in the graph database, such as vertices that meet certain conditions. Each resource consists of three elements: type, label, and properties. There are a total of 18 types and combinations of any label and properties to form resources. The internal condition of a resource is an “AND” relationship, while the condition between multiple resources is an “OR” relationship. Users can belong to one or more user groups, and each user group can have permissions for any number of resources. The types of operations include read, write, delete, execute, etc. HugeGraph supports dynamically creating users, user groups, and resources, and supports dynamically assigning or revoking permissions. During the initialization of the database, a super administrator user is created, and subsequently, various role users can be created by the super administrator. If a newly created user is assigned sufficient permissions, they can create or manage more users.

Example:

user(name=boss) -belong-> group(name=all) -access(read)-> target(graph=graph1, resource={label: person, city: Beijing})
Description: User ‘boss’ has read permission for people in the ‘graph1’ graph from Beijing.

Interface Description:

The core of user authentication and access control is 5 categories: UserAPI, GroupAPI, TargetAPI, BelongAPI, AccessAPI. Alongside them, ManagerAPI grants graphspace-level manager roles, LoginAPI issues and verifies tokens, and ProjectAPI groups several graphs so that permissions can be granted for the whole set at once.

10.2 User (User) API

The user interface includes APIs for creating users, deleting users, modifying users, and querying user-related information.

10.2.1 Create User

Params
  • user_name: User name
  • user_password: User password
  • user_nickname: User nickname
  • user_phone: User phone number
  • user_email: User email
  • user_avatar: URL of the user avatar
  • user_description: User description

Both user_name and user_password are required, the rest are optional.

Request Body
1{
2    "user_name": "boss",
3    "user_password": "******",
4    "user_phone": "182****9088",
5    "user_email": "123@xx.com"
6}
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/auth/users
Response Status
1201 
Response Body

In the response message, the password is encrypted as ciphertext.

 1{
 2    "user_password": "******",
 3    "user_email": "123@xx.com",
 4    "user_update": "2020-11-17 14:31:07.833",
 5    "user_name": "boss",
 6    "user_creator": "admin",
 7    "user_phone": "182****9088",
 8    "id": "boss",
 9    "user_create": "2020-11-17 14:31:07.833"
10}

10.2.2 Delete User

Params
  • id: User ID to be deleted
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/auth/users/test
Response Status
1204

10.2.3 Modify User

Params
  • id: User ID to be modified
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/users/test
Request Body

Modify user_password and user_phone. user_name can not be changed, and when it is passed it must match the existing name.

1{
2    "user_name": "test",
3    "user_password": "******",
4    "user_phone": "183****9266"
5}
Response Status
1200
Response Body

The returned result is the entire user object including the modified content.

1{
2    "user_password": "******",
3    "user_update": "2020-11-12 10:29:30.455",
4    "user_name": "test",
5    "user_creator": "admin",
6    "user_phone": "183****9266",
7    "id": "test",
8    "user_create": "2020-11-12 10:27:13.601"
9}

10.2.4 Query User List

Params
  • name: Return only the user with this name. When it is given, the response is a single user object instead of a list, and 404 is returned if no such user exists.
  • limit: Upper limit of the number of results returned, default is 100
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/users
Response Status
1200
Response Body
 1{
 2    "users": [
 3        {
 4            "user_password": "******",
 5            "user_update": "2020-11-11 11:41:12.254",
 6            "user_name": "admin",
 7            "user_creator": "system",
 8          "id": "admin",
 9            "user_create": "2020-11-11 11:41:12.254"
10        }
11    ]
12}

10.2.5 Query a User

Params
  • id: User ID to be queried
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/users/admin
Response Status
1200
Response Body
1{
2    "user_password": "******",
3    "user_update": "2020-11-11 11:41:12.254",
4    "user_name": "admin",
5    "user_creator": "system",
6    "id": "admin",
7    "user_create": "2020-11-11 11:41:12.254"
8}

10.2.6 Query Roles of a User

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/users/boss/role
Response Status
1200
Response Body
 1{
 2    "roles": {
 3        "hugegraph": {
 4            "READ": [
 5                {
 6                    "type": "ALL",
 7                    "label": "*",
 8                    "properties": null
 9                }
10            ]
11        }
12    }
13}

10.3 Group (Group) API

Groups grant corresponding resource permissions, and users are assigned to different groups, thereby having different resource permissions. The group interface includes APIs for creating groups, deleting groups, modifying groups, and querying group-related information.

GroupAPI remains at /auth/groups, the only group route on 1.7.0. Current master also serves /graphspaces/DEFAULT/auth/groups, added by apache/hugegraph#3096.

The GraphSpace API generates each persisted group name as ~hubble_role:v1: + base64url(graphspace) + : + 32 hex digits. For DEFAULT, the name and ID look like ~hubble_role:v1:REVGQVVMVA:<32 hex>; request group_name is only a client label. Use the ID returned by the create response below.

10.3.1 Create Group

Params
  • group_name: Required client label; the Server generates the persisted name
  • group_description: Group description
Request Body
1{
2    "group_name": "all",
3    "group_description": "group can do anything"
4}

group_name is required, but cannot customize the persisted graph-space group name generated by Server. Copy the response id for later membership, authorization, lookup, update, or deletion operations.

Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/auth/groups
Response Status
1201 
Response Body
1{
2    "group_creator": "admin",
3    "group_name": "<server-generated graphspace-scoped name>",
4    "group_create": "2020-11-11 15:46:08.791",
5    "group_update": "2020-11-11 15:46:08.791",
6    "id": "{group_id}",
7    "group_description": "group can do anything"
8}

10.3.2 Delete Group

Params
  • id: Group ID to be deleted
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/auth/groups/{group_id}
Response Status
1204

10.3.3 Modify Group

Params
  • id: Group ID to be modified
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/groups/{group_id}
Request Body

Modify group_description. On the GraphSpace form group_name is omitted here, or equal to the generated name: any other value is rejected with “The name of group can’t be updated”.

1{
2    "group_description": "grant"
3}
Response Status
1200
Response Body

The returned result is the entire group object including the modified content.

1{
2    "group_creator": "admin",
3    "group_name": "<server-generated graphspace-scoped name>",
4    "group_create": "2020-11-12 09:50:58.458",
5    "group_update": "2020-11-12 09:57:58.155",
6    "id": "{group_id}",
7    "group_description": "grant"
8}

10.3.4 Query Group List

Params
  • limit: Upper limit of the number of results returned
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/groups
Response Status
1200
Response Body
 1{
 2    "groups": [
 3        {
 4            "group_creator": "admin",
 5            "group_name": "<server-generated graphspace-scoped name>",
 6            "group_create": "2020-11-11 15:46:08.791",
 7            "group_update": "2020-11-11 15:46:08.791",
 8            "id": "{group_id}",
 9            "group_description": "group can do anything"
10        }
11    ]
12}

10.3.5 Query a Specific Group

Params
  • id: Group ID to be queried
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/groups/{group_id}
Response Status
1200
Response Body
1{
2    "group_creator": "admin",
3    "group_name": "<server-generated graphspace-scoped name>",
4    "group_create": "2020-11-11 15:46:08.791",
5    "group_update": "2020-11-11 15:46:08.791",
6    "id": "{group_id}",
7    "group_description": "group can do anything"
8}

10.4 Resource (Target) API

Resources describe data in the graph database, such as vertices that meet certain criteria. Each resource includes three elements: type, label, and properties. There are 18 types in total, and the combination of any label and any properties forms a resource. The internal conditions of a resource are based on the AND relationship, while the conditions between multiple resources are based on the OR relationship.
The resource API includes creating, deleting, modifying, and querying resources.

10.4.1 Create Resource

Params
  • target_name: Name of the resource
  • target_graph: Graph of the resource
  • target_url: URL of the resource
  • target_resources: Resource definitions (list)

target_resources can include multiple target_resource, stored in the form of a list.
Each target_resource contains:

  • type: Optional value: VERTEX, EDGE, etc. Can be filled with ALL, indicating it can be a vertex or edge.
  • label: Optional value: name of a vertex or edge type. Can be filled with *, indicating any type.
  • properties: Map type, can contain multiple key-value pairs of properties. Must match all property values. Property values can support conditional ranges (e.g., age: P.gte(18)). If properties are null, it means any property is allowed. If both the property name and value are ‘*’, it also means any property is allowed.

For example, a specific resource: “target_resources”: [{“type”:“VERTEX”,“label”:“person”,“properties”:{“city”:“Beijing”,“age”:“P.gte(20)”}}]
The resource definition means: a vertex of type ‘person’ with the city property set to ‘Beijing’ and the age property greater than or equal to 20.

Request Body
 1{
 2    "target_name": "all",
 3    "target_graph": "hugegraph",
 4    "target_url": "127.0.0.1:8080",
 5    "target_resources": [
 6        {
 7            "type": "ALL"
 8        }
 9    ]
10}
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/auth/targets
Response Status
1201 
Response Body
 1{
 2    "target_creator": "admin",
 3    "target_name": "all",
 4    "target_url": "127.0.0.1:8080",
 5    "target_graph": "hugegraph",
 6    "target_create": "2020-11-11 15:32:01.192",
 7    "target_resources": [
 8        {
 9            "type": "ALL",
10            "label": "*",
11            "properties": null
12        }
13    ],
14    "id": "{target_id}",
15    "target_update": "2020-11-11 15:32:01.192"
16}

10.4.2 Delete Resource

Params
  • id: Resource Id to be deleted
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/auth/targets/{target_id}
Response Status
1204

10.4.3 Modify Resource

Params
  • id: Resource Id to be modified
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/targets/{target_id}
Request Body

Modify the ’type’ in the resource definition.

1{
2    "target_resources": [
3        {
4            "type": "NONE"
5        }
6    ]
7}
Response Status
1200
Response Body

The response contains the entire target group object, including the modified content.

 1{
 2    "target_creator": "admin",
 3    "target_name": "all",
 4    "target_url": "127.0.0.1:8080",
 5    "target_graph": "hugegraph",
 6    "target_create": "2020-11-12 09:34:13.848",
 7    "target_resources": [
 8        {
 9            "type": "NONE",
10            "label": "*",
11            "properties": null
12        }
13    ],
14    "id": "{target_id}",
15    "target_update": "2020-11-12 09:37:12.780"
16}

10.4.4 Query Resource List

Params
  • limit: Upper limit of the number of returned results.
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/targets
Response Status
1200
Response Body
 1{
 2    "targets": [
 3        {
 4            "target_creator": "admin",
 5            "target_name": "all",
 6            "target_url": "127.0.0.1:8080",
 7            "target_graph": "hugegraph",
 8            "target_create": "2020-11-11 15:32:01.192",
 9            "target_resources": [
10                {
11                    "type": "ALL",
12                    "label": "*",
13                    "properties": null
14                }
15            ],
16            "id": "{target_id}",
17            "target_update": "2020-11-11 15:32:01.192"
18        },
19        {
20            "target_creator": "admin",
21            "target_name": "grant",
22            "target_url": "127.0.0.1:8080",
23            "target_graph": "hugegraph",
24            "target_create": "2020-11-11 15:43:24.841",
25            "target_resources": [
26                {
27                    "type": "GRANT",
28                    "label": "*",
29                    "properties": null
30                }
31            ],
32            "id": "{another_target_id}",
33            "target_update": "2020-11-11 15:43:24.841"
34        }
35    ]
36}

10.4.5 Query a Specific Resource

Params
  • id: Id of the resource to query
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/targets/{target_id}
Response Status
1200
Response Body
 1{
 2    "target_creator": "admin",
 3    "target_name": "all",
 4    "target_url": "127.0.0.1:8080",
 5    "target_graph": "hugegraph",
 6    "target_create": "2020-11-11 15:32:01.192",
 7    "target_resources": [
 8        {
 9            "type": "ALL",
10            "label": "*",
11            "properties": null
12        }
13    ],
14    "id": "{target_id}",
15    "target_update": "2020-11-11 15:32:01.192"
16}

10.5 Association of Roles (Belong) API

The association between users and user groups allows a user to be associated with one or more user groups. User groups have permissions for related resources, and the permissions for different user groups can be understood as different roles. In other words, users are associated with roles.
The API for associating roles includes creating, deleting, modifying, and querying the association of roles for users.

Use your actual group ID from 10.3. For later requests, use the Belong response id and URL-encode > as %3E in URLs.

10.5.1 Create an Association of Roles for a User

Params
  • user: User ID
  • group: User group ID
  • belong_description: Description
Request Body
1{
2  "user": "boss",
3    "group": "{group_id}"
4}
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/auth/belongs
Response Status
1201 
Response Body
1{
2    "belong_create": "2020-11-11 16:19:35.422",
3    "belong_creator": "admin",
4    "belong_update": "2020-11-11 16:19:35.422",
5  "id": "{belong_id}",
6  "user": "boss",
7    "group": "{group_id}"
8}

10.5.2 Delete an Association of Roles

Params
  • id: ID of the association of roles to delete
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/auth/belongs/{belong_id}
Response Status
1204

10.5.3 Modify an Association of Roles

An association of roles can only be modified for its description. The user and group properties cannot be modified. If you need to modify an association of roles, you need to delete the existing association and create a new one.

Params
  • id: ID of the association of roles to modify
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/belongs/{belong_id}
Request Body

Modify the belong_description field

1{
2    "belong_description": "update test"
3}
Response Status
1200
Response Body

The response includes the modified content as well as the entire association of roles object

1{
2    "belong_description": "update test",
3    "belong_create": "2020-11-12 10:40:21.720",
4    "belong_creator": "admin",
5    "belong_update": "2020-11-12 10:42:47.265",
6  "id": "{belong_id}",
7  "user": "boss",
8    "group": "{group_id}"
9}

10.5.4 Query List of Associations of Roles

Params
  • user: Return only the associations of this user
  • group: Return only the associations of this group
  • limit: Upper limit on the number of results to return, default is 100

user and group can not be used together.

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/belongs
Response Status
1200
Response Body
 1{
 2    "belongs": [
 3        {
 4            "belong_create": "2020-11-11 16:19:35.422",
 5            "belong_creator": "admin",
 6            "belong_update": "2020-11-11 16:19:35.422",
 7          "id": "{belong_id}",
 8          "user": "boss",
 9            "group": "{group_id}"
10        }
11    ]
12}

10.5.5 View a Specific Association of Roles

Params
  • id: The id of the association of roles to be queried
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/belongs/{belong_id}
Response Status
1200
Response Body
1{
2    "belong_create": "2020-11-11 16:19:35.422",
3    "belong_creator": "admin",
4    "belong_update": "2020-11-11 16:19:35.422",
5  "id": "{belong_id}",
6  "user": "boss",
7    "group": "{group_id}"
8}

10.6 Authorization (Access) API

Grant permissions to user groups for resources, including operations such as READ, WRITE, DELETE, EXECUTE, etc. The authorization API includes: creating, deleting, modifying, and querying permissions.

Use your actual group ID from 10.3 and target ID from 10.4. For later requests, use the Access response id and URL-encode > as %3E in URLs.

10.6.1 Create Authorization (Granting permissions to user groups for resources)

Params
  • group: Group ID
  • target: Resource ID
  • access_permission: Permission grant
  • access_description: Authorization description

Access permissions:

  • READ: Read operations, including all queries such as querying the schema, retrieving vertices/edges, aggregating vertex and edge counts (VERTEX_AGGR/EDGE_AGGR), and reading the graph’s status (STATUS), variables (VAR), tasks (TASK), etc.
  • WRITE: Write operations, including creating and updating operations, such as adding property keys to the schema or adding/updating properties of vertices.
  • DELETE: Delete operations, including deleting metadata, vertices, or edges.
  • EXECUTE: Execute operations, including executing Gremlin queries, executing tasks, and executing metadata functions.
Request Body
1{
2    "group": "{group_id}",
3    "target": "{target_id}",
4    "access_permission": "READ"
5}
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/auth/accesses
Response Status
1201 
Response Body
1{
2    "access_permission": "READ",
3    "access_create": "2020-11-11 15:54:54.008",
4    "id": "{access_id}",
5    "access_update": "2020-11-11 15:54:54.008",
6    "access_creator": "admin",
7    "group": "{group_id}",
8    "target": "{target_id}"
9}

10.6.2 Delete Authorization

Params
  • id: The ID of the authorization to be deleted
Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/auth/accesses/{access_id}
Response Status
1204

10.6.3 Modify Authorization

Authorization can only be modified for its description. User group, resource, and permission cannot be modified. If you need to modify the authorization relationship, delete the original authorization and create a new one.

Params
  • id: The ID of the authorization to be modified
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/accesses/{access_id}
Request Body

Modify access_description

1{
2    "access_description": "test"
3}
Response Status
1200
Response Body

The response includes the modified content as well as the entire authorization object.

 1{
 2    "access_description": "test",
 3    "access_permission": "READ",
 4    "access_create": "2020-11-12 10:12:03.074",
 5    "id": "{access_id}",
 6    "access_update": "2020-11-12 10:16:18.637",
 7    "access_creator": "admin",
 8    "group": "{group_id}",
 9    "target": "{target_id}"
10}

10.6.4 Query Authorization List

Params
  • group: Return only the authorizations of this group
  • target: Return only the authorizations on this resource
  • limit: The maximum number of results to return, default is 100

group and target can not be used together.

Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/accesses
Response Status
1200
Response Body
 1{
 2    "accesses": [
 3        {
 4            "access_permission": "READ",
 5            "access_create": "2020-11-11 15:54:54.008",
 6            "id": "{access_id}",
 7            "access_update": "2020-11-11 15:54:54.008",
 8            "access_creator": "admin",
 9            "group": "{group_id}",
10            "target": "{target_id}"
11        }
12    ]
13}

10.6.5 Query a Specific Authorization

Params
  • id: The ID of the authorization to be queried
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/accesses/{access_id}
Response Status
1200
Response Body
1{
2    "access_permission": "READ",
3    "access_create": "2020-11-11 15:54:54.008",
4    "id": "{access_id}",
5    "access_update": "2020-11-11 15:54:54.008",
6    "access_creator": "admin",
7    "group": "{group_id}",
8    "target": "{target_id}"
9}

10.7 Graphspace Manager (Manager) API

Note: Before using the following APIs, you need to create a graphspace first. For example, create a graphspace named gs1 via the Graphspace API. The examples below assume that gs1 already exists.

Note: The manager APIs only work when the server runs in PD mode. In standalone mode they return 400 with the message GraphSpace management is not supported in standalone mode.

  1. The graphspace manager API is used to grant/revoke manager roles for users at the graphspace level, and to query the roles of the current user or other users in a graphspace. Supported role types include SPACE, SPACE_MEMBER, and ADMIN.

10.7.1 Check whether the current login user has a specific role

Params
  • type: Role type to check, required, one of SPACE, SPACE_MEMBER, ADMIN
Method & Url
1GET http://localhost:8080/graphspaces/gs1/auth/managers/check?type=SPACE_MEMBER
Response Status
1200
Response Body
1{
2  "check": true
3}

10.7.2 List graphspace managers

Params
  • type: Role type, required, one of SPACE, SPACE_MEMBER, ADMIN. SPACE lists the managers of the graphspace, SPACE_MEMBER lists its members, and ADMIN lists the administrators of the whole cluster.
Method & Url
1GET http://localhost:8080/graphspaces/gs1/auth/managers?type=SPACE
Response Status
1200
Response Body
1{
2  "admins": [
3    "admin"
4  ]
5}

10.7.3 Grant/create a graphspace manager

  • The following example grants user boss the SPACE_MEMBER role in graphspace gs1.
Params
  • user: User or group name, required
  • type: Role type, required, one of SPACE, SPACE_MEMBER, ADMIN

Granting SPACE to a user that is already a space member revokes the member role first, and the other way round. Only an administrator can grant ADMIN.

Request Body
1{
2  "user": "boss",
3  "type": "SPACE_MEMBER"
4}
Method & Url
1POST http://localhost:8080/graphspaces/gs1/auth/managers
Response Status
1201
Response Body
1{
2  "user": "boss",
3  "type": "SPACE_MEMBER",
4  "graphspace": "gs1"
5}

10.7.4 Revoke graphspace manager privileges

  • The following example revokes the SPACE_MEMBER role of user boss in graphspace gs1.
Params
  • user: User name to revoke. The built-in admin user can not be removed from ADMIN.
  • type: Role type to revoke, one of SPACE, SPACE_MEMBER, ADMIN
Method & Url
1DELETE http://localhost:8080/graphspaces/gs1/auth/managers?user=boss&type=SPACE_MEMBER
Response Status
1204

10.7.5 Query roles of a specific user in a graphspace

Params
  • user: User name
Method & Url
1GET http://localhost:8080/graphspaces/gs1/auth/managers/role?user=boss
Response Status
1200
Response Body

The returned roles are a subset of ADMIN, SPACE and SPACE_MEMBER; NONE is returned when the user holds none of them in this graphspace.

1{
2  "user": "boss",
3  "graphspace": "gs1",
4  "roles": [
5    "SPACE_MEMBER"
6  ]
7}

10.7.6 Check whether the current login user holds a default role

Default roles are the built-in roles of a graphspace, see Graphspace API. Valid role values are space, space_member, analyst and observer; graph is only taken into account for the observer role.

Params
  • role: Default role name, required
  • graph: Graph name, optional, only used with role=observer
Method & Url
1GET http://localhost:8080/graphspaces/gs1/auth/managers/default?role=analyst
Response Status
1200
Response Body
1{
2  "check": true
3}

10.8 Login (Login) API

Besides HTTP Basic authentication, the server can hand out a JWT token that is then passed as Authorization: Bearer <token>. The login endpoints are not scoped to a graphspace.

The token is signed with the auth.token_secret option and expires after auth.token_expire seconds (default 86400). The default secret is generated randomly at startup, so set it explicitly when tokens must stay valid across a restart or must be accepted by more than one server.

10.8.1 Log in and get a token

Params
  • user_name: User name, required
  • user_password: User password, required
  • token_expire: Token lifetime in seconds, optional
Request Body
1{
2    "user_name": "test",
3    "user_password": "******"
4}
Method & Url
1POST http://localhost:8080/auth/login
Response Status
1200

Wrong credentials return 401.

Response Body
1{
2    "token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJ0ZXN0IiwidXNlcl9pZCI6InRlc3QiLCJleHAiOjE3MTIxMjM0NTZ9.PBs0iBt0PtqvLDpJvKrPHkyIzT1TICz9zJmMy8FvXVo"
3}

10.8.2 Log out and invalidate the token

The token to invalidate is taken from the request header, no request body is needed.

Params

Request header

  • Authorization: Bearer <token>, required. Only the Bearer scheme is accepted, other schemes return 400.
Method & Url
1DELETE http://localhost:8080/auth/logout
Response Status
1204

An invalid or expired token returns 401.

10.8.3 Verify a token

Params

Request header

  • Authorization: Bearer <token>, required
Method & Url
1GET http://localhost:8080/auth/verify
Response Status
1200

An invalid or expired token returns 401.

Response Body
1{
2    "user_name": "test",
3    "user_id": "test"
4}

10.9 Project (Project) API

A project groups a set of graphs together with an admin group and an op group, so that permissions can be granted for the whole set at once. Creating a project also creates its project_target, project_admin_group and project_op_group, which are returned in the response but can not be set by the client.

10.9.1 Create Project

Params
  • project_name: Project name, required
  • project_description: Project description, optional

project_graphs can not be passed on creation, use the add_graph action below.

Request Body
1{
2    "project_name": "test_project",
3    "project_description": "this is a good project"
4}
Method & Url
1POST http://localhost:8080/graphspaces/DEFAULT/auth/projects
Response Status
1201
Response Body
 1{
 2    "project_name": "test_project",
 3    "project_description": "this is a good project",
 4    "project_target": "project_test_project",
 5    "project_admin_group": "project_test_project_admin",
 6    "project_op_group": "project_test_project_op",
 7    "project_create": "2024-01-10 09:30:00.000",
 8    "project_update": "2024-01-10 09:30:00.000",
 9    "project_creator": "admin",
10    "id": "test_project"
11}

10.9.2 Add graphs to or remove graphs from a project

Params
  • id: Project ID
  • action: add_graph to add graphs, remove_graph to remove them
Request Body
1{
2    "project_graphs": [
3        "hugegraph"
4    ]
5}
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/projects/test_project?action=add_graph
Response Status
1200
Response Body

The whole project object is returned, including the updated graph list.

10.9.3 Modify the description of a project

Params
  • id: Project ID

Leave action out to update the description. project_graphs must not be present in this case.

Request Body
1{
2    "project_description": "update desc"
3}
Method & Url
1PUT http://localhost:8080/graphspaces/DEFAULT/auth/projects/test_project
Response Status
1200

10.9.4 Query Project List

Params
  • limit: The maximum number of results to return, default is 100
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/projects
Response Status
1200
Response Body
 1{
 2    "projects": [
 3        {
 4            "project_name": "test_project",
 5            "project_description": "this is a good project",
 6            "project_target": "project_test_project",
 7            "project_admin_group": "project_test_project_admin",
 8            "project_op_group": "project_test_project_op",
 9            "project_create": "2024-01-10 09:30:00.000",
10            "project_update": "2024-01-10 09:30:00.000",
11            "project_creator": "admin",
12            "id": "test_project"
13        }
14    ]
15}

10.9.5 Query a Specific Project

Params
  • id: Project ID
Method & Url
1GET http://localhost:8080/graphspaces/DEFAULT/auth/projects/test_project
Response Status
1200

10.9.6 Delete Project

Params
  • id: Project ID

Remove all graphs from the project before deleting it.

Method & Url
1DELETE http://localhost:8080/graphspaces/DEFAULT/auth/projects/test_project
Response Status
1204

18 - Metrics API

Metrics REST API: Retrieve runtime performance metrics, statistics, and health status data of the system.

HugeGraph provides a metrics interface for obtaining monitoring information, such as statistics on each Gremlin execution time, cache size, etc. The metrics interface includes the following categories: basic metrics, statistical metrics, system metrics, and backend storage metrics.

1. Basic Metrics

1.1 Get All Basic Metrics

Params
  • type: If the passed value is json, it is returned in json format, otherwise it is returned in Promethaus format.
1.1.1 Method & Url
1http://localhost:8080/metrics/?type=json
Response Status
1200
Response Body
  1{
  2  "gauges": {
  3    "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.capacity": {
  4      "value": 1000000
  5    },
  6    "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.expire": {
  7      "value": 600000
  8    },
  9    "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.hits": {
 10      "value": 0
 11    },
 12    "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.miss": {
 13      "value": 0
 14    },
 15    "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.size": {
 16      "value": 0
 17    },
 18    "org.apache.hugegraph.backend.cache.Cache.instances": {
 19      "value": 7
 20    },
 21    "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.capacity": {
 22      "value": 10000
 23    },
 24    "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.expire": {
 25      "value": 0
 26    },
 27    "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.hits": {
 28      "value": 0
 29    },
 30    "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.miss": {
 31      "value": 0
 32    },
 33    "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.size": {
 34      "value": 17
 35    },
 36    "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.capacity": {
 37      "value": 10000
 38    },
 39    "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.expire": {
 40      "value": 0
 41    },
 42    "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.hits": {
 43      "value": 0
 44    },
 45    "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.miss": {
 46      "value": 0
 47    },
 48    "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.size": {
 49      "value": 17
 50    },
 51    "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.capacity": {
 52      "value": 10240
 53    },
 54    "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.expire": {
 55      "value": 600000
 56    },
 57    "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.hits": {
 58      "value": 0
 59    },
 60    "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.miss": {
 61      "value": 0
 62    },
 63    "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.size": {
 64      "value": 0
 65    },
 66    "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.capacity": {
 67      "value": 10240
 68    },
 69    "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.expire": {
 70      "value": 600000
 71    },
 72    "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.hits": {
 73      "value": 0
 74    },
 75    "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.miss": {
 76      "value": 0
 77    },
 78    "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.size": {
 79      "value": 0
 80    },
 81    "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.capacity": {
 82      "value": 10240
 83    },
 84    "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.expire": {
 85      "value": 600000
 86    },
 87    "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.hits": {
 88      "value": 0
 89    },
 90    "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.miss": {
 91      "value": 0
 92    },
 93    "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.size": {
 94      "value": 0
 95    },
 96    "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.capacity": {
 97      "value": 10000000
 98    },
 99    "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.expire": {
100      "value": 600000
101    },
102    "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.hits": {
103      "value": 0
104    },
105    "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.miss": {
106      "value": 0
107    },
108    "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.size": {
109      "value": 0
110    },
111    "org.apache.hugegraph.server.RestServer.max-write-threads": {
112      "value": 0
113    },
114    "org.apache.hugegraph.task.TaskManager.pending-tasks": {
115      "value": 0
116    },
117    "org.apache.hugegraph.task.TaskManager.workers": {
118      "value": 4
119    },
120    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.average-load-penalty": {
121      "value": 922769200
122    },
123    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.estimated-size": {
124      "value": 2
125    },
126    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.eviction-count": {
127      "value": 0
128    },
129    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.eviction-weight": {
130      "value": 0
131    },
132    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.hit-count": {
133      "value": 0
134    },
135    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.hit-rate": {
136      "value": 0
137    },
138    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-count": {
139      "value": 2
140    },
141    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-failure-count": {
142      "value": 0
143    },
144    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-failure-rate": {
145      "value": 0
146    },
147    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-success-count": {
148      "value": 2
149    },
150    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.long-run-compilation-count": {
151      "value": 0
152    },
153    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.miss-count": {
154      "value": 2
155    },
156    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.miss-rate": {
157      "value": 1
158    },
159    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.request-count": {
160      "value": 2
161    },
162    "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.total-load-time": {
163      "value": 1845538400
164    },
165    "org.apache.tinkerpop.gremlin.server.GremlinServer.sessions": {
166      "value": 0
167    }
168  },
169  "counters": {
170    "favicon.ico/GET/FAILED_COUNTER": {
171      "count": 1
172    },
173    "favicon.ico/GET/TOTAL_COUNTER": {
174      "count": 1
175    },
176    "metrics/POST/FAILED_COUNTER": {
177      "count": 1
178    },
179    "metrics/POST/TOTAL_COUNTER": {
180      "count": 1
181    },
182    "metrics/backend/GET/SUCCESS_COUNTER": {
183      "count": 2
184    },
185    "metrics/backend/GET/TOTAL_COUNTER": {
186      "count": 2
187    },
188    "metrics/gauges/GET/SUCCESS_COUNTER": {
189      "count": 1
190    },
191    "metrics/gauges/GET/TOTAL_COUNTER": {
192      "count": 1
193    },
194    "metrics/system/GET/SUCCESS_COUNTER": {
195      "count": 2
196    },
197    "metrics/system/GET/TOTAL_COUNTER": {
198      "count": 2
199    },
200    "system/GET/FAILED_COUNTER": {
201      "count": 1
202    },
203    "system/GET/TOTAL_COUNTER": {
204      "count": 1
205    }
206  },
207  "histograms": {
208    "favicon.ico/GET/RESPONSE_TIME_HISTOGRAM": {
209      "count": 1,
210      "min": 1,
211      "mean": 1,
212      "max": 1,
213      "stddev": 0,
214      "p50": 1,
215      "p75": 1,
216      "p95": 1,
217      "p98": 1,
218      "p99": 1,
219      "p999": 1
220    },
221    "metrics/POST/RESPONSE_TIME_HISTOGRAM": {
222      "count": 1,
223      "min": 21,
224      "mean": 21,
225      "max": 21,
226      "stddev": 0,
227      "p50": 21,
228      "p75": 21,
229      "p95": 21,
230      "p98": 21,
231      "p99": 21,
232      "p999": 21
233    },
234    "metrics/backend/GET/RESPONSE_TIME_HISTOGRAM": {
235      "count": 2,
236      "min": 6,
237      "mean": 12.6852124529148,
238      "max": 20,
239      "stddev": 6.992918475157571,
240      "p50": 6,
241      "p75": 20,
242      "p95": 20,
243      "p98": 20,
244      "p99": 20,
245      "p999": 20
246    },
247    "metrics/gauges/GET/RESPONSE_TIME_HISTOGRAM": {
248      "count": 1,
249      "min": 7,
250      "mean": 7,
251      "max": 7,
252      "stddev": 0,
253      "p50": 7,
254      "p75": 7,
255      "p95": 7,
256      "p98": 7,
257      "p99": 7,
258      "p999": 7
259    },
260    "metrics/system/GET/RESPONSE_TIME_HISTOGRAM": {
261      "count": 2,
262      "min": 0,
263      "mean": 8.942674506664073,
264      "max": 40,
265      "stddev": 16.665399873223066,
266      "p50": 0,
267      "p75": 0,
268      "p95": 40,
269      "p98": 40,
270      "p99": 40,
271      "p999": 40
272    },
273    "system/GET/RESPONSE_TIME_HISTOGRAM": {
274      "count": 1,
275      "min": 2,
276      "mean": 2,
277      "max": 2,
278      "stddev": 0,
279      "p50": 2,
280      "p75": 2,
281      "p95": 2,
282      "p98": 2,
283      "p99": 2,
284      "p999": 2
285    }
286  },
287  "meters": {
288    "org.apache.hugegraph.api.API.commit-succeed": {
289      "count": 0,
290      "mean_rate": 0,
291      "m15_rate": 0,
292      "m5_rate": 0,
293      "m1_rate": 0,
294      "rate_unit": "events/second"
295    },
296    "org.apache.hugegraph.api.API.expected-error": {
297      "count": 0,
298      "mean_rate": 0,
299      "m15_rate": 0,
300      "m5_rate": 0,
301      "m1_rate": 0,
302      "rate_unit": "events/second"
303    },
304    "org.apache.hugegraph.api.API.illegal-arg": {
305      "count": 0,
306      "mean_rate": 0,
307      "m15_rate": 0,
308      "m5_rate": 0,
309      "m1_rate": 0,
310      "rate_unit": "events/second"
311    },
312    "org.apache.hugegraph.api.API.unknown-error": {
313      "count": 0,
314      "mean_rate": 0,
315      "m15_rate": 0,
316      "m5_rate": 0,
317      "m1_rate": 0,
318      "rate_unit": "events/second"
319    },
320    "org.apache.tinkerpop.gremlin.server.GremlinServer.errors": {
321      "count": 0,
322      "mean_rate": 0,
323      "m15_rate": 0,
324      "m5_rate": 0,
325      "m1_rate": 0,
326      "rate_unit": "events/second"
327    }
328  },
329  "timers": {
330    "org.apache.hugegraph.api.auth.AccessAPI.create": {
331      "count": 0,
332      "min": 0,
333      "mean": 0,
334      "max": 0,
335      "stddev": 0,
336      "p50": 0,
337      "p75": 0,
338      "p95": 0,
339      "p98": 0,
340      "p99": 0,
341      "p999": 0,
342      "duration_unit": "milliseconds",
343      "mean_rate": 0,
344      "m15_rate": 0,
345      "m5_rate": 0,
346      "m1_rate": 0,
347      "rate_unit": "calls/second"
348    },
349    "org.apache.hugegraph.api.auth.AccessAPI.delete": {
350      "count": 0,
351      "min": 0,
352      "mean": 0,
353      "max": 0,
354      "stddev": 0,
355      "p50": 0,
356      "p75": 0,
357      "p95": 0,
358      "p98": 0,
359      "p99": 0,
360      "p999": 0,
361      "duration_unit": "milliseconds",
362      "mean_rate": 0,
363      "m15_rate": 0,
364      "m5_rate": 0,
365      "m1_rate": 0,
366      "rate_unit": "calls/second"
367    },
368    "org.apache.hugegraph.api.auth.AccessAPI.get": {
369      "count": 0,
370      "min": 0,
371      "mean": 0,
372      "max": 0,
373      "stddev": 0,
374      "p50": 0,
375      "p75": 0,
376      "p95": 0,
377      "p98": 0,
378      "p99": 0,
379      "p999": 0,
380      "duration_unit": "milliseconds",
381      "mean_rate": 0,
382      "m15_rate": 0,
383      "m5_rate": 0,
384      "m1_rate": 0,
385      "rate_unit": "calls/second"
386    },
387    "org.apache.hugegraph.api.auth.AccessAPI.list": {
388      "count": 0,
389      "min": 0,
390      "mean": 0,
391      "max": 0,
392      "stddev": 0,
393      "p50": 0,
394      "p75": 0,
395      "p95": 0,
396      "p98": 0,
397      "p99": 0,
398      "p999": 0,
399      "duration_unit": "milliseconds",
400      "mean_rate": 0,
401      "m15_rate": 0,
402      "m5_rate": 0,
403      "m1_rate": 0,
404      "rate_unit": "calls/second"
405    },
406    ...
407  }
408}
1.1.2 Method & Url
1http://localhost:8080/metrics/
Response Status
1200
Response Body
 1# HELP hugegraph_info
 2# TYPE hugegraph_info untyped
 3hugegraph_info{version="0.69",
 4} 1.0
 5# HELP org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_capacity
 6# TYPE org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_capacity gauge
 7org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_capacity 1000000
 8# HELP org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_expire
 9# TYPE org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_expire gauge
10org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_expire 600000
11# HELP org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_hits
12# TYPE org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_hits gauge
13org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_hits 0
14# HELP org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_miss
15# TYPE org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_miss gauge
16org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_miss 0
17# HELP org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_size
18# TYPE org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_size gauge
19org_apache_hugegraph_backend_cache_Cache_edge_hugegraph_size 0
20# HELP org_apache_hugegraph_backend_cache_Cache_instances
21# TYPE org_apache_hugegraph_backend_cache_Cache_instances gauge
22org_apache_hugegraph_backend_cache_Cache_instances 7
23# HELP org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_capacity
24# TYPE org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_capacity gauge
25org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_capacity 10000
26# HELP org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_expire
27# TYPE org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_expire gauge
28org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_expire 0
29# HELP org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_hits
30# TYPE org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_hits gauge
31org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_hits 0
32# HELP org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_miss
33# TYPE org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_miss gauge
34org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_miss 0
35# HELP org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_size
36# TYPE org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_size gauge
37org_apache_hugegraph_backend_cache_Cache_schema_id_hugegraph_size 17
38# HELP org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_capacity
39# TYPE org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_capacity gauge
40org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_capacity 10000
41# HELP org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_expire
42# TYPE org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_expire gauge
43org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_expire 0
44# HELP org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_hits
45# TYPE org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_hits gauge
46org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_hits 0
47# HELP org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_miss
48# TYPE org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_miss gauge
49org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_miss 0
50# HELP org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_size
51# TYPE org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_size gauge
52org_apache_hugegraph_backend_cache_Cache_schema_name_hugegraph_size 17
53...

1.2 Get Gauges Metrics

Method & Url
1http://localhost:8080/metrics/gauges
Response Status
1200
Response Body
  1{
  2  "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.capacity": {
  3    "value": 1000000
  4  },
  5  "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.expire": {
  6    "value": 600000
  7  },
  8  "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.hits": {
  9    "value": 0
 10  },
 11  "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.miss": {
 12    "value": 0
 13  },
 14  "org.apache.hugegraph.backend.cache.Cache.edge-hugegraph.size": {
 15    "value": 0
 16  },
 17  "org.apache.hugegraph.backend.cache.Cache.instances": {
 18    "value": 7
 19  },
 20  "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.capacity": {
 21    "value": 10000
 22  },
 23  "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.expire": {
 24    "value": 0
 25  },
 26  "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.hits": {
 27    "value": 0
 28  },
 29  "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.miss": {
 30    "value": 0
 31  },
 32  "org.apache.hugegraph.backend.cache.Cache.schema-id-hugegraph.size": {
 33    "value": 17
 34  },
 35  "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.capacity": {
 36    "value": 10000
 37  },
 38  "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.expire": {
 39    "value": 0
 40  },
 41  "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.hits": {
 42    "value": 0
 43  },
 44  "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.miss": {
 45    "value": 0
 46  },
 47  "org.apache.hugegraph.backend.cache.Cache.schema-name-hugegraph.size": {
 48    "value": 17
 49  },
 50  "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.capacity": {
 51    "value": 10240
 52  },
 53  "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.expire": {
 54    "value": 600000
 55  },
 56  "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.hits": {
 57    "value": 0
 58  },
 59  "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.miss": {
 60    "value": 0
 61  },
 62  "org.apache.hugegraph.backend.cache.Cache.token-hugegraph.size": {
 63    "value": 0
 64  },
 65  "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.capacity": {
 66    "value": 10240
 67  },
 68  "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.expire": {
 69    "value": 600000
 70  },
 71  "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.hits": {
 72    "value": 0
 73  },
 74  "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.miss": {
 75    "value": 0
 76  },
 77  "org.apache.hugegraph.backend.cache.Cache.users-hugegraph.size": {
 78    "value": 0
 79  },
 80  "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.capacity": {
 81    "value": 10240
 82  },
 83  "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.expire": {
 84    "value": 600000
 85  },
 86  "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.hits": {
 87    "value": 0
 88  },
 89  "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.miss": {
 90    "value": 0
 91  },
 92  "org.apache.hugegraph.backend.cache.Cache.users_pwd-hugegraph.size": {
 93    "value": 0
 94  },
 95  "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.capacity": {
 96    "value": 10000000
 97  },
 98  "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.expire": {
 99    "value": 600000
100  },
101  "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.hits": {
102    "value": 0
103  },
104  "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.miss": {
105    "value": 0
106  },
107  "org.apache.hugegraph.backend.cache.Cache.vertex-hugegraph.size": {
108    "value": 0
109  },
110  "org.apache.hugegraph.server.RestServer.max-write-threads": {
111    "value": 0
112  },
113  "org.apache.hugegraph.task.TaskManager.pending-tasks": {
114    "value": 0
115  },
116  "org.apache.hugegraph.task.TaskManager.workers": {
117    "value": 4
118  },
119  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.average-load-penalty": {
120    "value": 9.227692E8
121  },
122  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.estimated-size": {
123    "value": 2
124  },
125  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.eviction-count": {
126    "value": 0
127  },
128  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.eviction-weight": {
129    "value": 0
130  },
131  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.hit-count": {
132    "value": 0
133  },
134  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.hit-rate": {
135    "value": 0.0
136  },
137  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-count": {
138    "value": 2
139  },
140  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-failure-count": {
141    "value": 0
142  },
143  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-failure-rate": {
144    "value": 0.0
145  },
146  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.load-success-count": {
147    "value": 2
148  },
149  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.long-run-compilation-count": {
150    "value": 0
151  },
152  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.miss-count": {
153    "value": 2
154  },
155  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.miss-rate": {
156    "value": 1.0
157  },
158  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.request-count": {
159    "value": 2
160  },
161  "org.apache.tinkerpop.gremlin.server.GremlinServer.gremlin-groovy.sessionless.class-cache.total-load-time": {
162    "value": 1845538400
163  },
164  "org.apache.tinkerpop.gremlin.server.GremlinServer.sessions": {
165    "value": 0
166  }
167}

1.3 Get Counters Metrics

Method & Url
1GET http://localhost:8080/metrics/counters
Response Status
1200
Response Body
 1{
 2  "favicon.ico/GET/FAILED_COUNTER": {
 3    "count": 1
 4  },
 5  "favicon.ico/GET/TOTAL_COUNTER": {
 6    "count": 1
 7  },
 8  "metrics//GET/SUCCESS_COUNTER": {
 9    "count": 2
10  },
11  "metrics//GET/TOTAL_COUNTER": {
12    "count": 2
13  },
14  "metrics/POST/FAILED_COUNTER": {
15    "count": 1
16  },
17  "metrics/POST/TOTAL_COUNTER": {
18    "count": 1
19  },
20  "metrics/backend/GET/SUCCESS_COUNTER": {
21    "count": 2
22  },
23  "metrics/backend/GET/TOTAL_COUNTER": {
24    "count": 2
25  },
26  "metrics/gauges/GET/SUCCESS_COUNTER": {
27    "count": 1
28  },
29  "metrics/gauges/GET/TOTAL_COUNTER": {
30    "count": 1
31  },
32  "metrics/statistics/GET/SUCCESS_COUNTER": {
33    "count": 2
34  },
35  "metrics/statistics/GET/TOTAL_COUNTER": {
36    "count": 2
37  },
38  "metrics/system/GET/SUCCESS_COUNTER": {
39    "count": 2
40  },
41  "metrics/system/GET/TOTAL_COUNTER": {
42    "count": 2
43  },
44  "metrics/timers/GET/SUCCESS_COUNTER": {
45    "count": 1
46  },
47  "metrics/timers/GET/TOTAL_COUNTER": {
48    "count": 1
49  },
50  "system/GET/FAILED_COUNTER": {
51    "count": 1
52  },
53  "system/GET/TOTAL_COUNTER": {
54    "count": 1
55  }
56}

1.4 Get Histograms Metrics

Method & Url
1GET http://localhost:8080/metrics/gauges
Response Status
1200
Response Body
  1{
  2  "favicon.ico/GET/RESPONSE_TIME_HISTOGRAM": {
  3    "count": 1,
  4    "min": 1,
  5    "mean": 1.0,
  6    "max": 1,
  7    "stddev": 0.0,
  8    "p50": 1.0,
  9    "p75": 1.0,
 10    "p95": 1.0,
 11    "p98": 1.0,
 12    "p99": 1.0,
 13    "p999": 1.0
 14  },
 15  "metrics//GET/RESPONSE_TIME_HISTOGRAM": {
 16    "count": 2,
 17    "min": 10,
 18    "mean": 10.0,
 19    "max": 10,
 20    "stddev": 0.0,
 21    "p50": 10.0,
 22    "p75": 10.0,
 23    "p95": 10.0,
 24    "p98": 10.0,
 25    "p99": 10.0,
 26    "p999": 10.0
 27  },
 28  "metrics/POST/RESPONSE_TIME_HISTOGRAM": {
 29    "count": 1,
 30    "min": 21,
 31    "mean": 21.0,
 32    "max": 21,
 33    "stddev": 0.0,
 34    "p50": 21.0,
 35    "p75": 21.0,
 36    "p95": 21.0,
 37    "p98": 21.0,
 38    "p99": 21.0,
 39    "p999": 21.0
 40  },
 41  "metrics/backend/GET/RESPONSE_TIME_HISTOGRAM": {
 42    "count": 2,
 43    "min": 6,
 44    "mean": 12.6852124529148,
 45    "max": 20,
 46    "stddev": 6.992918475157571,
 47    "p50": 6.0,
 48    "p75": 20.0,
 49    "p95": 20.0,
 50    "p98": 20.0,
 51    "p99": 20.0,
 52    "p999": 20.0
 53  },
 54  "metrics/gauges/GET/RESPONSE_TIME_HISTOGRAM": {
 55    "count": 1,
 56    "min": 7,
 57    "mean": 7.0,
 58    "max": 7,
 59    "stddev": 0.0,
 60    "p50": 7.0,
 61    "p75": 7.0,
 62    "p95": 7.0,
 63    "p98": 7.0,
 64    "p99": 7.0,
 65    "p999": 7.0
 66  },
 67  "metrics/statistics/GET/RESPONSE_TIME_HISTOGRAM": {
 68    "count": 2,
 69    "min": 1,
 70    "mean": 1.4551211076264199,
 71    "max": 2,
 72    "stddev": 0.49798181193626,
 73    "p50": 1.0,
 74    "p75": 2.0,
 75    "p95": 2.0,
 76    "p98": 2.0,
 77    "p99": 2.0,
 78    "p999": 2.0
 79  },
 80  "metrics/system/GET/RESPONSE_TIME_HISTOGRAM": {
 81    "count": 2,
 82    "min": 0,
 83    "mean": 8.942674506664073,
 84    "max": 40,
 85    "stddev": 16.665399873223066,
 86    "p50": 0.0,
 87    "p75": 0.0,
 88    "p95": 40.0,
 89    "p98": 40.0,
 90    "p99": 40.0,
 91    "p999": 40.0
 92  },
 93  "metrics/timers/GET/RESPONSE_TIME_HISTOGRAM": {
 94    "count": 1,
 95    "min": 3,
 96    "mean": 3.0,
 97    "max": 3,
 98    "stddev": 0.0,
 99    "p50": 3.0,
100    "p75": 3.0,
101    "p95": 3.0,
102    "p98": 3.0,
103    "p99": 3.0,
104    "p999": 3.0
105  },
106  "system/GET/RESPONSE_TIME_HISTOGRAM": {
107    "count": 1,
108    "min": 2,
109    "mean": 2.0,
110    "max": 2,
111    "stddev": 0.0,
112    "p50": 2.0,
113    "p75": 2.0,
114    "p95": 2.0,
115    "p98": 2.0,
116    "p99": 2.0,
117    "p999": 2.0
118  }
119}

1.5 Get Meters Metrics

Method & Url
1GET http://localhost:8080/metrics/meters
Response Status
1200
Response Body
 1{
 2  "org.apache.hugegraph.api.API.commit-succeed": {
 3    "count": 0,
 4    "mean_rate": 0.0,
 5    "m15_rate": 0.0,
 6    "m5_rate": 0.0,
 7    "m1_rate": 0.0,
 8    "rate_unit": "events/second"
 9  },
10  "org.apache.hugegraph.api.API.expected-error": {
11    "count": 0,
12    "mean_rate": 0.0,
13    "m15_rate": 0.0,
14    "m5_rate": 0.0,
15    "m1_rate": 0.0,
16    "rate_unit": "events/second"
17  },
18  "org.apache.hugegraph.api.API.illegal-arg": {
19    "count": 0,
20    "mean_rate": 0.0,
21    "m15_rate": 0.0,
22    "m5_rate": 0.0,
23    "m1_rate": 0.0,
24    "rate_unit": "events/second"
25  },
26  "org.apache.hugegraph.api.API.unknown-error": {
27    "count": 0,
28    "mean_rate": 0.0,
29    "m15_rate": 0.0,
30    "m5_rate": 0.0,
31    "m1_rate": 0.0,
32    "rate_unit": "events/second"
33  },
34  "org.apache.tinkerpop.gremlin.server.GremlinServer.errors": {
35    "count": 0,
36    "mean_rate": 0.0,
37    "m15_rate": 0.0,
38    "m5_rate": 0.0,
39    "m1_rate": 0.0,
40    "rate_unit": "events/second"
41  }
42}

1.6 Get Timers Metrics

Method & Url
1GET http://localhost:8080/metrics/timers
Response Status
1200
Response Body
 1{
 2  "org.apache.hugegraph.api.auth.AccessAPI.create": {
 3    "count": 0,
 4    "min": 0.0,
 5    "mean": 0.0,
 6    "max": 0.0,
 7    "stddev": 0.0,
 8    "p50": 0.0,
 9    "p75": 0.0,
10    "p95": 0.0,
11    "p98": 0.0,
12    "p99": 0.0,
13    "p999": 0.0,
14    "duration_unit": "milliseconds",
15    "mean_rate": 0.0,
16    "m15_rate": 0.0,
17    "m5_rate": 0.0,
18    "m1_rate": 0.0,
19    "rate_unit": "calls/second"
20  },
21  "org.apache.hugegraph.api.auth.AccessAPI.delete": {
22    "count": 0,
23    "min": 0.0,
24    "mean": 0.0,
25    "max": 0.0,
26    "stddev": 0.0,
27    "p50": 0.0,
28    "p75": 0.0,
29    "p95": 0.0,
30    "p98": 0.0,
31    "p99": 0.0,
32    "p999": 0.0,
33    "duration_unit": "milliseconds",
34    "mean_rate": 0.0,
35    "m15_rate": 0.0,
36    "m5_rate": 0.0,
37    "m1_rate": 0.0,
38    "rate_unit": "calls/second"
39  },
40  ...
41}

2.Statistical Metrics

Params
  • type: If the passed value is JSON, it is returned in JSON format, otherwise it is returned in Promethaus format.
2.1 Method & Url
1GET http://localhost:8080/metrics/statistics
Response Status
 1# HELP hugegraph_info
 2# TYPE hugegraph_info untyped
 3hugegraph_info{version="0.69",
 4} 1.0
 5# HELP metrics_POST
 6# TYPE metrics_POST gauge
 7metrics_POST{name=FAILED_REQUEST,} 1
 8metrics_POST{name=MEAN_RESPONSE_TIME,} 21.0
 9metrics_POST{
10name=MAX_RESPONSE_TIME,
11} 21
12metrics_POST{name=SUCCESS_REQUEST,
13} 0
14metrics_POST{
15name=TOTAL_REQUEST,
16} 1
17# HELP metrics_backend_GET
18# TYPE metrics_backend_GET gauge
19metrics_backend_GET{name=FAILED_REQUEST,
20} 0
21metrics_backend_GET{
22name=MEAN_RESPONSE_TIME,
23} 12.6852124529148
24metrics_backend_GET{
25name=MAX_RESPONSE_TIME,
26} 20
27metrics_backend_GET{
28name=SUCCESS_REQUEST,
29} 2
30metrics_backend_GET{name=TOTAL_REQUEST,} 2
31# HELP system_GET
32# TYPE system_GET gauge
33system_GET{name=FAILED_REQUEST,} 1
34system_GET{name=MEAN_RESPONSE_TIME,} 2.0
35system_GET{name=MAX_RESPONSE_TIME,} 2
36system_GET{
37name=SUCCESS_REQUEST,
38} 0
39system_GET{name=TOTAL_REQUEST,
40} 1
41# HELP metrics_gauges_GET
42# TYPE metrics_gauges_GET gauge
43metrics_gauges_GET{name=FAILED_REQUEST,} 0
44metrics_gauges_GET{name=MEAN_RESPONSE_TIME,
45} 7.0
46metrics_gauges_GET{
47name=MAX_RESPONSE_TIME,
48} 7
49metrics_gauges_GET{
50name=SUCCESS_REQUEST,
51} 1
52metrics_gauges_GET{
53name=TOTAL_REQUEST,
54} 1
55# HELP favicon.ico_GET
56# TYPE favicon.ico_GET gauge
57favicon.ico_GET{name=FAILED_REQUEST,
58} 1
59favicon.ico_GET{
60name=MEAN_RESPONSE_TIME,
61} 1.0
62favicon.ico_GET{name=MAX_RESPONSE_TIME,} 1
63favicon.ico_GET{name=SUCCESS_REQUEST,} 0
64favicon.ico_GET{
65name=TOTAL_REQUEST,
66} 1
67# HELP metrics__GET
68# TYPE metrics__GET gauge
69metrics__GET{name=FAILED_REQUEST,} 0
70metrics__GET{name=MEAN_RESPONSE_TIME,} 10.0
71metrics__GET{name=MAX_RESPONSE_TIME,
72} 10
73metrics__GET{
74name=SUCCESS_REQUEST,
75} 2
76metrics__GET{
77name=TOTAL_REQUEST,
78} 2
79# HELP metrics_system_GET
80# TYPE metrics_system_GET gauge
81metrics_system_GET{name=FAILED_REQUEST,} 0
82metrics_system_GET{name=MEAN_RESPONSE_TIME,
83} 8.942674506664073
84metrics_system_GET{
85name=MAX_RESPONSE_TIME,
86} 40
87metrics_system_GET{name=SUCCESS_REQUEST,} 2
88metrics_system_GET{name=TOTAL_REQUEST,
89} 2
Response Body
1200
2.2 Method & Url
1GET http://localhost:8080/metrics/statistics?type=json
Response Status
1200
Response Body
 1{
 2  "metrics/POST": {
 3    "FAILED_REQUEST": 1,
 4    "MEAN_RESPONSE_TIME": 21,
 5    "MAX_RESPONSE_TIME": 21,
 6    "SUCCESS_REQUEST": 0,
 7    "TOTAL_REQUEST": 1
 8  },
 9  "metrics/backend/GET": {
10    "FAILED_REQUEST": 0,
11    "MEAN_RESPONSE_TIME": 12.6852124529148,
12    "MAX_RESPONSE_TIME": 20,
13    "SUCCESS_REQUEST": 2,
14    "TOTAL_REQUEST": 2
15  },
16  "system/GET": {
17    "FAILED_REQUEST": 1,
18    "MEAN_RESPONSE_TIME": 2,
19    "MAX_RESPONSE_TIME": 2,
20    "SUCCESS_REQUEST": 0,
21    "TOTAL_REQUEST": 1
22  },
23  "metrics/gauges/GET": {
24    "FAILED_REQUEST": 0,
25    "MEAN_RESPONSE_TIME": 7,
26    "MAX_RESPONSE_TIME": 7,
27    "SUCCESS_REQUEST": 1,
28    "TOTAL_REQUEST": 1
29  },
30  "favicon.ico/GET": {
31    "FAILED_REQUEST": 1,
32    "MEAN_RESPONSE_TIME": 1,
33    "MAX_RESPONSE_TIME": 1,
34    "SUCCESS_REQUEST": 0,
35    "TOTAL_REQUEST": 1
36  },
37  "metrics//GET": {
38    "FAILED_REQUEST": 0,
39    "MEAN_RESPONSE_TIME": 10,
40    "MAX_RESPONSE_TIME": 10,
41    "SUCCESS_REQUEST": 2,
42    "TOTAL_REQUEST": 2
43  },
44  "metrics/system/GET": {
45    "FAILED_REQUEST": 0,
46    "MEAN_RESPONSE_TIME": 8.942674506664073,
47    "MAX_RESPONSE_TIME": 40,
48    "SUCCESS_REQUEST": 2,
49    "TOTAL_REQUEST": 2
50  }
51}

3.System Metrics

System metrics mainly return the machine metrics, such as memory, threads, and other information.

Method & Url
1GET http://localhost:8080/metrics/system
Response Status
1200
Response Body
 1{
 2  "basic": {
 3    "mem": 1010,
 4    "mem_total": 911,
 5    "mem_used": 239,
 6    "mem_free": 671,
 7    "mem_unit": "MB",
 8    "processors": 20,
 9    "uptime": 137503,
10    "systemload_average": -1.0
11  },
12  "heap": {
13    "committed": 911,
14    "init": 254,
15    "used": 239,
16    "max": 3596
17  },
18  "nonheap": {
19    "committed": 98,
20    "init": 2,
21    "used": 95,
22    "max": 0
23  },
24  "thread": {
25    "peak": 82,
26    "daemon": 34,
27    "total_started": 108,
28    "count": 82
29  },
30  "class_loading": {
31    "count": 11495,
32    "loaded": 11495,
33    "unloaded": 0
34  },
35  "garbage_collector": {
36    "ps_scavenge_count": 16,
37    "ps_scavenge_time": 155,
38    "ps_marksweep_count": 3,
39    "ps_marksweep_time": 494,
40    "time_unit": "ms"
41  }
42}

4.Backend Metrics

HugeGraph supports multiple backend storage, with backend metrics including memory, disk, and other information.

Method & Url
1GET http://localhost:8080/metrics/backend
Response Status
1200
Response Body
 1{
 2  "hugegraph": {
 3    "backend": "rocksdb",
 4    "nodes": 1,
 5    "cluster_id": "local",
 6    "servers": {
 7      "local": {
 8        "mem_unit": "MB",
 9        "disk_unit": "GB",
10        "mem_used": 0.1,
11        "mem_used_readable": "103.53 KB",
12        "disk_usage": 0.03,
13        "disk_usage_readable": "29.03 KB",
14        "block_cache_usage": 0.00359344482421875,
15        "block_cache_pinned_usage": 0.00359344482421875,
16        "block_cache_capacity": 304.0,
17        "estimate_table_readers_mem": 0.019697189331054688,
18        "size_all_mem_tables": 0.07421875,
19        "cur_size_all_mem_tables": 0.07421875,
20        "estimate_live_data_size": 5.536526441574097E-5,
21        "total_sst_files_size": 5.536526441574097E-5,
22        "live_sst_files_size": 5.536526441574097E-5,
23        "estimate_pending_compaction_bytes": 0.0,
24        "estimate_num_keys": 0,
25        "num_entries_active_mem_table": 0,
26        "num_entries_imm_mem_tables": 0,
27        "num_deletes_active_mem_table": 0,
28        "num_deletes_imm_mem_tables": 0,
29        "num_running_flushes": 0,
30        "mem_table_flush_pending": 0,
31        "num_running_compactions": 0,
32        "compaction_pending": 0,
33        "num_immutable_mem_table": 0,
34        "num_snapshots": 0,
35        "oldest_snapshot_time": 0,
36        "num_live_versions": 38,
37        "current_super_version_number": 38
38      }
39    }
40  }
41}

19 - Other API

Other REST API: Provide auxiliary functions such as version query, API listing, exception trace switch, IP allowlist and the Arthas agent.

11.1 Other

11.1.1 View Version Information of HugeGraph

Method & Url
1GET http://localhost:8080/versions
Response Status
1200
Response Body
1{
2    "versions": {
3        "version": "v1",
4        "core": "1.7.0",
5        "gremlin": "3.5.1",
6        "api": "0.72.0.0"
7    }
8}

11.1.2 View the profile of the server

Returns the service name, the core version, the documentation links and the API groups served by this node.

Method & Url
1GET http://localhost:8080/
Response Status
1200
Response Body

The swagger_ui value is derived from restserver.url, and apis lists the API groups registered on this node, sorted by name.

 1{
 2    "service": "hugegraph",
 3    "version": "1.7.0",
 4    "doc": "https://hugegraph.apache.org/docs/",
 5    "api_doc": "https://hugegraph.apache.org/docs/clients/",
 6    "swagger_ui": "http://127.0.0.1:8080/swagger-ui/index.html",
 7    "apis": [
 8        "arthas",
 9        "auth",
10        "cypher",
11        "filter",
12        "graph",
13        "gremlin",
14        "job",
15        "metrics",
16        "profile",
17        "raft",
18        "schema",
19        "space",
20        "traversers",
21        "variables"
22    ]
23}

11.1.3 List all APIs of the server

Lists every registered resource method, grouped by API group and resource class. Each entry carries the url, the HTTP method and the query parameters with their types and default values.

Method & Url
1GET http://localhost:8080/apis
Response Status
1200
Response Body

The response is long, the following fragment shows the shape:

 1{
 2    "apis": {
 3        "schema": {
 4            "PropertyKeyAPI": [
 5                {
 6                    "url": "graphspaces/{graphspace}/graphs/{graph}/schema/propertykeys",
 7                    "method": "GET",
 8                    "parameters": [
 9                        {
10                            "name": "names",
11                            "type": "java.util.List<java.lang.String>",
12                            "default_value": null
13                        }
14                    ]
15                }
16            ]
17        }
18    }
19}

11.1.4 View and switch the exception trace stack

Whether the error responses of the server carry the exception stack in the exception and cause fields is decided by the exception.allow_trace option (default true). The switch below is a node-wide runtime override: while it is on, the stack is always included, no matter what the option says. GET reports the state of that override, which starts as false.

Method & Url
1GET http://localhost:8080/exception/trace
Response Status
1200
Response Body
1{
2    "trace": false
3}
Method & Url
1PUT http://localhost:8080/exception/trace
Request Body
1true
Response Status
1200
Response Body
1{
2    "trace": true
3}

11.1.5 Manage the IP allowlist, this operation requires administrator privileges

The allowlist is only enforced when it is switched on, see the white_ip.status option (default disable).

List the allowlist
Method & Url
1GET http://localhost:8080/whiteiplist
Response Status
1200
Response Body
1{
2    "whiteIpList": [
3        "127.0.0.1"
4    ]
5}
Add IPs to or remove IPs from the allowlist
Params
  • ips: list of IPv4 addresses
  • action: load to add, remove to delete
Method & Url
1POST http://localhost:8080/whiteiplist
Request Body
1{
2    "ips": [
3        "10.0.0.1",
4        "10.0.0.2"
5    ],
6    "action": "load"
7}
Response Status
1202
Response Body

existed_ips are the addresses already in the list, added_ips are the newly added ones, and illegal_ips is only returned when some addresses are not valid IPv4 addresses. For action=remove the response carries removed_ips and non_existed_ips instead.

1{
2    "existed_ips": [],
3    "added_ips": [
4        "10.0.0.1",
5        "10.0.0.2"
6    ]
7}
Enable or disable the allowlist
Params
  • status: true to enable, false to disable
Method & Url
1PUT http://localhost:8080/whiteiplist?status=true
Response Status
1200
Response Body
1{
2    "WhiteIpListOpen": true
3}

11.1.6 Start the Arthas agent

Attaches the Arthas agent to the running server process for diagnosis. The ports, the bind IP and the disabled commands are taken from the arthas.telnetPort, arthas.httpPort, arthas.ip and arthas.disabledCommands options, see Config Options.

Method & Url
1PUT http://localhost:8080/arthas
Response Status
1200
Response Body

The applied Arthas configuration is returned:

1{
2    "arthas.telnetPort": "8562",
3    "arthas.httpPort": "8561",
4    "arthas.ip": "0.0.0.0",
5    "arthas.disabledCommands": "jad"
6}