Executing Gremlin Queries (1.0.0)
Function
This API is used to return the query result of a Gremlin statement.
URI
- URI format
POST /ges/v1.0/{project_id}/graphs/{graph_name}/action?action_id=execute-gremlin-query - Parameter description
Table 1 URI parameter description Parameter
Mandatory
Type
Description
project_id
Yes
String
Project ID, which is used for resource isolation. For details, see Obtaining a Project ID.
graph_name
Yes
String
Graph name
Request
- Request example
POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/action?action_id=execute-gremlin-query { "command":"g.V().limit(100)" }
- SERVER_URL: Address for accessing a graph. For details about its value, see Constraints of Using Service Plane APIs.
- The size of the request body cannot exceed 64 MB.
- Request body parameter description
Table 2 Request body parameter description Parameter
Mandatory
Type
Description
command
Yes
String
Query command (Gremlin language)
Response
- Parameter description
Table 3 Response description Parameter
Mandatory
Type
Description
errorMessage
No
String
System prompt. If execution succeeds, this parameter may be left blank. If execution fails, this parameter is used to display the error message.
errorCode
No
String
System prompt. If execution succeeds, this parameter may be left blank. If execution fails, this parameter is used to display the error code.
data
No
Json
Query results. This parameter is left blank when the request fails.
- Response example (successful request)
Http Status Code: 200 { "data": { "runtime": 0.775425022, "vertices": [ { "id": "Vivian", "label": "user", "properties": { "Occupation": [ "artist" ], "ChineseName": [ "Vivian" ], "Zip-code": [ "98133" ], "Gender": [ "F" ], "Age": [ "25-34" ] } }, ...... ] } } - Response example (failed request)
Http Status Code: 400 { "errorMessage": "org.apache.tinkerpop.gremlin.driver.exception.ResponseException: No such property: g1 for class: Script4", "errorCode": "GES.8503" }
Return Value
- Normal
- Abnormal
Table 4 Return code for failed requests Return Value
Description
400 Bad Request
Request error.
401 Unauthorized
Authentication failed.
403 Forbidden
No operation permission.
404 Not Found
The requested resource was not found.
500 Internal Server Error
Internal service error.
503 Service Unavailable
Service unavailable.
Last Article: Gremlin Operation APIs
Next Article: Algorithm APIs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.