Skip to content

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}