© 2016 Neo Technology

Detailed documentation of the Neo4j Server REST API.

The Neo4j REST API is designed with discoverability in mind, so that you can start with a GET on the Service root and from there discover URIs to perform other requests. While the examples below use correct URIs best practice is to discover URIs where possible, rather than relying on the layout in these examples. This allows for handling changes to the URI structure gracefully.

The default representation is json, both for responses and for data sent with POST/PUT requests.

To interact with the JSON interface you must explicitly set the request header Accept:application/json for those requests that responds with data. You should also set the header Content-Type:application/json if your request sends data, for example when you’re creating a relationship. The examples include the relevant request and response headers.

The server supports streaming results, with better performance and lower memory overhead. See Streaming for more information.

Service root

Get service root

The service root is your starting point to discover the REST API. It contains the basic starting points for the database, and some version and extension information.

alt
Figure 1. Final Graph

Example request

  • GET http://localhost:7474/db/data/

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "node" : "http://localhost:7474/db/data/node",
  "relationship" : "http://localhost:7474/db/data/relationship",
  "node_index" : "http://localhost:7474/db/data/index/node",
  "relationship_index" : "http://localhost:7474/db/data/index/relationship",
  "extensions_info" : "http://localhost:7474/db/data/ext",
  "relationship_types" : "http://localhost:7474/db/data/relationship/types",
  "batch" : "http://localhost:7474/db/data/batch",
  "cypher" : "http://localhost:7474/db/data/cypher",
  "indexes" : "http://localhost:7474/db/data/schema/index",
  "constraints" : "http://localhost:7474/db/data/schema/constraint",
  "transaction" : "http://localhost:7474/db/data/transaction",
  "node_labels" : "http://localhost:7474/db/data/labels",
  "neo4j_version" : "3.0.7"
}

Streaming

All responses from the REST API can be transmitted as JSON streams, resulting in better performance and lower memory overhead on the server side. To use streaming, supply the header X-Stream: true with each request.

Example request

  • GET http://localhost:7474/db/data/

  • Accept: application/json

  • X-Stream: true

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8; stream=true

{
  "extensions" : { },
  "node" : "http://localhost:7474/db/data/node",
  "relationship" : "http://localhost:7474/db/data/relationship",
  "node_index" : "http://localhost:7474/db/data/index/node",
  "relationship_index" : "http://localhost:7474/db/data/index/relationship",
  "extensions_info" : "http://localhost:7474/db/data/ext",
  "relationship_types" : "http://localhost:7474/db/data/relationship/types",
  "batch" : "http://localhost:7474/db/data/batch",
  "cypher" : "http://localhost:7474/db/data/cypher",
  "indexes" : "http://localhost:7474/db/data/schema/index",
  "constraints" : "http://localhost:7474/db/data/schema/constraint",
  "transaction" : "http://localhost:7474/db/data/transaction",
  "node_labels" : "http://localhost:7474/db/data/labels",
  "neo4j_version" : "3.0.7"
}

Legacy Cypher HTTP endpoint

This endpoint is deprecated. Please transition to using the transactional HTTP endpoint (see the Developer Manual). Among other things it allows you to run multiple Cypher statements in the same transaction.

The Neo4j REST API allows querying with Cypher (see the Cypher documentation). The results are returned as a list of string headers (columns), and a data part, consisting of a list of all rows. Every row consists of a list of REST representations of the field value — Node, Relationship, Path, or any simple value like String.

In order to speed up queries in repeated scenarios, try not to use literals but replace them with parameters wherever possible in order to let the server cache query plans, see Use parameters for details. Also see the Cypher documentation for where parameters can be used.

Use parameters

Cypher supports queries with parameters which are submitted as JSON.

MATCH (x { name: { startName }})-[r]-(friend)
WHERE friend.name = { name }
RETURN TYPE(r)
alt
Figure 2. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "MATCH (x {name: {startName}})-[r]-(friend) WHERE friend.name = {name} RETURN TYPE(r)",
  "params" : {
    "startName" : "I",
    "name" : "you"
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "TYPE(r)" ],
  "data" : [ [ "know" ] ]
}

Create a node

Create a node with a label and a property using Cypher. See the request for the parameter sent with the query.

CREATE (n:Person { name : { name }})
RETURN n
alt
Figure 3. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "CREATE (n:Person { name : {name} }) RETURN n",
  "params" : {
    "name" : "Andres"
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "n" ],
  "data" : [ [ {
    "metadata" : {
      "id" : 108,
      "labels" : [ "Person" ]
    },
    "data" : {
      "name" : "Andres"
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/108/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/108/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/108/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/108/relationships",
    "labels" : "http://localhost:7474/db/data/node/108/labels",
    "traverse" : "http://localhost:7474/db/data/node/108/traverse/{returnType}",
    "extensions" : { },
    "all_relationships" : "http://localhost:7474/db/data/node/108/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/108/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/108/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/108",
    "incoming_relationships" : "http://localhost:7474/db/data/node/108/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/108/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/108/relationships/in/{-list|&|types}"
  } ] ]
}

Create a node with multiple properties

Create a node with a label and multiple properties using Cypher. See the request for the parameter sent with the query.

CREATE (n:Person { props })
RETURN n
alt
Figure 4. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "CREATE (n:Person { props } ) RETURN n",
  "params" : {
    "props" : {
      "position" : "Developer",
      "name" : "Michael",
      "awesome" : true,
      "children" : 3
    }
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "n" ],
  "data" : [ [ {
    "metadata" : {
      "id" : 105,
      "labels" : [ "Person" ]
    },
    "data" : {
      "awesome" : true,
      "children" : 3,
      "name" : "Michael",
      "position" : "Developer"
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/105/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/105/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/105/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/105/relationships",
    "labels" : "http://localhost:7474/db/data/node/105/labels",
    "traverse" : "http://localhost:7474/db/data/node/105/traverse/{returnType}",
    "extensions" : { },
    "all_relationships" : "http://localhost:7474/db/data/node/105/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/105/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/105/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/105",
    "incoming_relationships" : "http://localhost:7474/db/data/node/105/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/105/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/105/relationships/in/{-list|&|types}"
  } ] ]
}

Create multiple nodes with properties

Create multiple nodes with properties using Cypher. See the request for the parameter sent with the query.

UNWIND { props } AS properties
CREATE (n:Person)
SET n = properties
RETURN n
alt
Figure 5. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "UNWIND {props} AS properties CREATE (n:Person) SET n = properties RETURN n",
  "params" : {
    "props" : [ {
      "name" : "Andres",
      "position" : "Developer"
    }, {
      "name" : "Michael",
      "position" : "Developer"
    } ]
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "n" ],
  "data" : [ [ {
    "metadata" : {
      "id" : 109,
      "labels" : [ "Person" ]
    },
    "data" : {
      "name" : "Andres",
      "position" : "Developer"
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/109/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/109/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/109/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/109/relationships",
    "labels" : "http://localhost:7474/db/data/node/109/labels",
    "traverse" : "http://localhost:7474/db/data/node/109/traverse/{returnType}",
    "extensions" : { },
    "all_relationships" : "http://localhost:7474/db/data/node/109/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/109/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/109/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/109",
    "incoming_relationships" : "http://localhost:7474/db/data/node/109/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/109/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/109/relationships/in/{-list|&|types}"
  } ], [ {
    "metadata" : {
      "id" : 110,
      "labels" : [ "Person" ]
    },
    "data" : {
      "name" : "Michael",
      "position" : "Developer"
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/110/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/110/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/110/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/110/relationships",
    "labels" : "http://localhost:7474/db/data/node/110/labels",
    "traverse" : "http://localhost:7474/db/data/node/110/traverse/{returnType}",
    "extensions" : { },
    "all_relationships" : "http://localhost:7474/db/data/node/110/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/110/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/110/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/110",
    "incoming_relationships" : "http://localhost:7474/db/data/node/110/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/110/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/110/relationships/in/{-list|&|types}"
  } ] ]
}

Set all properties on a node using Cypher

Set all properties on a node.

CREATE (n:Person { name: 'this property is to be deleted' })
SET n = { props }
RETURN n
alt
Figure 6. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "CREATE (n:Person { name: 'this property is to be deleted' } ) SET n = { props } RETURN n",
  "params" : {
    "props" : {
      "position" : "Developer",
      "firstName" : "Michael",
      "awesome" : true,
      "children" : 3
    }
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "n" ],
  "data" : [ [ {
    "metadata" : {
      "id" : 136,
      "labels" : [ "Person" ]
    },
    "data" : {
      "firstName" : "Michael",
      "awesome" : true,
      "children" : 3,
      "position" : "Developer"
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/136/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/136/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/136/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/136/relationships",
    "labels" : "http://localhost:7474/db/data/node/136/labels",
    "traverse" : "http://localhost:7474/db/data/node/136/traverse/{returnType}",
    "extensions" : { },
    "all_relationships" : "http://localhost:7474/db/data/node/136/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/136/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/136/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/136",
    "incoming_relationships" : "http://localhost:7474/db/data/node/136/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/136/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/136/relationships/in/{-list|&|types}"
  } ] ]
}

Send a query

A simple query returning all nodes connected to some node, returning the node and the name property, if it exists, otherwise NULL:

MATCH (x { name: 'I' })-[r]->(n)
RETURN type(r), n.name, n.age
alt
Figure 7. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "MATCH (x {name: 'I'})-[r]->(n) RETURN type(r), n.name, n.age",
  "params" : { }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "type(r)", "n.name", "n.age" ],
  "data" : [ [ "know", "you", null ], [ "know", "him", 25 ] ]
}

Return paths

Paths can be returned just like other return types.

MATCH path =(x { name: 'I' })--(friend)
RETURN path, friend.name
alt
Figure 8. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "MATCH path = (x {name: 'I'})--(friend) RETURN path, friend.name",
  "params" : { }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "path", "friend.name" ],
  "data" : [ [ {
    "relationships" : [ "http://localhost:7474/db/data/relationship/73" ],
    "nodes" : [ "http://localhost:7474/db/data/node/134", "http://localhost:7474/db/data/node/135" ],
    "directions" : [ "->" ],
    "start" : "http://localhost:7474/db/data/node/134",
    "length" : 1,
    "end" : "http://localhost:7474/db/data/node/135"
  }, "you" ] ]
}

Nested results

When sending queries that return nested results like list and maps, these will get serialized into nested JSON representations according to their types.

MATCH (n)
WHERE n.name IN ['I', 'you']
RETURN collect(n.name)
alt
Figure 9. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "MATCH (n) WHERE n.name in ['I', 'you'] RETURN collect(n.name)",
  "params" : { }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "collect(n.name)" ],
  "data" : [ [ [ "I", "you" ] ] ]
}

Retrieve query metadata

By passing in an additional GET parameter when you execute Cypher queries, metadata about the query will be returned, such as how many labels were added or removed by the query.

MATCH (n { name: 'I' })
SET n:Actor
REMOVE n:Director
RETURN labels(n)
alt
Figure 10. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher?includeStats=true

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "MATCH (n {name: 'I'}) SET n:Actor REMOVE n:Director RETURN labels(n)",
  "params" : { }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "columns" : [ "labels(n)" ],
  "data" : [ [ [ "Actor" ] ] ],
  "stats" : {
    "nodes_deleted" : 0,
    "relationship_deleted" : 0,
    "nodes_created" : 0,
    "labels_added" : 1,
    "relationships_created" : 0,
    "indexes_added" : 0,
    "properties_set" : 0,
    "contains_updates" : true,
    "indexes_removed" : 0,
    "constraints_added" : 0,
    "labels_removed" : 1,
    "constraints_removed" : 0
  }
}

Errors

Errors on the server will be reported as a JSON-formatted message, exception name and stacktrace.

MATCH (x { name: 'I' })
RETURN x.dummy/0
alt
Figure 11. Final Graph

Example request

  • POST http://localhost:7474/db/data/cypher

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "query" : "MATCH (x {name: 'I'}) RETURN x.dummy/0",
  "params" : { }
}

Example response

  • 400: Bad Request

  • Content-Type: application/json; charset=UTF-8

{
  "message": "/ by zero",
  "exception": "BadInputException",
  "fullname": "org.neo4j.server.rest.repr.BadInputException",
  "stackTrace": [
    "org.neo4j.server.rest.repr.RepresentationExceptionHandlingIterable.exceptionOnNext(RepresentationExceptionHandlingIterable.java:39)",
    "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.next(ExceptionHandlingIterable.java:55)",
    "org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)",
    "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:64)",
    "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)",
    "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)",
    "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:58)",
    "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)",
    "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:235)",
    "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:175)",
    "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:158)",
    "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)",
    "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:138)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "cause": {
    "exception": "QueryExecutionException",
    "cause": {
      "exception": "QueryExecutionKernelException",
      "cause": {
        "exception": "ArithmeticException",
        "cause": {
          "exception": "ArithmeticException",
          "fullname": "org.neo4j.cypher.internal.frontend.v3_0.ArithmeticException",
          "stackTrace": [
            "org.neo4j.cypher.internal.compiler.v3_0.commands.expressions.Divide.apply(Divide.scala:36)",
            "org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1$$anonfun$apply$1.apply(ProjectionPipe.scala:48)",
            "org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1$$anonfun$apply$1.apply(ProjectionPipe.scala:46)",
            "scala.collection.immutable.Map$Map1.foreach(Map.scala:116)",
            "org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1.apply(ProjectionPipe.scala:46)",
            "org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1.apply(ProjectionPipe.scala:45)",
            "scala.collection.Iterator$$anon$11.next(Iterator.scala:409)",
            "scala.collection.Iterator$$anon$11.next(Iterator.scala:409)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator$$anonfun$next$1.apply(ResultIterator.scala:73)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator$$anonfun$next$1.apply(ResultIterator.scala:70)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator$$anonfun$failIfThrows$1.apply(ResultIterator.scala:96)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.decoratedCypherException(ResultIterator.scala:105)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.failIfThrows(ResultIterator.scala:94)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.next(ResultIterator.scala:70)",
            "org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.next(ResultIterator.scala:48)",
            "org.neo4j.cypher.internal.compiler.v3_0.PipeExecutionResult.next(PipeExecutionResult.scala:79)",
            "org.neo4j.cypher.internal.compiler.v3_0.PipeExecutionResult$$anon$2.next(PipeExecutionResult.scala:69)",
            "org.neo4j.cypher.internal.compiler.v3_0.PipeExecutionResult$$anon$2.next(PipeExecutionResult.scala:66)",
            "org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1$$anonfun$next$1.apply(CompatibilityFor3_0.scala:313)",
            "org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1$$anonfun$next$1.apply(CompatibilityFor3_0.scala:313)",
            "org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.runSafely(CompatibilityFor3_0.scala:187)",
            "org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1.next(CompatibilityFor3_0.scala:312)",
            "org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1.next(CompatibilityFor3_0.scala:306)",
            "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:241)",
            "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:54)",
            "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.next(ExceptionHandlingIterable.java:53)",
            "org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)",
            "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:64)",
            "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)",
            "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)",
            "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:58)",
            "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)",
            "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:235)",
            "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:175)",
            "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:158)",
            "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)",
            "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:138)",
            "java.lang.reflect.Method.invoke(Method.java:508)",
            "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
            "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
            "java.lang.Thread.run(Thread.java:785)"
          ],
          "errors": [
            {
              "code": "Neo.DatabaseError.General.UnknownError",
              "stackTrace": "org.neo4j.cypher.internal.frontend.v3_0.ArithmeticException\n\tat org.neo4j.cypher.internal.compiler.v3_0.commands.expressions.Divide.apply(Divide.scala:36)\n\tat org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1$$anonfun$apply$1.apply(ProjectionPipe.scala:48)\n\tat org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1$$anonfun$apply$1.apply(ProjectionPipe.scala:46)\n\tat scala.collection.immutable.Map$Map1.foreach(Map.scala:116)\n\tat org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1.apply(ProjectionPipe.scala:46)\n\tat org.neo4j.cypher.internal.compiler.v3_0.pipes.ProjectionPipe$$anonfun$internalCreateResults$1.apply(ProjectionPipe.scala:45)\n\tat scala.collection.Iterator$$anon$11.next(Iterator.scala:409)\n\tat scala.collection.Iterator$$anon$11.next(Iterator.scala:409)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator$$anonfun$next$1.apply(ResultIterator.scala:73)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator$$anonfun$next$1.apply(ResultIterator.scala:70)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator$$anonfun$failIfThrows$1.apply(ResultIterator.scala:96)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.decoratedCypherException(ResultIterator.scala:105)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.failIfThrows(ResultIterator.scala:94)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.next(ResultIterator.scala:70)\n\tat org.neo4j.cypher.internal.compiler.v3_0.ClosingIterator.next(ResultIterator.scala:48)\n\tat org.neo4j.cypher.internal.compiler.v3_0.PipeExecutionResult.next(PipeExecutionResult.scala:79)\n\tat org.neo4j.cypher.internal.compiler.v3_0.PipeExecutionResult$$anon$2.next(PipeExecutionResult.scala:69)\n\tat org.neo4j.cypher.internal.compiler.v3_0.PipeExecutionResult$$anon$2.next(PipeExecutionResult.scala:66)\n\tat org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1$$anonfun$next$1.apply(CompatibilityFor3_0.scala:313)\n\tat org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1$$anonfun$next$1.apply(CompatibilityFor3_0.scala:313)\n\tat org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.runSafely(CompatibilityFor3_0.scala:187)\n\tat org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1.next(CompatibilityFor3_0.scala:312)\n\tat org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1.next(CompatibilityFor3_0.scala:306)\n\tat org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:241)\n\tat org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:54)\n\tat org.neo4j.helpers.collection.ExceptionHandlingIterable$1.next(ExceptionHandlingIterable.java:53)\n\tat org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)\n\tat org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:64)\n\tat org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)\n\tat org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)\n\tat org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:58)\n\tat org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)\n\tat org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:235)\n\tat org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:175)\n\tat org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:158)\n\tat org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)\n\tat org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:138)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)\n\tat java.lang.reflect.Method.invoke(Method.java:508)\n\tat com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)\n\tat com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)\n\tat com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)\n\tat org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)\n\tat com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)\n\tat com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)\n\tat com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)\n\tat com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)\n\tat com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)\n\tat com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558)\n\tat com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\n\tat org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)\n\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\n\tat java.lang.Thread.run(Thread.java:785)\n"
            }
          ]
        },
        "fullname": "org.neo4j.cypher.ArithmeticException",
        "stackTrace": [
          "org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.arithmeticException(CompatibilityFor3_0.scala:134)",
          "org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.arithmeticException(CompatibilityFor3_0.scala:131)",
          "org.neo4j.cypher.internal.frontend.v3_0.ArithmeticException.mapToPublic(CypherException.scala:98)",
          "org.neo4j.cypher.internal.compatibility.exceptionHandlerFor3_0$.runSafely(CompatibilityFor3_0.scala:192)",
          "org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1.next(CompatibilityFor3_0.scala:312)",
          "org.neo4j.cypher.internal.compatibility.ExecutionResultWrapperFor3_0$$anon$1.next(CompatibilityFor3_0.scala:306)",
          "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:241)",
          "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:54)",
          "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.next(ExceptionHandlingIterable.java:53)",
          "org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)",
          "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:64)",
          "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)",
          "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)",
          "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:58)",
          "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)",
          "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:235)",
          "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:175)",
          "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:158)",
          "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)",
          "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:138)",
          "java.lang.reflect.Method.invoke(Method.java:508)",
          "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
          "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
          "java.lang.Thread.run(Thread.java:785)"
        ],
        "message": "/ by zero",
        "errors": [
          {
            "code": "Neo.ClientError.Statement.ArithmeticError",
            "message": "/ by zero"
          }
        ]
      },
      "fullname": "org.neo4j.kernel.impl.query.QueryExecutionKernelException",
      "stackTrace": [
        "org.neo4j.cypher.internal.javacompat.ExecutionResult.converted(ExecutionResult.java:399)",
        "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:245)",
        "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:54)",
        "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.next(ExceptionHandlingIterable.java:53)",
        "org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)",
        "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:64)",
        "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)",
        "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)",
        "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:58)",
        "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)",
        "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:235)",
        "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:175)",
        "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:158)",
        "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)",
        "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:138)",
        "java.lang.reflect.Method.invoke(Method.java:508)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
        "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
        "java.lang.Thread.run(Thread.java:785)"
      ],
      "message": "/ by zero",
      "errors": [
        {
          "code": "Neo.ClientError.Statement.ArithmeticError",
          "message": "/ by zero"
        }
      ]
    },
    "fullname": "org.neo4j.graphdb.QueryExecutionException",
    "stackTrace": [
      "org.neo4j.kernel.impl.query.QueryExecutionKernelException.asUserException(QueryExecutionKernelException.java:35)",
      "org.neo4j.cypher.internal.javacompat.ExecutionResult.converted(ExecutionResult.java:399)",
      "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:245)",
      "org.neo4j.cypher.internal.javacompat.ExecutionResult.next(ExecutionResult.java:54)",
      "org.neo4j.helpers.collection.ExceptionHandlingIterable$1.next(ExceptionHandlingIterable.java:53)",
      "org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)",
      "org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:64)",
      "org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)",
      "org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)",
      "org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:58)",
      "org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)",
      "org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat.java:235)",
      "org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:175)",
      "org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:158)",
      "org.neo4j.server.rest.repr.OutputFormat.ok(OutputFormat.java:71)",
      "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:138)",
      "java.lang.reflect.Method.invoke(Method.java:508)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
      "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
      "java.lang.Thread.run(Thread.java:785)"
    ],
    "message": "/ by zero",
    "errors": [
      {
        "code": "Neo.ClientError.Statement.ArithmeticError",
        "message": "/ by zero"
      }
    ]
  },
  "errors": [
    {
      "code": "Neo.ClientError.Request.InvalidFormat",
      "message": "/ by zero"
    }
  ]
}

Property values

The REST API allows setting properties on nodes and relationships through direct RESTful operations. However, there are restrictions as to what types of values can be used as property values. Allowed value types are as follows:

  • Numbers: Both integer values, with capacity as Java’s Long type, and floating points, with capacity as Java’s Double.

  • Booleans.

  • Strings.

  • Arrays of the basic types above.

Arrays

There are two important points to be made about array values. First, all values in the array must be of the same type. That means either all integers, all floats, all booleans or all strings. Mixing types is not currently supported.

Second, storing empty arrays is only possible given certain preconditions. Because the JSON transfer format does not contain type information for arrays, type is inferred from the values in the array. If the array is empty, the Neo4j Server cannot determine the type. In these cases, it will check if an array is already stored for the given property, and will use the stored array’s type when storing the empty array. If no array exists already, the server will reject the request.

Property keys

You can list all property keys ever used in the database. This includes and property keys you have used, but deleted.

There is currently no way to tell which ones are in use and which ones are not, short of walking the entire set of properties in the database.

List all property keys

Example request

  • GET http://localhost:7474/db/data/propertykeys

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ "position", "prop", "property_1480348106836_1", "age", "property_1480348107102_1", "foo", "name", "property_1480348106521_1", "children", "jim", "property_1480348106216_1", "property_1480348106379_1", "array1", "firstName", "array2", "since", "strength", "property_1480348106015_1", "property_1480348107102_2", "property_1480348107273_1", "cost", "awesome" ]

Nodes

Create node

alt
Figure 12. Final Graph

Example request

  • POST http://localhost:7474/db/data/node

  • Accept: application/json; charset=UTF-8

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/node/354

{
  "extensions" : { },
  "metadata" : {
    "id" : 354,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/354/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/354/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/354/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/354/relationships",
  "labels" : "http://localhost:7474/db/data/node/354/labels",
  "traverse" : "http://localhost:7474/db/data/node/354/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/354/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/354/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/354/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/354",
  "incoming_relationships" : "http://localhost:7474/db/data/node/354/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/354/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/354/relationships/in/{-list|&|types}",
  "data" : { }
}

Create node with properties

alt
Figure 13. Final Graph

Example request

  • POST http://localhost:7474/db/data/node

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "foo" : "bar"
}

Example response

  • 201: Created

  • Content-Length: 1237

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/node/350

{
  "extensions" : { },
  "metadata" : {
    "id" : 350,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/350/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/350/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/350/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/350/relationships",
  "labels" : "http://localhost:7474/db/data/node/350/labels",
  "traverse" : "http://localhost:7474/db/data/node/350/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/350/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/350/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/350/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/350",
  "incoming_relationships" : "http://localhost:7474/db/data/node/350/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/350/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/350/relationships/in/{-list|&|types}",
  "data" : {
    "foo" : "bar"
  }
}

Get node

Note that the response contains URI/templates for the available operations for getting properties and relationships.

alt
Figure 14. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/99

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 99,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/99/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/99/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/99/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/99/relationships",
  "labels" : "http://localhost:7474/db/data/node/99/labels",
  "traverse" : "http://localhost:7474/db/data/node/99/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/99/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/99/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/99/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/99",
  "incoming_relationships" : "http://localhost:7474/db/data/node/99/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/99/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/99/relationships/in/{-list|&|types}",
  "data" : { }
}

Get non-existent node

alt
Figure 15. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/10300000

  • Accept: application/json; charset=UTF-8

Example response

  • 404: Not Found

  • Content-Type: application/json; charset=UTF-8

{
  "message": "Cannot find node with id [10300000] in database.",
  "exception": "NodeNotFoundException",
  "fullname": "org.neo4j.server.rest.web.NodeNotFoundException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:166)",
    "org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:211)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:279)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "cause": {
    "exception": "NotFoundException",
    "cause": {
      "exception": "EntityNotFoundException",
      "fullname": "org.neo4j.kernel.api.exceptions.EntityNotFoundException",
      "stackTrace": [
        "org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getNodeById(GraphDatabaseFacade.java:283)",
        "org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:162)",
        "org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:211)",
        "org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:279)",
        "java.lang.reflect.Method.invoke(Method.java:508)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
        "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
        "java.lang.Thread.run(Thread.java:785)"
      ],
      "message": "Unable to load NODE with id 10300000.",
      "errors": [
        {
          "code": "Neo.ClientError.Statement.EntityNotFound",
          "message": "Unable to load NODE with id 10300000."
        }
      ]
    },
    "fullname": "org.neo4j.graphdb.NotFoundException",
    "stackTrace": [
      "org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getNodeById(GraphDatabaseFacade.java:283)",
      "org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:162)",
      "org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:211)",
      "org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:279)",
      "java.lang.reflect.Method.invoke(Method.java:508)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
      "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
      "java.lang.Thread.run(Thread.java:785)"
    ],
    "message": "Node 10300000 not found",
    "errors": [
      {
        "code": "Neo.ClientError.Statement.EntityNotFound",
        "message": "Node 10300000 not found"
      }
    ]
  },
  "errors": [
    {
      "code": "Neo.ClientError.Statement.EntityNotFound",
      "message": "Cannot find node with id [10300000] in database."
    }
  ]
}

Delete node

alt
Figure 16. Starting Graph
alt
Figure 17. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/351

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Nodes with relationships cannot be deleted

The relationships on a node has to be deleted before the node can be deleted.

You can use DETACH DELETE in Cypher to delete nodes and their relationships in one go.
alt
Figure 18. Starting Graph

Example request

  • DELETE http://localhost:7474/db/data/node/358

  • Accept: application/json; charset=UTF-8

Example response

  • 409: Conflict

  • Content-Type: application/json; charset=UTF-8

{
  "message": "The node with id 358 cannot be deleted. Check that the node is orphaned before deletion.",
  "exception": "ConstraintViolationException",
  "fullname": "org.neo4j.graphdb.ConstraintViolationException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.deleteNode(DatabaseActions.java:221)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNode(RestfulGraphDatabase.java:293)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "errors": [
    {
      "code": "Neo.ClientError.Schema.ConstraintValidationFailed",
      "message": "The node with id 358 cannot be deleted. Check that the node is orphaned before deletion."
    }
  ]
}

Relationships

Relationships are a first class citizen in the Neo4j REST API. They can be accessed either stand-alone or through the nodes they are attached to.

The general pattern to get relationships from a node is:

GET http://localhost:7474/db/data/node/123/relationships/{dir}/{-list|&|types}

Where dir is one of all, in, out and types is an ampersand-separated list of types. See the examples below for more information.

Get Relationship by ID

alt
Figure 19. Final Graph

Example request

  • GET http://localhost:7474/db/data/relationship/150

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 150,
    "type" : "know"
  },
  "start" : "http://localhost:7474/db/data/node/256",
  "property" : "http://localhost:7474/db/data/relationship/150/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/150",
  "end" : "http://localhost:7474/db/data/node/257",
  "type" : "know",
  "properties" : "http://localhost:7474/db/data/relationship/150/properties",
  "data" : { }
}

Create relationship

Upon successful creation of a relationship, the new relationship is returned.

alt
Figure 20. Starting Graph
alt
Figure 21. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/0/relationships

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/1",
  "type" : "LOVES"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/relationship/1

{
  "extensions" : { },
  "metadata" : {
    "id" : 1,
    "type" : "LOVES"
  },
  "start" : "http://localhost:7474/db/data/node/0",
  "property" : "http://localhost:7474/db/data/relationship/1/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/1",
  "end" : "http://localhost:7474/db/data/node/1",
  "type" : "LOVES",
  "properties" : "http://localhost:7474/db/data/relationship/1/properties",
  "data" : { }
}

Create a relationship with properties

Upon successful creation of a relationship, the new relationship is returned.

alt
Figure 22. Starting Graph
alt
Figure 23. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/10/relationships

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/11",
  "type" : "LOVES",
  "data" : {
    "foo" : "bar"
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/relationship/8

{
  "extensions" : { },
  "metadata" : {
    "id" : 8,
    "type" : "LOVES"
  },
  "start" : "http://localhost:7474/db/data/node/10",
  "property" : "http://localhost:7474/db/data/relationship/8/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/8",
  "end" : "http://localhost:7474/db/data/node/11",
  "type" : "LOVES",
  "properties" : "http://localhost:7474/db/data/relationship/8/properties",
  "data" : {
    "foo" : "bar"
  }
}

Delete relationship

alt
Figure 24. Starting Graph
alt
Figure 25. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/143

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Get all properties on a relationship

alt
Figure 26. Final Graph

Example request

  • GET http://localhost:7474/db/data/relationship/146/properties

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "cost" : "high",
  "since" : "1day"
}

Set all properties on a relationship

alt
Figure 27. Starting Graph
alt
Figure 28. Final Graph

Example request

  • PUT http://localhost:7474/db/data/relationship/151/properties

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "happy" : false
}

Example response

  • 204: No Content

Get single property on a relationship

alt
Figure 29. Final Graph

Example request

  • GET http://localhost:7474/db/data/relationship/147/properties/cost

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

"high"

Set single property on a relationship

alt
Figure 30. Starting Graph
alt
Figure 31. Final Graph

Example request

  • PUT http://localhost:7474/db/data/relationship/145/properties/cost

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

"deadly"

Example response

  • 204: No Content

Get all relationships

alt
Figure 32. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/48/relationships/all

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "extensions" : { },
  "metadata" : {
    "id" : 33,
    "type" : "HATES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/48",
  "property" : "http://localhost:7474/db/data/relationship/33/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/33",
  "end" : "http://localhost:7474/db/data/node/51",
  "type" : "HATES",
  "properties" : "http://localhost:7474/db/data/relationship/33/properties"
}, {
  "extensions" : { },
  "metadata" : {
    "id" : 32,
    "type" : "LIKES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/50",
  "property" : "http://localhost:7474/db/data/relationship/32/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/32",
  "end" : "http://localhost:7474/db/data/node/48",
  "type" : "LIKES",
  "properties" : "http://localhost:7474/db/data/relationship/32/properties"
}, {
  "extensions" : { },
  "metadata" : {
    "id" : 31,
    "type" : "LIKES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/48",
  "property" : "http://localhost:7474/db/data/relationship/31/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/31",
  "end" : "http://localhost:7474/db/data/node/49",
  "type" : "LIKES",
  "properties" : "http://localhost:7474/db/data/relationship/31/properties"
} ]

Get incoming relationships

alt
Figure 33. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/67/relationships/in

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "extensions" : { },
  "metadata" : {
    "id" : 43,
    "type" : "LIKES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/69",
  "property" : "http://localhost:7474/db/data/relationship/43/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/43",
  "end" : "http://localhost:7474/db/data/node/67",
  "type" : "LIKES",
  "properties" : "http://localhost:7474/db/data/relationship/43/properties"
} ]

Get outgoing relationships

alt
Figure 34. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/92/relationships/out

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "extensions" : { },
  "metadata" : {
    "id" : 59,
    "type" : "HATES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/92",
  "property" : "http://localhost:7474/db/data/relationship/59/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/59",
  "end" : "http://localhost:7474/db/data/node/95",
  "type" : "HATES",
  "properties" : "http://localhost:7474/db/data/relationship/59/properties"
}, {
  "extensions" : { },
  "metadata" : {
    "id" : 57,
    "type" : "LIKES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/92",
  "property" : "http://localhost:7474/db/data/relationship/57/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/57",
  "end" : "http://localhost:7474/db/data/node/93",
  "type" : "LIKES",
  "properties" : "http://localhost:7474/db/data/relationship/57/properties"
} ]

Get typed relationships

Note that the "&" needs to be encoded like "%26" for example when using cURL from the terminal.

alt
Figure 35. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/23/relationships/all/LIKES&HATES

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "extensions" : { },
  "metadata" : {
    "id" : 18,
    "type" : "HATES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/23",
  "property" : "http://localhost:7474/db/data/relationship/18/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/18",
  "end" : "http://localhost:7474/db/data/node/26",
  "type" : "HATES",
  "properties" : "http://localhost:7474/db/data/relationship/18/properties"
}, {
  "extensions" : { },
  "metadata" : {
    "id" : 17,
    "type" : "LIKES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/25",
  "property" : "http://localhost:7474/db/data/relationship/17/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/17",
  "end" : "http://localhost:7474/db/data/node/23",
  "type" : "LIKES",
  "properties" : "http://localhost:7474/db/data/relationship/17/properties"
}, {
  "extensions" : { },
  "metadata" : {
    "id" : 16,
    "type" : "LIKES"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/23",
  "property" : "http://localhost:7474/db/data/relationship/16/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/16",
  "end" : "http://localhost:7474/db/data/node/24",
  "type" : "LIKES",
  "properties" : "http://localhost:7474/db/data/relationship/16/properties"
} ]

Get relationships on a node without relationships

alt
Figure 36. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/81/relationships/all

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ ]

Relationship types

Get relationship types

Example request

  • GET http://localhost:7474/db/data/relationship/types

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json

[ "KNOWS", "LOVES" ]

Node properties

Set property on node

Setting different properties will retain the existing ones for this node. Note that a single value are submitted not as a map but just as a value (which is valid JSON) like in the example below.

alt
Figure 37. Final Graph

Example request

  • PUT http://localhost:7474/db/data/node/192/properties/foo

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

"bar"

Example response

  • 204: No Content

Update node properties

This will replace all existing properties on the node with the new set of attributes.

alt
Figure 38. Final Graph

Example request

  • PUT http://localhost:7474/db/data/node/191/properties

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "age" : "18"
}

Example response

  • 204: No Content

Get properties for node

alt
Figure 39. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/390/properties

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "foo" : "bar"
}

Get property for node

Get a single node property from a node.

alt
Figure 40. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/389/properties/foo

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

"bar"

Property values can not be null

This example shows the response you get when trying to set a property to null.

Example request

  • POST http://localhost:7474/db/data/node

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "foo" : null
}

Example response

  • 400: Bad Request

  • Content-Type: application/json; charset=UTF-8

{
  "message": "Could not set property \"foo\", unsupported type: null",
  "exception": "PropertyValueException",
  "fullname": "org.neo4j.server.rest.web.PropertyValueException",
  "stackTrace": [
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperty(PropertySettingStrategy.java:141)",
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperties(PropertySettingStrategy.java:88)",
    "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:197)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:252)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "errors": [
    {
      "code": "Neo.ClientError.Statement.ArgumentError",
      "message": "Could not set property \"foo\", unsupported type: null"
    }
  ]
}

Property values can not be nested

Nesting properties is not supported. You could for example store the nested JSON as a string instead.

Example request

  • POST http://localhost:7474/db/data/node/

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "foo" : {
    "bar" : "baz"
  }
}

Example response

  • 400: Bad Request

  • Content-Type: application/json; charset=UTF-8

{
  "message": "Could not set property \"foo\", unsupported type: {bar\u003dbaz}",
  "exception": "PropertyValueException",
  "fullname": "org.neo4j.server.rest.web.PropertyValueException",
  "stackTrace": [
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperty(PropertySettingStrategy.java:141)",
    "org.neo4j.server.rest.domain.PropertySettingStrategy.setProperties(PropertySettingStrategy.java:88)",
    "org.neo4j.server.rest.web.DatabaseActions.createNode(DatabaseActions.java:197)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.createNode(RestfulGraphDatabase.java:252)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "errors": [
    {
      "code": "Neo.ClientError.Statement.ArgumentError",
      "message": "Could not set property \"foo\", unsupported type: {bar\u003dbaz}"
    }
  ]
}

Delete all properties from node

alt
Figure 41. Starting Graph
alt
Figure 42. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/217/properties

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Delete a named property from a node

To delete a single property from a node, see the example below

alt
Figure 43. Starting Graph
alt
Figure 44. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/216/properties/name

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Relationship properties

Update relationship properties

alt
Figure 45. Starting Graph
alt
Figure 46. Final Graph

Example request

  • PUT http://localhost:7474/db/data/relationship/133/properties

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "jim" : "tobias"
}

Example response

  • 204: No Content

Remove properties from a relationship

alt
Figure 47. Starting Graph
alt
Figure 48. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/141/properties

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Remove property from a relationship

See the example request below.

alt
Figure 49. Starting Graph
alt
Figure 50. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/144/properties/cost

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Remove non-existent property from a relationship

Attempting to remove a property that doesn’t exist results in an error.

alt
Figure 51. Starting Graph

Example request

  • DELETE http://localhost:7474/db/data/relationship/142/properties/non-existent

  • Accept: application/json; charset=UTF-8

Example response

  • 404: Not Found

  • Content-Type: application/json; charset=UTF-8

{
  "message": "(240)-[LOVES,142]-\u003e(241) does not have a property \"non-existent\"",
  "exception": "NoSuchPropertyException",
  "fullname": "org.neo4j.server.rest.web.NoSuchPropertyException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:663)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:812)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "errors": [
    {
      "code": "Neo.ClientError.Statement.PropertyNotFound",
      "message": "(240)-[LOVES,142]-\u003e(241) does not have a property \"non-existent\""
    }
  ]
}

Remove properties from a non-existing relationship

Attempting to remove all properties from a relationship which doesn’t exist results in an error.

Example request

  • DELETE http://localhost:7474/db/data/relationship/1234/properties

  • Accept: application/json; charset=UTF-8

Example response

  • 404: Not Found

  • Content-Type: application/json; charset=UTF-8

{
  "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found",
  "exception": "RelationshipNotFoundException",
  "fullname": "org.neo4j.server.rest.web.RelationshipNotFoundException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:180)",
    "org.neo4j.server.rest.web.DatabaseActions.removeAllRelationshipProperties(DatabaseActions.java:653)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteAllRelationshipProperties(RestfulGraphDatabase.java:792)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "cause": {
    "exception": "NotFoundException",
    "cause": {
      "exception": "EntityNotFoundException",
      "fullname": "org.neo4j.kernel.api.exceptions.EntityNotFoundException",
      "stackTrace": [
        "org.neo4j.kernel.impl.api.store.DiskLayer.relationshipVisit(DiskLayer.java:432)",
        "org.neo4j.kernel.impl.api.store.CacheLayer.relationshipVisit(CacheLayer.java:345)",
        "org.neo4j.kernel.impl.api.StateHandlingStatementOperations.relationshipVisit(StateHandlingStatementOperations.java:1409)",
        "org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.relationshipVisit(ConstraintEnforcingEntityOperations.java:417)",
        "org.neo4j.kernel.impl.api.OperationsFacade.relationshipVisit(OperationsFacade.java:512)",
        "org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getRelationshipById(GraphDatabaseFacade.java:304)",
        "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:176)",
        "org.neo4j.server.rest.web.DatabaseActions.removeAllRelationshipProperties(DatabaseActions.java:653)",
        "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteAllRelationshipProperties(RestfulGraphDatabase.java:792)",
        "java.lang.reflect.Method.invoke(Method.java:508)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
        "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
        "java.lang.Thread.run(Thread.java:785)"
      ],
      "message": "Unable to load RELATIONSHIP with id 1234.",
      "errors": [
        {
          "code": "Neo.ClientError.Statement.EntityNotFound",
          "message": "Unable to load RELATIONSHIP with id 1234."
        }
      ]
    },
    "fullname": "org.neo4j.graphdb.NotFoundException",
    "stackTrace": [
      "org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getRelationshipById(GraphDatabaseFacade.java:309)",
      "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:176)",
      "org.neo4j.server.rest.web.DatabaseActions.removeAllRelationshipProperties(DatabaseActions.java:653)",
      "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteAllRelationshipProperties(RestfulGraphDatabase.java:792)",
      "java.lang.reflect.Method.invoke(Method.java:508)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
      "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
      "java.lang.Thread.run(Thread.java:785)"
    ],
    "message": "Relationship 1234 not found",
    "errors": [
      {
        "code": "Neo.ClientError.Statement.EntityNotFound",
        "message": "Relationship 1234 not found"
      }
    ]
  },
  "errors": [
    {
      "code": "Neo.ClientError.Statement.EntityNotFound",
      "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found"
    }
  ]
}

Remove property from a non-existing relationship

Attempting to remove a property from a relationship which doesn’t exist results in an error.

Example request

  • DELETE http://localhost:7474/db/data/relationship/1234/properties/cost

  • Accept: application/json; charset=UTF-8

Example response

  • 404: Not Found

  • Content-Type: application/json; charset=UTF-8

{
  "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found",
  "exception": "RelationshipNotFoundException",
  "fullname": "org.neo4j.server.rest.web.RelationshipNotFoundException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:180)",
    "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:659)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:812)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "cause": {
    "exception": "NotFoundException",
    "cause": {
      "exception": "EntityNotFoundException",
      "fullname": "org.neo4j.kernel.api.exceptions.EntityNotFoundException",
      "stackTrace": [
        "org.neo4j.kernel.impl.api.store.DiskLayer.relationshipVisit(DiskLayer.java:432)",
        "org.neo4j.kernel.impl.api.store.CacheLayer.relationshipVisit(CacheLayer.java:345)",
        "org.neo4j.kernel.impl.api.StateHandlingStatementOperations.relationshipVisit(StateHandlingStatementOperations.java:1409)",
        "org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.relationshipVisit(ConstraintEnforcingEntityOperations.java:417)",
        "org.neo4j.kernel.impl.api.OperationsFacade.relationshipVisit(OperationsFacade.java:512)",
        "org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getRelationshipById(GraphDatabaseFacade.java:304)",
        "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:176)",
        "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:659)",
        "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:812)",
        "java.lang.reflect.Method.invoke(Method.java:508)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
        "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
        "java.lang.Thread.run(Thread.java:785)"
      ],
      "message": "Unable to load RELATIONSHIP with id 1234.",
      "errors": [
        {
          "code": "Neo.ClientError.Statement.EntityNotFound",
          "message": "Unable to load RELATIONSHIP with id 1234."
        }
      ]
    },
    "fullname": "org.neo4j.graphdb.NotFoundException",
    "stackTrace": [
      "org.neo4j.kernel.impl.factory.GraphDatabaseFacade.getRelationshipById(GraphDatabaseFacade.java:309)",
      "org.neo4j.server.rest.web.DatabaseActions.relationship(DatabaseActions.java:176)",
      "org.neo4j.server.rest.web.DatabaseActions.removeRelationshipProperty(DatabaseActions.java:659)",
      "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteRelationshipProperty(RestfulGraphDatabase.java:812)",
      "java.lang.reflect.Method.invoke(Method.java:508)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
      "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
      "java.lang.Thread.run(Thread.java:785)"
    ],
    "message": "Relationship 1234 not found",
    "errors": [
      {
        "code": "Neo.ClientError.Statement.EntityNotFound",
        "message": "Relationship 1234 not found"
      }
    ]
  },
  "errors": [
    {
      "code": "Neo.ClientError.Statement.EntityNotFound",
      "message": "org.neo4j.graphdb.NotFoundException: Relationship 1234 not found"
    }
  ]
}

Node labels

Adding a label to a node

alt
Figure 52. Starting Graph
alt
Figure 53. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/219/labels

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

"Person"

Example response

  • 204: No Content

Adding multiple labels to a node

alt
Figure 54. Starting Graph
alt
Figure 55. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/230/labels

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

[ "Person", "Actor" ]

Example response

  • 204: No Content

Adding a label with an invalid name

Labels with empty names are not allowed, however, all other valid strings are accepted as label names. Adding an invalid label to a node will lead to a HTTP 400 response.

Example request

  • POST http://localhost:7474/db/data/node/237/labels

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

""

Example response

  • 400: Bad Request

  • Content-Type: application/json; charset=UTF-8

{
  "message": "Unable to add label, see nested exception.",
  "exception": "BadInputException",
  "fullname": "org.neo4j.server.rest.repr.BadInputException",
  "stackTrace": [
    "org.neo4j.server.rest.web.DatabaseActions.addLabelToNode(DatabaseActions.java:311)",
    "org.neo4j.server.rest.web.RestfulGraphDatabase.addNodeLabel(RestfulGraphDatabase.java:446)",
    "java.lang.reflect.Method.invoke(Method.java:508)",
    "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
    "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
    "java.lang.Thread.run(Thread.java:785)"
  ],
  "cause": {
    "exception": "ConstraintViolationException",
    "cause": {
      "exception": "IllegalTokenNameException",
      "fullname": "org.neo4j.kernel.api.exceptions.schema.IllegalTokenNameException",
      "stackTrace": [
        "org.neo4j.kernel.impl.api.DataIntegrityValidatingStatementOperations.checkValidTokenName(DataIntegrityValidatingStatementOperations.java:255)",
        "org.neo4j.kernel.impl.api.DataIntegrityValidatingStatementOperations.labelGetOrCreateForName(DataIntegrityValidatingStatementOperations.java:88)",
        "org.neo4j.kernel.impl.api.OperationsFacade.labelGetOrCreateForName(OperationsFacade.java:893)",
        "org.neo4j.kernel.impl.core.NodeProxy.addLabel(NodeProxy.java:582)",
        "org.neo4j.server.rest.web.DatabaseActions.addLabelToNode(DatabaseActions.java:306)",
        "org.neo4j.server.rest.web.RestfulGraphDatabase.addNodeLabel(RestfulGraphDatabase.java:446)",
        "java.lang.reflect.Method.invoke(Method.java:508)",
        "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
        "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
        "java.lang.Thread.run(Thread.java:785)"
      ],
      "message": "\u0027\u0027 is not a valid token name. Only non-null, non-empty strings are allowed.",
      "errors": [
        {
          "code": "Neo.ClientError.Schema.TokenNameError",
          "message": "\u0027\u0027 is not a valid token name. Only non-null, non-empty strings are allowed."
        }
      ]
    },
    "fullname": "org.neo4j.graphdb.ConstraintViolationException",
    "stackTrace": [
      "org.neo4j.kernel.impl.core.NodeProxy.addLabel(NodeProxy.java:592)",
      "org.neo4j.server.rest.web.DatabaseActions.addLabelToNode(DatabaseActions.java:306)",
      "org.neo4j.server.rest.web.RestfulGraphDatabase.addNodeLabel(RestfulGraphDatabase.java:446)",
      "java.lang.reflect.Method.invoke(Method.java:508)",
      "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:144)",
      "org.neo4j.server.rest.web.CollectUserAgentFilter.doFilter(CollectUserAgentFilter.java:69)",
      "java.lang.Thread.run(Thread.java:785)"
    ],
    "message": "Invalid label name \u0027\u0027.",
    "errors": [
      {
        "code": "Neo.ClientError.Schema.ConstraintValidationFailed",
        "message": "Invalid label name \u0027\u0027."
      }
    ]
  },
  "errors": [
    {
      "code": "Neo.ClientError.Request.InvalidFormat",
      "message": "Unable to add label, see nested exception."
    }
  ]
}

Replacing labels on a node

This removes any labels currently on a node, and replaces them with the labels passed in as the request body.

alt
Figure 56. Starting Graph
alt
Figure 57. Final Graph

Example request

  • PUT http://localhost:7474/db/data/node/220/labels

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

[ "Actor", "Director" ]

Example response

  • 204: No Content

Removing a label from a node

alt
Figure 58. Starting Graph
alt
Figure 59. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/221/labels/Person

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Removing a non-existent label from a node

alt
Figure 60. Starting Graph
alt
Figure 61. Final Graph

Example request

  • DELETE http://localhost:7474/db/data/node/222/labels/Person

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Listing labels for a node

alt
Figure 62. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/226/labels

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ "Director", "Actor" ]

Get all nodes with a label

alt
Figure 63. Final Graph

Example request

  • GET http://localhost:7474/db/data/label/Actor/nodes

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 231,
    "labels" : [ "Actor" ]
  },
  "data" : {
    "name" : "Donald Sutherland"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/231/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/231/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/231/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/231/relationships",
  "labels" : "http://localhost:7474/db/data/node/231/labels",
  "traverse" : "http://localhost:7474/db/data/node/231/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/231/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/231/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/231/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/231",
  "incoming_relationships" : "http://localhost:7474/db/data/node/231/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/231/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/231/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 233,
    "labels" : [ "Director", "Actor" ]
  },
  "data" : {
    "name" : "Clint Eastwood"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/233/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/233/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/233/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/233/relationships",
  "labels" : "http://localhost:7474/db/data/node/233/labels",
  "traverse" : "http://localhost:7474/db/data/node/233/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/233/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/233/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/233/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/233",
  "incoming_relationships" : "http://localhost:7474/db/data/node/233/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/233/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/233/relationships/in/{-list|&|types}"
} ]

Get nodes by label and property

You can retrieve all nodes with a given label and property by passing one property as a query parameter. Notice that the property value is JSON-encoded and then URL-encoded.

If there is an index available on the label/property combination you send, that index will be used. If no index is available, all nodes with the given label will be filtered through to find matching nodes.

Currently, it is not possible to search using multiple properties.

alt
Figure 64. Final Graph

Example request

  • GET http://localhost:7474/db/data/label/Person/nodes?name=%22Clint+Eastwood%22

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 236,
    "labels" : [ "Person" ]
  },
  "data" : {
    "name" : "Clint Eastwood"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/236/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/236/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/236/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/236/relationships",
  "labels" : "http://localhost:7474/db/data/node/236/labels",
  "traverse" : "http://localhost:7474/db/data/node/236/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/236/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/236/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/236/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/236",
  "incoming_relationships" : "http://localhost:7474/db/data/node/236/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/236/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/236/relationships/in/{-list|&|types}"
} ]

List all labels

By default, the server will return labels in use only. If you also want to return labels not in use, append the "in_use=0" query parameter.

Example request

  • GET http://localhost:7474/db/data/labels

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ "Actor", "Person", "Director" ]

Node degree

The node degree is the number of relationships associated with a node. Neo4j stores the degree for each node, making this a useful mechanism to quickly get the number of relationships a node has. You can also optionally filter degree by direction and/or relationship type.

Get the degree of a node

Return the total number of relationships associated with a node.

alt
Figure 65. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/175/degree/all

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

2

Get the degree of a node by direction

Return the number of relationships of a particular direction for a node. Specify all, in or out.

alt
Figure 66. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/178/degree/out

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

2

Get the degree of a node by direction and types

If you are only interested in the degree of a particular relationship type, or a set of relationship types, you specify relationship types after the direction. You can combine multiple relationship types by using the & character.

alt
Figure 67. Final Graph

Example request

  • GET http://localhost:7474/db/data/node/172/degree/out/KNOWS&LIKES

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

3

Indexing

How to use schema based indexes from the REST API. For more details about indexes and the optional schema in Neo4j, see the Developer Manual.

For how to use manual indexes ("legacy indexes") see Legacy indexing.

Create index

This will start a background job in the database that will create and populate the index. You can check the status of your index by listing all the indexes for the relevant label.

Example request

  • POST http://localhost:7474/db/data/schema/index/label_1480348121136_1

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "property_keys" : [ "property_1480348121136_1" ]
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "label" : "label_1480348121136_1",
  "property_keys" : [ "property_1480348121136_1" ]
}

List indexes for a label

Example request

  • GET http://localhost:7474/db/data/schema/index/label_1480348120839_1

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348120839_1" ],
  "label" : "label_1480348120839_1"
} ]

Drop index

Drop index

Example request

  • DELETE http://localhost:7474/db/data/schema/index/label_1480348121022_1/property_1480348121022_1

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Constraints

Create uniqueness constraint

Create a uniqueness constraint on a property.

Example request

  • POST http://localhost:7474/db/data/schema/constraint/label_1480348106216_1/uniqueness/

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "property_keys" : [ "property_1480348106216_1" ]
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "label" : "label_1480348106216_1",
  "type" : "UNIQUENESS",
  "property_keys" : [ "property_1480348106216_1" ]
}

Get a specific uniqueness constraint

Get a specific uniqueness constraint for a label and a property.

Example request

  • GET http://localhost:7474/db/data/schema/constraint/label_1480348107273_1/uniqueness/property_1480348107273_1

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348107273_1" ],
  "label" : "label_1480348107273_1",
  "type" : "UNIQUENESS"
} ]

Get all uniqueness constraints for a label

Example request

  • GET http://localhost:7474/db/data/schema/constraint/label_1480348107102_1/uniqueness/

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348107102_2" ],
  "label" : "label_1480348107102_1",
  "type" : "UNIQUENESS"
}, {
  "property_keys" : [ "property_1480348107102_1" ],
  "label" : "label_1480348107102_1",
  "type" : "UNIQUENESS"
} ]

Drop uniqueness constraint

Drop uniqueness constraint for a label and a property.

Example request

  • DELETE http://localhost:7474/db/data/schema/constraint/label_1480348106015_1/uniqueness/property_1480348106015_1

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Get a specific node property existence constraint

Get a specific node property existence constraint for a label and a property.

Example request

  • GET http://localhost:7474/db/data/schema/constraint/label_1480348177274_1/existence/property_1480348177274_1

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348177274_1" ],
  "label" : "label_1480348177274_1",
  "type" : "NODE_PROPERTY_EXISTENCE"
} ]

Get all node property existence constraints for a label

Example request

  • GET http://localhost:7474/db/data/schema/constraint/label_1480348177408_1/existence/

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348177408_2" ],
  "label" : "label_1480348177408_1",
  "type" : "NODE_PROPERTY_EXISTENCE"
}, {
  "property_keys" : [ "property_1480348177408_1" ],
  "label" : "label_1480348177408_1",
  "type" : "NODE_PROPERTY_EXISTENCE"
} ]

Get all constraints for a label

Example request

  • GET http://localhost:7474/db/data/schema/constraint/label_1480348106836_1

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348106836_1" ],
  "label" : "label_1480348106836_1",
  "type" : "UNIQUENESS"
} ]

Get a specific relationship property existence constraint

Get a specific relationship property existence constraint for a label and a property.

Example request

  • GET http://localhost:7474/db/data/schema/relationship/constraint/relationshipType_1480348174663_1/existence/property_1480348174663_1

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "relationshipType" : "relationshipType_1480348174663_1",
  "property_keys" : [ "property_1480348174663_1" ],
  "type" : "RELATIONSHIP_PROPERTY_EXISTENCE"
} ]

Get all relationship property existence constraints for a type

Example request

  • GET http://localhost:7474/db/data/schema/relationship/constraint/relationshipType_1480348177024_1/existence/

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "relationshipType" : "relationshipType_1480348177024_1",
  "property_keys" : [ "property_1480348177024_2" ],
  "type" : "RELATIONSHIP_PROPERTY_EXISTENCE"
}, {
  "relationshipType" : "relationshipType_1480348177024_1",
  "property_keys" : [ "property_1480348177024_1" ],
  "type" : "RELATIONSHIP_PROPERTY_EXISTENCE"
} ]

Get all constraints

Example request

  • GET http://localhost:7474/db/data/schema/constraint

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "property_keys" : [ "property_1480348106216_1" ],
  "label" : "label_1480348106216_1",
  "type" : "UNIQUENESS"
}, {
  "property_keys" : [ "property_1480348106379_1" ],
  "label" : "label_1480348106379_1",
  "type" : "UNIQUENESS"
} ]

Traversals

The Traversal REST Endpoint executes arbitrary Javascript code under the hood as part of the evaluators definitions. In hosted and open environments, this may constitute a security risk. In these case, consider using declarative approaches like Cypher or write your own server side extension executing the interesting traversals with the Java API (see Extending Neo4j). To properly secure your server, see Operations Manual → Security.

Traversals are performed from a start node. The traversal is controlled by the URI and the body sent with the request.

returnType

The kind of objects in the response is determined by 'traverse/{returnType}' in the URL. returnType can have one of these values:

  • node

  • relationship

  • path: contains full representations of start and end node, the rest are URIs.

  • fullpath: contains full representations of all nodes and relationships.

To decide how the graph should be traversed you can use these parameters in the request body:

order

Decides in which order to visit nodes. Possible values:

relationships

Decides which relationship types and directions should be followed. The direction can be one of:

  • all

  • in

  • out

uniqueness

Decides how uniqueness should be calculated. For details on different uniqueness values see the Java API on Uniqueness. Possible values:

  • node_global

  • none

  • relationship_global

  • node_path

  • relationship_path

prune_evaluator

Decides whether the traverser should continue down that path or if it should be pruned so that the traverser won’t continue down that path. You can write your own prune evaluator as (see Traversal using a return filter or use the built-in none prune evaluator.

return_filter

Decides whether the current position should be included in the result. You can provide your own code for this (see Traversal using a return filter), or use one of the built-in filters:

  • all

  • all_but_start_node

max_depth

Is a short-hand way of specifying a prune evaluator which prunes after a certain depth. If not specified a max depth of 1 is used and if a prune_evaluator is specified instead of a max_depth, no max depth limit is set.

The position object in the body of the return_filter and prune_evaluator is a link:javadocs/org/neo4j/graphdb/Path.html[Path] object representing the path from the start node to the current traversal position.

Out of the box, the REST API supports JavaScript code in filters and evaluators. The script body will be executed in a Java context which has access to the full Neo4j Java API. See the examples for the exact syntax of the request.

Traversal using a return filter

In this example, the none prune evaluator is used and a return filter is supplied in order to return all names containing "t". The result is to be returned as nodes and the max depth is set to 3.

alt
Figure 68. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/217/traverse/node

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "relationships" : [ {
    "type" : "knows",
    "direction" : "all"
  }, {
    "type" : "loves",
    "direction" : "all"
  } ],
  "return_filter" : {
    "language" : "javascript",
    "body" : "position.endNode().getProperty('name').toLowerCase().contains('t')"
  },
  "uniqueness" : "node_global",
  "max_depth" : 3,
  "order" : "breadth_first",
  "prune_evaluator" : {
    "language" : "javascript",
    "body" : "position.length() > 10"
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 217,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Root"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/217/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/217/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/217/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/217/relationships",
  "labels" : "http://localhost:7474/db/data/node/217/labels",
  "traverse" : "http://localhost:7474/db/data/node/217/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/217/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/217/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/217/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/217",
  "incoming_relationships" : "http://localhost:7474/db/data/node/217/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/217/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/217/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 220,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Mattias"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/220/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/220/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/220/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/220/relationships",
  "labels" : "http://localhost:7474/db/data/node/220/labels",
  "traverse" : "http://localhost:7474/db/data/node/220/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/220/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/220/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/220/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/220",
  "incoming_relationships" : "http://localhost:7474/db/data/node/220/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/220/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/220/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 218,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Tobias"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/218/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/218/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/218/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/218/relationships",
  "labels" : "http://localhost:7474/db/data/node/218/labels",
  "traverse" : "http://localhost:7474/db/data/node/218/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/218/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/218/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/218/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/218",
  "incoming_relationships" : "http://localhost:7474/db/data/node/218/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/218/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/218/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 223,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Peter"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/223/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/223/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/223/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/223/relationships",
  "labels" : "http://localhost:7474/db/data/node/223/labels",
  "traverse" : "http://localhost:7474/db/data/node/223/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/223/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/223/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/223/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/223",
  "incoming_relationships" : "http://localhost:7474/db/data/node/223/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/223/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/223/relationships/in/{-list|&|types}"
} ]

Return relationships from a traversal

alt
Figure 69. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/213/traverse/relationship

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "order" : "breadth_first",
  "uniqueness" : "none",
  "return_filter" : {
    "language" : "builtin",
    "name" : "all"
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "extensions" : { },
  "metadata" : {
    "id" : 138,
    "type" : "own"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/213",
  "property" : "http://localhost:7474/db/data/relationship/138/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/138",
  "end" : "http://localhost:7474/db/data/node/212",
  "type" : "own",
  "properties" : "http://localhost:7474/db/data/relationship/138/properties"
}, {
  "extensions" : { },
  "metadata" : {
    "id" : 137,
    "type" : "know"
  },
  "data" : { },
  "start" : "http://localhost:7474/db/data/node/213",
  "property" : "http://localhost:7474/db/data/relationship/137/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/137",
  "end" : "http://localhost:7474/db/data/node/214",
  "type" : "know",
  "properties" : "http://localhost:7474/db/data/relationship/137/properties"
} ]

Return paths from a traversal

alt
Figure 70. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/203/traverse/path

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "order" : "breadth_first",
  "uniqueness" : "none",
  "return_filter" : {
    "language" : "builtin",
    "name" : "all"
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "relationships" : [ ],
  "nodes" : [ "http://localhost:7474/db/data/node/203" ],
  "directions" : [ ],
  "start" : "http://localhost:7474/db/data/node/203",
  "length" : 0,
  "end" : "http://localhost:7474/db/data/node/203"
}, {
  "relationships" : [ "http://localhost:7474/db/data/relationship/130" ],
  "nodes" : [ "http://localhost:7474/db/data/node/203", "http://localhost:7474/db/data/node/202" ],
  "directions" : [ "->" ],
  "start" : "http://localhost:7474/db/data/node/203",
  "length" : 1,
  "end" : "http://localhost:7474/db/data/node/202"
}, {
  "relationships" : [ "http://localhost:7474/db/data/relationship/129" ],
  "nodes" : [ "http://localhost:7474/db/data/node/203", "http://localhost:7474/db/data/node/204" ],
  "directions" : [ "->" ],
  "start" : "http://localhost:7474/db/data/node/203",
  "length" : 1,
  "end" : "http://localhost:7474/db/data/node/204"
} ]

Traversal returning nodes below a certain depth

Here, all nodes at a traversal depth below 3 are returned.

alt
Figure 71. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/205/traverse/node

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "return_filter" : {
    "language" : "javascript",
    "body" : "position.length()<3;"
  },
  "prune_evaluator" : {
    "name" : "none",
    "language" : "builtin"
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 205,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Root"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/205/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/205/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/205/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/205/relationships",
  "labels" : "http://localhost:7474/db/data/node/205/labels",
  "traverse" : "http://localhost:7474/db/data/node/205/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/205/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/205/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/205/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/205",
  "incoming_relationships" : "http://localhost:7474/db/data/node/205/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/205/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/205/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 207,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Johan"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/207/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/207/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/207/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/207/relationships",
  "labels" : "http://localhost:7474/db/data/node/207/labels",
  "traverse" : "http://localhost:7474/db/data/node/207/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/207/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/207/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/207/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/207",
  "incoming_relationships" : "http://localhost:7474/db/data/node/207/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/207/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/207/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 209,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Emil"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/209/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/209/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/209/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/209/relationships",
  "labels" : "http://localhost:7474/db/data/node/209/labels",
  "traverse" : "http://localhost:7474/db/data/node/209/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/209/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/209/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/209/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/209",
  "incoming_relationships" : "http://localhost:7474/db/data/node/209/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/209/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/209/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 208,
    "labels" : [ ]
  },
  "data" : {
    "name" : "Mattias"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/208/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/208/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/208/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/208/relationships",
  "labels" : "http://localhost:7474/db/data/node/208/labels",
  "traverse" : "http://localhost:7474/db/data/node/208/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/208/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/208/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/208/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/208",
  "incoming_relationships" : "http://localhost:7474/db/data/node/208/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/208/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/208/relationships/in/{-list|&|types}"
} ]

Creating a paged traverser

Paged traversers are created by POST-ing a traversal description to the link identified by the paged_traverser key in a node representation. When creating a paged traverser, the same options apply as for a regular traverser, meaning that node, path, or fullpath, can be targeted.

Example request

  • POST http://localhost:7474/db/data/node/297/paged/traverse/node

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "prune_evaluator" : {
    "language" : "builtin",
    "name" : "none"
  },
  "return_filter" : {
    "language" : "javascript",
    "body" : "position.endNode().getProperty('name').contains('1');"
  },
  "order" : "depth_first",
  "relationships" : {
    "type" : "NEXT",
    "direction" : "out"
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/node/297/paged/traverse/node/7e8be85dbc6c4082b58f14f453298998

[ {
  "metadata" : {
    "id" : 298,
    "labels" : [ ]
  },
  "data" : {
    "name" : "1"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/298/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/298/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/298/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/298/relationships",
  "labels" : "http://localhost:7474/db/data/node/298/labels",
  "traverse" : "http://localhost:7474/db/data/node/298/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/298/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/298/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/298/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/298",
  "incoming_relationships" : "http://localhost:7474/db/data/node/298/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/298/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/298/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 307,
    "labels" : [ ]
  },
  "data" : {
    "name" : "10"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/307/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/307/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/307/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/307/relationships",
  "labels" : "http://localhost:7474/db/data/node/307/labels",
  "traverse" : "http://localhost:7474/db/data/node/307/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/307/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/307/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/307/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/307",
  "incoming_relationships" : "http://localhost:7474/db/data/node/307/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/307/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/307/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 308,
    "labels" : [ ]
  },
  "data" : {
    "name" : "11"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/308/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/308/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/308/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/308/relationships",
  "labels" : "http://localhost:7474/db/data/node/308/labels",
  "traverse" : "http://localhost:7474/db/data/node/308/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/308/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/308/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/308/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/308",
  "incoming_relationships" : "http://localhost:7474/db/data/node/308/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/308/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/308/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 309,
    "labels" : [ ]
  },
  "data" : {
    "name" : "12"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/309/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/309/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/309/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/309/relationships",
  "labels" : "http://localhost:7474/db/data/node/309/labels",
  "traverse" : "http://localhost:7474/db/data/node/309/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/309/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/309/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/309/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/309",
  "incoming_relationships" : "http://localhost:7474/db/data/node/309/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/309/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/309/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 310,
    "labels" : [ ]
  },
  "data" : {
    "name" : "13"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/310/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/310/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/310/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/310/relationships",
  "labels" : "http://localhost:7474/db/data/node/310/labels",
  "traverse" : "http://localhost:7474/db/data/node/310/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/310/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/310/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/310/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/310",
  "incoming_relationships" : "http://localhost:7474/db/data/node/310/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/310/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/310/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 311,
    "labels" : [ ]
  },
  "data" : {
    "name" : "14"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/311/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/311/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/311/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/311/relationships",
  "labels" : "http://localhost:7474/db/data/node/311/labels",
  "traverse" : "http://localhost:7474/db/data/node/311/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/311/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/311/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/311/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/311",
  "incoming_relationships" : "http://localhost:7474/db/data/node/311/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/311/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/311/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 312,
    "labels" : [ ]
  },
  "data" : {
    "name" : "15"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/312/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/312/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/312/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/312/relationships",
  "labels" : "http://localhost:7474/db/data/node/312/labels",
  "traverse" : "http://localhost:7474/db/data/node/312/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/312/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/312/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/312/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/312",
  "incoming_relationships" : "http://localhost:7474/db/data/node/312/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/312/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/312/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 313,
    "labels" : [ ]
  },
  "data" : {
    "name" : "16"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/313/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/313/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/313/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/313/relationships",
  "labels" : "http://localhost:7474/db/data/node/313/labels",
  "traverse" : "http://localhost:7474/db/data/node/313/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/313/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/313/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/313/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/313",
  "incoming_relationships" : "http://localhost:7474/db/data/node/313/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/313/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/313/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 314,
    "labels" : [ ]
  },
  "data" : {
    "name" : "17"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/314/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/314/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/314/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/314/relationships",
  "labels" : "http://localhost:7474/db/data/node/314/labels",
  "traverse" : "http://localhost:7474/db/data/node/314/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/314/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/314/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/314/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/314",
  "incoming_relationships" : "http://localhost:7474/db/data/node/314/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/314/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/314/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 315,
    "labels" : [ ]
  },
  "data" : {
    "name" : "18"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/315/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/315/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/315/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/315/relationships",
  "labels" : "http://localhost:7474/db/data/node/315/labels",
  "traverse" : "http://localhost:7474/db/data/node/315/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/315/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/315/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/315/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/315",
  "incoming_relationships" : "http://localhost:7474/db/data/node/315/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/315/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/315/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 316,
    "labels" : [ ]
  },
  "data" : {
    "name" : "19"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/316/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/316/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/316/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/316/relationships",
  "labels" : "http://localhost:7474/db/data/node/316/labels",
  "traverse" : "http://localhost:7474/db/data/node/316/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/316/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/316/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/316/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/316",
  "incoming_relationships" : "http://localhost:7474/db/data/node/316/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/316/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/316/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 318,
    "labels" : [ ]
  },
  "data" : {
    "name" : "21"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/318/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/318/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/318/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/318/relationships",
  "labels" : "http://localhost:7474/db/data/node/318/labels",
  "traverse" : "http://localhost:7474/db/data/node/318/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/318/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/318/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/318/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/318",
  "incoming_relationships" : "http://localhost:7474/db/data/node/318/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/318/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/318/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 328,
    "labels" : [ ]
  },
  "data" : {
    "name" : "31"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/328/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/328/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/328/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/328/relationships",
  "labels" : "http://localhost:7474/db/data/node/328/labels",
  "traverse" : "http://localhost:7474/db/data/node/328/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/328/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/328/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/328/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/328",
  "incoming_relationships" : "http://localhost:7474/db/data/node/328/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/328/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/328/relationships/in/{-list|&|types}"
} ]

Paging through the results of a paged traverser

Paged traversers hold state on the server, and allow clients to page through the results of a traversal. To progress to the next page of traversal results, the client issues a HTTP GET request on the paged traversal URI which causes the traversal to fill the next page (or partially fill it if insufficient results are available).

Note that if a traverser expires through inactivity it will cause a 404 response on the next GET request. Traversers' leases are renewed on every successful access for the same amount of time as originally specified.

When the paged traverser reaches the end of its results, the client can expect a 404 response as the traverser is disposed by the server.

Example request

  • GET http://localhost:7474/db/data/node/330/paged/traverse/node/5e0204746c7a44c792df13a24f0e26b0

  • Accept: application/json

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 661,
    "labels" : [ ]
  },
  "data" : {
    "name" : "331"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/661/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/661/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/661/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/661/relationships",
  "labels" : "http://localhost:7474/db/data/node/661/labels",
  "traverse" : "http://localhost:7474/db/data/node/661/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/661/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/661/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/661/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/661",
  "incoming_relationships" : "http://localhost:7474/db/data/node/661/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/661/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/661/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 671,
    "labels" : [ ]
  },
  "data" : {
    "name" : "341"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/671/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/671/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/671/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/671/relationships",
  "labels" : "http://localhost:7474/db/data/node/671/labels",
  "traverse" : "http://localhost:7474/db/data/node/671/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/671/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/671/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/671/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/671",
  "incoming_relationships" : "http://localhost:7474/db/data/node/671/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/671/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/671/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 681,
    "labels" : [ ]
  },
  "data" : {
    "name" : "351"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/681/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/681/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/681/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/681/relationships",
  "labels" : "http://localhost:7474/db/data/node/681/labels",
  "traverse" : "http://localhost:7474/db/data/node/681/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/681/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/681/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/681/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/681",
  "incoming_relationships" : "http://localhost:7474/db/data/node/681/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/681/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/681/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 691,
    "labels" : [ ]
  },
  "data" : {
    "name" : "361"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/691/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/691/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/691/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/691/relationships",
  "labels" : "http://localhost:7474/db/data/node/691/labels",
  "traverse" : "http://localhost:7474/db/data/node/691/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/691/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/691/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/691/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/691",
  "incoming_relationships" : "http://localhost:7474/db/data/node/691/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/691/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/691/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 701,
    "labels" : [ ]
  },
  "data" : {
    "name" : "371"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/701/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/701/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/701/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/701/relationships",
  "labels" : "http://localhost:7474/db/data/node/701/labels",
  "traverse" : "http://localhost:7474/db/data/node/701/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/701/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/701/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/701/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/701",
  "incoming_relationships" : "http://localhost:7474/db/data/node/701/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/701/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/701/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 711,
    "labels" : [ ]
  },
  "data" : {
    "name" : "381"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/711/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/711/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/711/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/711/relationships",
  "labels" : "http://localhost:7474/db/data/node/711/labels",
  "traverse" : "http://localhost:7474/db/data/node/711/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/711/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/711/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/711/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/711",
  "incoming_relationships" : "http://localhost:7474/db/data/node/711/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/711/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/711/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 721,
    "labels" : [ ]
  },
  "data" : {
    "name" : "391"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/721/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/721/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/721/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/721/relationships",
  "labels" : "http://localhost:7474/db/data/node/721/labels",
  "traverse" : "http://localhost:7474/db/data/node/721/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/721/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/721/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/721/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/721",
  "incoming_relationships" : "http://localhost:7474/db/data/node/721/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/721/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/721/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 731,
    "labels" : [ ]
  },
  "data" : {
    "name" : "401"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/731/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/731/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/731/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/731/relationships",
  "labels" : "http://localhost:7474/db/data/node/731/labels",
  "traverse" : "http://localhost:7474/db/data/node/731/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/731/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/731/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/731/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/731",
  "incoming_relationships" : "http://localhost:7474/db/data/node/731/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/731/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/731/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 740,
    "labels" : [ ]
  },
  "data" : {
    "name" : "410"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/740/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/740/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/740/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/740/relationships",
  "labels" : "http://localhost:7474/db/data/node/740/labels",
  "traverse" : "http://localhost:7474/db/data/node/740/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/740/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/740/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/740/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/740",
  "incoming_relationships" : "http://localhost:7474/db/data/node/740/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/740/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/740/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 741,
    "labels" : [ ]
  },
  "data" : {
    "name" : "411"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/741/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/741/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/741/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/741/relationships",
  "labels" : "http://localhost:7474/db/data/node/741/labels",
  "traverse" : "http://localhost:7474/db/data/node/741/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/741/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/741/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/741/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/741",
  "incoming_relationships" : "http://localhost:7474/db/data/node/741/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/741/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/741/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 742,
    "labels" : [ ]
  },
  "data" : {
    "name" : "412"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/742/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/742/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/742/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/742/relationships",
  "labels" : "http://localhost:7474/db/data/node/742/labels",
  "traverse" : "http://localhost:7474/db/data/node/742/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/742/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/742/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/742/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/742",
  "incoming_relationships" : "http://localhost:7474/db/data/node/742/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/742/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/742/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 743,
    "labels" : [ ]
  },
  "data" : {
    "name" : "413"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/743/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/743/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/743/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/743/relationships",
  "labels" : "http://localhost:7474/db/data/node/743/labels",
  "traverse" : "http://localhost:7474/db/data/node/743/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/743/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/743/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/743/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/743",
  "incoming_relationships" : "http://localhost:7474/db/data/node/743/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/743/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/743/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 744,
    "labels" : [ ]
  },
  "data" : {
    "name" : "414"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/744/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/744/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/744/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/744/relationships",
  "labels" : "http://localhost:7474/db/data/node/744/labels",
  "traverse" : "http://localhost:7474/db/data/node/744/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/744/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/744/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/744/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/744",
  "incoming_relationships" : "http://localhost:7474/db/data/node/744/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/744/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/744/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 745,
    "labels" : [ ]
  },
  "data" : {
    "name" : "415"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/745/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/745/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/745/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/745/relationships",
  "labels" : "http://localhost:7474/db/data/node/745/labels",
  "traverse" : "http://localhost:7474/db/data/node/745/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/745/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/745/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/745/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/745",
  "incoming_relationships" : "http://localhost:7474/db/data/node/745/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/745/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/745/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 746,
    "labels" : [ ]
  },
  "data" : {
    "name" : "416"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/746/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/746/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/746/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/746/relationships",
  "labels" : "http://localhost:7474/db/data/node/746/labels",
  "traverse" : "http://localhost:7474/db/data/node/746/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/746/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/746/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/746/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/746",
  "incoming_relationships" : "http://localhost:7474/db/data/node/746/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/746/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/746/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 747,
    "labels" : [ ]
  },
  "data" : {
    "name" : "417"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/747/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/747/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/747/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/747/relationships",
  "labels" : "http://localhost:7474/db/data/node/747/labels",
  "traverse" : "http://localhost:7474/db/data/node/747/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/747/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/747/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/747/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/747",
  "incoming_relationships" : "http://localhost:7474/db/data/node/747/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/747/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/747/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 748,
    "labels" : [ ]
  },
  "data" : {
    "name" : "418"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/748/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/748/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/748/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/748/relationships",
  "labels" : "http://localhost:7474/db/data/node/748/labels",
  "traverse" : "http://localhost:7474/db/data/node/748/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/748/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/748/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/748/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/748",
  "incoming_relationships" : "http://localhost:7474/db/data/node/748/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/748/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/748/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 749,
    "labels" : [ ]
  },
  "data" : {
    "name" : "419"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/749/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/749/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/749/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/749/relationships",
  "labels" : "http://localhost:7474/db/data/node/749/labels",
  "traverse" : "http://localhost:7474/db/data/node/749/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/749/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/749/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/749/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/749",
  "incoming_relationships" : "http://localhost:7474/db/data/node/749/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/749/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/749/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 751,
    "labels" : [ ]
  },
  "data" : {
    "name" : "421"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/751/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/751/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/751/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/751/relationships",
  "labels" : "http://localhost:7474/db/data/node/751/labels",
  "traverse" : "http://localhost:7474/db/data/node/751/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/751/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/751/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/751/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/751",
  "incoming_relationships" : "http://localhost:7474/db/data/node/751/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/751/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/751/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 761,
    "labels" : [ ]
  },
  "data" : {
    "name" : "431"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/761/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/761/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/761/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/761/relationships",
  "labels" : "http://localhost:7474/db/data/node/761/labels",
  "traverse" : "http://localhost:7474/db/data/node/761/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/761/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/761/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/761/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/761",
  "incoming_relationships" : "http://localhost:7474/db/data/node/761/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/761/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/761/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 771,
    "labels" : [ ]
  },
  "data" : {
    "name" : "441"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/771/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/771/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/771/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/771/relationships",
  "labels" : "http://localhost:7474/db/data/node/771/labels",
  "traverse" : "http://localhost:7474/db/data/node/771/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/771/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/771/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/771/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/771",
  "incoming_relationships" : "http://localhost:7474/db/data/node/771/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/771/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/771/relationships/in/{-list|&|types}"
} ]

Paged traverser page size

The default page size is 50 items, but depending on the application larger or smaller pages sizes might be appropriate. This can be set by adding a pageSize query parameter.

Example request

  • POST http://localhost:7474/db/data/node/33/paged/traverse/node?pageSize=1

  • Accept: application/json

  • Content-Type: application/json

{
  "prune_evaluator" : {
    "language" : "builtin",
    "name" : "none"
  },
  "return_filter" : {
    "language" : "javascript",
    "body" : "position.endNode().getProperty('name').contains('1');"
  },
  "order" : "depth_first",
  "relationships" : {
    "type" : "NEXT",
    "direction" : "out"
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/node/33/paged/traverse/node/9788e48bdc0b44c08811bad98c9cb4da

[ {
  "metadata" : {
    "id" : 34,
    "labels" : [ ]
  },
  "data" : {
    "name" : "1"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/34/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/34/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/34/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/34/relationships",
  "labels" : "http://localhost:7474/db/data/node/34/labels",
  "traverse" : "http://localhost:7474/db/data/node/34/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/34/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/34/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/34/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/34",
  "incoming_relationships" : "http://localhost:7474/db/data/node/34/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/34/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/34/relationships/in/{-list|&|types}"
} ]

Paged traverser timeout

The default timeout for a paged traverser is 60 seconds, but depending on the application larger or smaller timeouts might be appropriate. This can be set by adding a leaseTime query parameter with the number of seconds the paged traverser should last.

Example request

  • POST http://localhost:7474/db/data/node/807/paged/traverse/node?leaseTime=10

  • Accept: application/json

  • Content-Type: application/json

{
  "prune_evaluator" : {
    "language" : "builtin",
    "name" : "none"
  },
  "return_filter" : {
    "language" : "javascript",
    "body" : "position.endNode().getProperty('name').contains('1');"
  },
  "order" : "depth_first",
  "relationships" : {
    "type" : "NEXT",
    "direction" : "out"
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/node/807/paged/traverse/node/3d59ecbee2404055b9f2cea77ebd3429

[ {
  "metadata" : {
    "id" : 808,
    "labels" : [ ]
  },
  "data" : {
    "name" : "1"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/808/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/808/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/808/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/808/relationships",
  "labels" : "http://localhost:7474/db/data/node/808/labels",
  "traverse" : "http://localhost:7474/db/data/node/808/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/808/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/808/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/808/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/808",
  "incoming_relationships" : "http://localhost:7474/db/data/node/808/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/808/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/808/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 817,
    "labels" : [ ]
  },
  "data" : {
    "name" : "10"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/817/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/817/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/817/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/817/relationships",
  "labels" : "http://localhost:7474/db/data/node/817/labels",
  "traverse" : "http://localhost:7474/db/data/node/817/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/817/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/817/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/817/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/817",
  "incoming_relationships" : "http://localhost:7474/db/data/node/817/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/817/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/817/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 818,
    "labels" : [ ]
  },
  "data" : {
    "name" : "11"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/818/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/818/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/818/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/818/relationships",
  "labels" : "http://localhost:7474/db/data/node/818/labels",
  "traverse" : "http://localhost:7474/db/data/node/818/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/818/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/818/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/818/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/818",
  "incoming_relationships" : "http://localhost:7474/db/data/node/818/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/818/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/818/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 819,
    "labels" : [ ]
  },
  "data" : {
    "name" : "12"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/819/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/819/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/819/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/819/relationships",
  "labels" : "http://localhost:7474/db/data/node/819/labels",
  "traverse" : "http://localhost:7474/db/data/node/819/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/819/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/819/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/819/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/819",
  "incoming_relationships" : "http://localhost:7474/db/data/node/819/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/819/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/819/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 820,
    "labels" : [ ]
  },
  "data" : {
    "name" : "13"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/820/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/820/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/820/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/820/relationships",
  "labels" : "http://localhost:7474/db/data/node/820/labels",
  "traverse" : "http://localhost:7474/db/data/node/820/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/820/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/820/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/820/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/820",
  "incoming_relationships" : "http://localhost:7474/db/data/node/820/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/820/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/820/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 821,
    "labels" : [ ]
  },
  "data" : {
    "name" : "14"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/821/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/821/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/821/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/821/relationships",
  "labels" : "http://localhost:7474/db/data/node/821/labels",
  "traverse" : "http://localhost:7474/db/data/node/821/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/821/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/821/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/821/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/821",
  "incoming_relationships" : "http://localhost:7474/db/data/node/821/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/821/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/821/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 822,
    "labels" : [ ]
  },
  "data" : {
    "name" : "15"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/822/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/822/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/822/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/822/relationships",
  "labels" : "http://localhost:7474/db/data/node/822/labels",
  "traverse" : "http://localhost:7474/db/data/node/822/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/822/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/822/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/822/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/822",
  "incoming_relationships" : "http://localhost:7474/db/data/node/822/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/822/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/822/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 823,
    "labels" : [ ]
  },
  "data" : {
    "name" : "16"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/823/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/823/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/823/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/823/relationships",
  "labels" : "http://localhost:7474/db/data/node/823/labels",
  "traverse" : "http://localhost:7474/db/data/node/823/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/823/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/823/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/823/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/823",
  "incoming_relationships" : "http://localhost:7474/db/data/node/823/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/823/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/823/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 824,
    "labels" : [ ]
  },
  "data" : {
    "name" : "17"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/824/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/824/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/824/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/824/relationships",
  "labels" : "http://localhost:7474/db/data/node/824/labels",
  "traverse" : "http://localhost:7474/db/data/node/824/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/824/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/824/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/824/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/824",
  "incoming_relationships" : "http://localhost:7474/db/data/node/824/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/824/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/824/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 825,
    "labels" : [ ]
  },
  "data" : {
    "name" : "18"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/825/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/825/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/825/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/825/relationships",
  "labels" : "http://localhost:7474/db/data/node/825/labels",
  "traverse" : "http://localhost:7474/db/data/node/825/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/825/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/825/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/825/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/825",
  "incoming_relationships" : "http://localhost:7474/db/data/node/825/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/825/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/825/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 826,
    "labels" : [ ]
  },
  "data" : {
    "name" : "19"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/826/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/826/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/826/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/826/relationships",
  "labels" : "http://localhost:7474/db/data/node/826/labels",
  "traverse" : "http://localhost:7474/db/data/node/826/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/826/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/826/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/826/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/826",
  "incoming_relationships" : "http://localhost:7474/db/data/node/826/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/826/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/826/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 828,
    "labels" : [ ]
  },
  "data" : {
    "name" : "21"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/828/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/828/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/828/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/828/relationships",
  "labels" : "http://localhost:7474/db/data/node/828/labels",
  "traverse" : "http://localhost:7474/db/data/node/828/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/828/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/828/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/828/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/828",
  "incoming_relationships" : "http://localhost:7474/db/data/node/828/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/828/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/828/relationships/in/{-list|&|types}"
}, {
  "metadata" : {
    "id" : 838,
    "labels" : [ ]
  },
  "data" : {
    "name" : "31"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/838/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/838/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/838/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/838/relationships",
  "labels" : "http://localhost:7474/db/data/node/838/labels",
  "traverse" : "http://localhost:7474/db/data/node/838/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/838/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/838/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/838/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/838",
  "incoming_relationships" : "http://localhost:7474/db/data/node/838/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/838/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/838/relationships/in/{-list|&|types}"
} ]

Graph Algorithms

Neo4j comes with a number of built-in graph algorithms. They are performed from a start node. The traversal is controlled by the URI and the body sent with the request. These are the parameters that can be used:

algorithm

The algorithm to choose. If not set, default is shortestPath. algorithm can have one of these values:

  • shortestPath

  • allSimplePaths

  • allPaths

  • dijkstra (optionally with cost_property and default_cost parameters)

max_depth

The maximum depth as an integer for the algorithms like shortestPath, where applicable. Default is 1.

Find all shortest paths

The shortestPath algorithm can find multiple paths between the same nodes, like in this example.

alt
Figure 72. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/170/paths

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/176",
  "max_depth" : 3,
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "shortestPath"
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "relationships" : [ "http://localhost:7474/db/data/relationship/105", "http://localhost:7474/db/data/relationship/114" ],
  "nodes" : [ "http://localhost:7474/db/data/node/170", "http://localhost:7474/db/data/node/172", "http://localhost:7474/db/data/node/176" ],
  "directions" : [ "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/170",
  "length" : 2,
  "end" : "http://localhost:7474/db/data/node/176"
}, {
  "relationships" : [ "http://localhost:7474/db/data/relationship/106", "http://localhost:7474/db/data/relationship/112" ],
  "nodes" : [ "http://localhost:7474/db/data/node/170", "http://localhost:7474/db/data/node/173", "http://localhost:7474/db/data/node/176" ],
  "directions" : [ "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/170",
  "length" : 2,
  "end" : "http://localhost:7474/db/data/node/176"
} ]

Find one of the shortest paths

If no path algorithm is specified, a shortestPath algorithm with a max depth of 1 will be chosen. In this example, the max_depth is set to 3 in order to find the shortest path between a maximum of 3 linked nodes.

alt
Figure 73. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/163/path

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/169",
  "max_depth" : 3,
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "shortestPath"
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "relationships" : [ "http://localhost:7474/db/data/relationship/95", "http://localhost:7474/db/data/relationship/104" ],
  "nodes" : [ "http://localhost:7474/db/data/node/163", "http://localhost:7474/db/data/node/165", "http://localhost:7474/db/data/node/169" ],
  "directions" : [ "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/163",
  "length" : 2,
  "end" : "http://localhost:7474/db/data/node/169"
}

Execute a Dijkstra algorithm and get a single path

This example is running a Dijkstra algorithm over a graph with different cost properties on different relationships. Note that the request URI ends with /path which means a single path is what we want here.

alt
Figure 74. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/177/path

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/181",
  "cost_property" : "cost",
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "dijkstra"
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "relationships" : [ "http://localhost:7474/db/data/relationship/116", "http://localhost:7474/db/data/relationship/118", "http://localhost:7474/db/data/relationship/119" ],
  "nodes" : [ "http://localhost:7474/db/data/node/177", "http://localhost:7474/db/data/node/179", "http://localhost:7474/db/data/node/180", "http://localhost:7474/db/data/node/181" ],
  "directions" : [ "->", "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/177",
  "length" : 3,
  "weight" : 1.5,
  "end" : "http://localhost:7474/db/data/node/181"
}

Execute a Dijkstra algorithm with equal weights on relationships

The following is executing a Dijkstra search on a graph with equal weights on all relationships. This example is included to show the difference when the same graph structure is used, but the path weight is equal to the number of hops.

alt
Figure 75. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/183/path

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/187",
  "cost_property" : "cost",
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "dijkstra"
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "relationships" : [ "http://localhost:7474/db/data/relationship/122", "http://localhost:7474/db/data/relationship/127" ],
  "nodes" : [ "http://localhost:7474/db/data/node/183", "http://localhost:7474/db/data/node/184", "http://localhost:7474/db/data/node/187" ],
  "directions" : [ "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/183",
  "length" : 2,
  "weight" : 2.0,
  "end" : "http://localhost:7474/db/data/node/187"
}

Execute a Dijkstra algorithm and get multiple paths

This example is running a Dijkstra algorithm over a graph with different cost properties on different relationships. Note that the request URI ends with /paths which means we want multiple paths returned, in case they exist.

alt
Figure 76. Final Graph

Example request

  • POST http://localhost:7474/db/data/node/157/paths

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "to" : "http://localhost:7474/db/data/node/161",
  "cost_property" : "cost",
  "relationships" : {
    "type" : "to",
    "direction" : "out"
  },
  "algorithm" : "dijkstra"
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "relationships" : [ "http://localhost:7474/db/data/relationship/89", "http://localhost:7474/db/data/relationship/91", "http://localhost:7474/db/data/relationship/92" ],
  "nodes" : [ "http://localhost:7474/db/data/node/157", "http://localhost:7474/db/data/node/159", "http://localhost:7474/db/data/node/160", "http://localhost:7474/db/data/node/161" ],
  "directions" : [ "->", "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/157",
  "length" : 3,
  "weight" : 1.5,
  "end" : "http://localhost:7474/db/data/node/161"
}, {
  "relationships" : [ "http://localhost:7474/db/data/relationship/90", "http://localhost:7474/db/data/relationship/94" ],
  "nodes" : [ "http://localhost:7474/db/data/node/157", "http://localhost:7474/db/data/node/162", "http://localhost:7474/db/data/node/161" ],
  "directions" : [ "->", "->" ],
  "start" : "http://localhost:7474/db/data/node/157",
  "length" : 2,
  "weight" : 1.5,
  "end" : "http://localhost:7474/db/data/node/161"
} ]

Batch operations

Batch operations lets you execute multiple API calls through a single HTTP call. This improves performance for large insert and update operations significantly.

This service is transactional. If any of the operations performed fails (returns a non-2xx HTTP status code), the transaction will be rolled back and no changes will be applied.

IMPORTANT:

You cannot use this resource to execute Cypher queries with USING PERIODIC COMMIT.

Execute multiple operations in batch

The batch service expects an array of job descriptions as input, each job description describing an action to be performed via the normal server API.

Each job description should contain a to attribute, with a value relative to the data API root (so http://localhost:7474/db/data/node becomes just /node), and a method attribute containing HTTP verb to use.

Optionally you may provide a body attribute, and an id attribute to help you keep track of responses, although responses are guaranteed to be returned in the same order the job descriptions are received.

The following figure outlines the different parts of the job descriptions:

batch request api
alt
Figure 77. Starting Graph
alt
Figure 78. Final Graph

Example request

  • POST http://localhost:7474/db/data/batch

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

[ {
  "method" : "PUT",
  "to" : "/node/496/properties",
  "body" : {
    "age" : 1
  },
  "id" : 0
}, {
  "method" : "GET",
  "to" : "/node/496",
  "id" : 1
}, {
  "method" : "POST",
  "to" : "/node",
  "body" : {
    "age" : 1
  },
  "id" : 2
}, {
  "method" : "POST",
  "to" : "/node",
  "body" : {
    "age" : 1
  },
  "id" : 3
} ]

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "id" : 0,
  "from" : "/node/496/properties"
}, {
  "id" : 1,
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 496,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/496/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/496/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/496/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/496/relationships",
    "labels" : "http://localhost:7474/db/data/node/496/labels",
    "traverse" : "http://localhost:7474/db/data/node/496/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/496/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/496/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/496/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/496",
    "incoming_relationships" : "http://localhost:7474/db/data/node/496/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/496/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/496/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 1
    }
  },
  "from" : "/node/496"
}, {
  "id" : 2,
  "location" : "http://localhost:7474/db/data/node/498",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 498,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/498/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/498/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/498/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/498/relationships",
    "labels" : "http://localhost:7474/db/data/node/498/labels",
    "traverse" : "http://localhost:7474/db/data/node/498/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/498/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/498/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/498/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/498",
    "incoming_relationships" : "http://localhost:7474/db/data/node/498/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/498/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/498/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 1
    }
  },
  "from" : "/node"
}, {
  "id" : 3,
  "location" : "http://localhost:7474/db/data/node/499",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 499,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/499/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/499/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/499/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/499/relationships",
    "labels" : "http://localhost:7474/db/data/node/499/labels",
    "traverse" : "http://localhost:7474/db/data/node/499/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/499/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/499/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/499/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/499",
    "incoming_relationships" : "http://localhost:7474/db/data/node/499/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/499/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/499/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 1
    }
  },
  "from" : "/node"
} ]

Refer to items created earlier in the same batch job

The batch operation API allows you to refer to the URI returned from a created resource in subsequent job descriptions, within the same batch call.

Use the {[JOB ID]} special syntax to inject URIs from created resources into JSON strings in subsequent job descriptions.

alt
Figure 79. Final Graph

Example request

  • POST http://localhost:7474/db/data/batch

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

[ {
  "method" : "POST",
  "to" : "/node",
  "id" : 0,
  "body" : {
    "name" : "bob"
  }
}, {
  "method" : "POST",
  "to" : "/node",
  "id" : 1,
  "body" : {
    "age" : 12
  }
}, {
  "method" : "POST",
  "to" : "{0}/relationships",
  "id" : 3,
  "body" : {
    "to" : "{1}",
    "data" : {
      "since" : "2010"
    },
    "type" : "KNOWS"
  }
}, {
  "method" : "POST",
  "to" : "/index/relationship/my_rels",
  "id" : 4,
  "body" : {
    "key" : "since",
    "value" : "2010",
    "uri" : "{3}"
  }
} ]

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "id" : 0,
  "location" : "http://localhost:7474/db/data/node/271",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 271,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/271/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/271/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/271/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/271/relationships",
    "labels" : "http://localhost:7474/db/data/node/271/labels",
    "traverse" : "http://localhost:7474/db/data/node/271/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/271/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/271/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/271/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/271",
    "incoming_relationships" : "http://localhost:7474/db/data/node/271/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/271/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/271/relationships/in/{-list|&|types}",
    "data" : {
      "name" : "bob"
    }
  },
  "from" : "/node"
}, {
  "id" : 1,
  "location" : "http://localhost:7474/db/data/node/272",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 272,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/272/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/272/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/272/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/272/relationships",
    "labels" : "http://localhost:7474/db/data/node/272/labels",
    "traverse" : "http://localhost:7474/db/data/node/272/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/272/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/272/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/272/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/272",
    "incoming_relationships" : "http://localhost:7474/db/data/node/272/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/272/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/272/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 12
    }
  },
  "from" : "/node"
}, {
  "id" : 3,
  "location" : "http://localhost:7474/db/data/relationship/155",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 155,
      "type" : "KNOWS"
    },
    "start" : "http://localhost:7474/db/data/node/271",
    "property" : "http://localhost:7474/db/data/relationship/155/properties/{key}",
    "self" : "http://localhost:7474/db/data/relationship/155",
    "end" : "http://localhost:7474/db/data/node/272",
    "type" : "KNOWS",
    "properties" : "http://localhost:7474/db/data/relationship/155/properties",
    "data" : {
      "since" : "2010"
    }
  },
  "from" : "http://localhost:7474/db/data/node/271/relationships"
}, {
  "id" : 4,
  "location" : "http://localhost:7474/db/data/index/relationship/my_rels/since/2010/155",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 155,
      "type" : "KNOWS"
    },
    "start" : "http://localhost:7474/db/data/node/271",
    "property" : "http://localhost:7474/db/data/relationship/155/properties/{key}",
    "self" : "http://localhost:7474/db/data/relationship/155",
    "end" : "http://localhost:7474/db/data/node/272",
    "type" : "KNOWS",
    "properties" : "http://localhost:7474/db/data/relationship/155/properties",
    "data" : {
      "since" : "2010"
    },
    "indexed" : "http://localhost:7474/db/data/index/relationship/my_rels/since/2010/155"
  },
  "from" : "/index/relationship/my_rels"
} ]

Execute multiple operations in batch streaming

alt
Figure 80. Final Graph

Example request

  • POST http://localhost:7474/db/data/batch

  • Accept: application/json

  • Content-Type: application/json

  • X-Stream: true

[ {
  "method" : "PUT",
  "to" : "/node/128/properties",
  "body" : {
    "age" : 1
  },
  "id" : 0
}, {
  "method" : "GET",
  "to" : "/node/128",
  "id" : 1
}, {
  "method" : "POST",
  "to" : "/node",
  "body" : {
    "age" : 1
  },
  "id" : 2
}, {
  "method" : "POST",
  "to" : "/node",
  "body" : {
    "age" : 1
  },
  "id" : 3
} ]

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "id" : 0,
  "from" : "/node/128/properties",
  "body" : null,
  "status" : 204
}, {
  "id" : 1,
  "from" : "/node/128",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 128,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/128/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/128/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/128/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/128/relationships",
    "labels" : "http://localhost:7474/db/data/node/128/labels",
    "traverse" : "http://localhost:7474/db/data/node/128/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/128/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/128/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/128/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/128",
    "incoming_relationships" : "http://localhost:7474/db/data/node/128/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/128/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/128/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 1
    }
  },
  "status" : 200
}, {
  "id" : 2,
  "from" : "/node",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 130,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/130/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/130/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/130/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/130/relationships",
    "labels" : "http://localhost:7474/db/data/node/130/labels",
    "traverse" : "http://localhost:7474/db/data/node/130/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/130/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/130/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/130/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/130",
    "incoming_relationships" : "http://localhost:7474/db/data/node/130/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/130/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/130/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 1
    }
  },
  "location" : "http://localhost:7474/db/data/node/130",
  "status" : 201
}, {
  "id" : 3,
  "from" : "/node",
  "body" : {
    "extensions" : { },
    "metadata" : {
      "id" : 131,
      "labels" : [ ]
    },
    "paged_traverse" : "http://localhost:7474/db/data/node/131/paged/traverse/{returnType}{?pageSize,leaseTime}",
    "outgoing_relationships" : "http://localhost:7474/db/data/node/131/relationships/out",
    "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/131/relationships/out/{-list|&|types}",
    "create_relationship" : "http://localhost:7474/db/data/node/131/relationships",
    "labels" : "http://localhost:7474/db/data/node/131/labels",
    "traverse" : "http://localhost:7474/db/data/node/131/traverse/{returnType}",
    "all_relationships" : "http://localhost:7474/db/data/node/131/relationships/all",
    "all_typed_relationships" : "http://localhost:7474/db/data/node/131/relationships/all/{-list|&|types}",
    "property" : "http://localhost:7474/db/data/node/131/properties/{key}",
    "self" : "http://localhost:7474/db/data/node/131",
    "incoming_relationships" : "http://localhost:7474/db/data/node/131/relationships/in",
    "properties" : "http://localhost:7474/db/data/node/131/properties",
    "incoming_typed_relationships" : "http://localhost:7474/db/data/node/131/relationships/in/{-list|&|types}",
    "data" : {
      "age" : 1
    }
  },
  "location" : "http://localhost:7474/db/data/node/131",
  "status" : 201
} ]

Legacy indexing

This documents the legacy indexing in Neo4j, which is no longer the preferred way to handle indexes. Consider looking at Indexing.

An index can contain either nodes or relationships.

To create an index with default configuration, simply start using it by adding nodes/relationships to it. It will then be automatically created for you.

What default configuration means depends on how you have configured your database. If you haven’t changed any indexing configuration, it means the indexes will be using a Lucene-based backend.

All the examples below show you how to do operations on node indexes, but all of them are just as applicable to relationship indexes. Simple change the "node" part of the URL to "relationship".

If you want to customize the index settings, see Create node index with configuration.

Create node index

Instead of creating the index this way, you can simply start to use it, and it will be created automatically with default configuration.

Example request

  • POST http://localhost:7474/db/data/index/node/

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "name" : "index_1480348131336_1"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/index_1480348131336_1/

{
  "template" : "http://localhost:7474/db/data/index/node/index_1480348131336_1/{key}/{value}"
}

Create node index with configuration

This request is only necessary if you want to customize the index settings. If you are happy with the defaults, you can just start indexing nodes/relationships, as non-existent indexes will automatically be created as you do. See Configuration and full-text indexing for more information on index configuration.

Example request

  • POST http://localhost:7474/db/data/index/node/

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "name" : "fulltext",
  "config" : {
    "type" : "fulltext",
    "provider" : "lucene"
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/fulltext/

{
  "template" : "http://localhost:7474/db/data/index/node/fulltext/{key}/{value}",
  "type" : "fulltext",
  "provider" : "lucene"
}

Delete node index

Example request

  • DELETE http://localhost:7474/db/data/index/node/index_1480348129947_1

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

List node indexes

Example request

  • GET http://localhost:7474/db/data/index/node/

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "index_1480348129352_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348129352_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348130101_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348130101_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348129180_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348129180_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348129512_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348129512_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348129596_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348129596_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348128185_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348128185_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348128155_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348128155_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348128197_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348128197_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348129059_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348129059_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348130192_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348130192_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348128237_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348128237_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348129237_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348129237_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348130204_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348130204_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "index_1480348130033_1" : {
    "template" : "http://localhost:7474/db/data/index/node/index_1480348130033_1/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  },
  "node_auto_index" : {
    "template" : "http://localhost:7474/db/data/index/node/node_auto_index/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  }
}

Add node to index

Associates a node with the given key/value pair in the given index.

Spaces in the URI have to be encoded as %20.
This does not overwrite previous entries. If you index the same key/value/item combination twice, two index entries are created. To do update-type operations, you need to delete the old entry before adding a new one.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348129237_1

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "value" : "some value",
  "uri" : "http://localhost:7474/db/data/node/368",
  "key" : "some-key"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/index_1480348129237_1/some-key/some%20value/368

{
  "extensions" : { },
  "metadata" : {
    "id" : 368,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/368/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/368/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/368/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/368/relationships",
  "labels" : "http://localhost:7474/db/data/node/368/labels",
  "traverse" : "http://localhost:7474/db/data/node/368/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/368/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/368/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/368/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/368",
  "incoming_relationships" : "http://localhost:7474/db/data/node/368/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/368/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/368/relationships/in/{-list|&|types}",
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348129237_1/some-key/some%20value/368"
}

Remove all entries with a given node from an index

Example request

  • DELETE http://localhost:7474/db/data/index/node/index_1480348130101_1/373

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Remove all entries with a given node and key from an index

Example request

  • DELETE http://localhost:7474/db/data/index/node/index_1480348130564_1/kvkey2/376

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Remove all entries with a given node, key and value from an index

Example request

  • DELETE http://localhost:7474/db/data/index/node/index_1480348129352_1/kvkey1/value1/369

  • Accept: application/json; charset=UTF-8

Example response

  • 204: No Content

Find node by exact match

Spaces in the URI have to be encoded as %20.

Example request

  • GET http://localhost:7474/db/data/index/node/index_1480348131244_1/key/the%2520value

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 384,
    "labels" : [ ]
  },
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348131244_1/key/the%2520value/384",
  "paged_traverse" : "http://localhost:7474/db/data/node/384/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/384/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/384/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/384/relationships",
  "labels" : "http://localhost:7474/db/data/node/384/labels",
  "traverse" : "http://localhost:7474/db/data/node/384/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/384/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/384/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/384/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/384",
  "incoming_relationships" : "http://localhost:7474/db/data/node/384/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/384/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/384/relationships/in/{-list|&|types}"
} ]

Find node by query

The query language used here depends on what type of index you are querying. The default index type is Lucene, in which case you should use the Lucene query language here. Below an example of a fuzzy search over multiple keys.

Getting the results with a predefined ordering requires adding the parameter

order=ordering

where ordering is one of index, relevance or score. In this case an additional field will be added to each result, named score, that holds the float value that is the score reported by the query result.

Example request

  • GET http://localhost:7474/db/data/index/node/index_1480348131136_1?query=Name:Build~0.1%20AND%20Gender:Male

  • Accept: application/json; charset=UTF-8

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

[ {
  "metadata" : {
    "id" : 383,
    "labels" : [ ]
  },
  "data" : {
    "Name" : "Builder"
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/383/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/383/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/383/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/383/relationships",
  "labels" : "http://localhost:7474/db/data/node/383/labels",
  "traverse" : "http://localhost:7474/db/data/node/383/traverse/{returnType}",
  "extensions" : { },
  "all_relationships" : "http://localhost:7474/db/data/node/383/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/383/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/383/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/383",
  "incoming_relationships" : "http://localhost:7474/db/data/node/383/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/383/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/383/relationships/in/{-list|&|types}"
} ]

Unique indexing

As of Neo4j 2.0, unique constraints have been added. These make Neo4j enforce the uniqueness, guaranteeing that uniqueness is maintained. See the Developer Manual for details about this. For most cases, the unique constraints should be used rather than the features described below.

For uniqueness enforcements, there are two modes:

  • URL Parameter uniqueness=get_or_create: Create a new node/relationship and index it if no existing one can be found. If an existing node/relationship is found, discard the sent data and return the existing node/relationship.

  • URL Parameter uniqueness=create_or_fail: Create a new node/relationship if no existing one can be found in the index. If an existing node/relationship is found, return a conflict error.

For details about Neo4j transaction semantics and uniqueness, see the Java Developer Reference.

Get or create unique node (create)

The node is created if it doesn’t exist in the unique index already.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348131046_1?uniqueness=get_or_create

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Tobias",
  "properties" : {
    "name" : "Tobias",
    "sequence" : 1
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/index_1480348131046_1/name/Tobias/382

{
  "extensions" : { },
  "metadata" : {
    "id" : 382,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/382/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/382/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/382/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/382/relationships",
  "labels" : "http://localhost:7474/db/data/node/382/labels",
  "traverse" : "http://localhost:7474/db/data/node/382/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/382/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/382/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/382/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/382",
  "incoming_relationships" : "http://localhost:7474/db/data/node/382/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/382/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/382/relationships/in/{-list|&|types}",
  "data" : {
    "sequence" : 1,
    "name" : "Tobias"
  },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348131046_1/name/Tobias/382"
}

Get or create unique node (existing)

Here, a node is not created but the existing unique node returned, since another node is indexed with the same data already. The node data returned is then that of the already existing node.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348130033_1?uniqueness=get_or_create

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Peter",
  "properties" : {
    "name" : "Peter",
    "sequence" : 2
  }
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/index_1480348130033_1/name/Peter/372

{
  "extensions" : { },
  "metadata" : {
    "id" : 372,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/372/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/372/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/372/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/372/relationships",
  "labels" : "http://localhost:7474/db/data/node/372/labels",
  "traverse" : "http://localhost:7474/db/data/node/372/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/372/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/372/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/372/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/372",
  "incoming_relationships" : "http://localhost:7474/db/data/node/372/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/372/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/372/relationships/in/{-list|&|types}",
  "data" : {
    "sequence" : 1,
    "name" : "Peter"
  },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348130033_1/name/Peter/372"
}

Create a unique node or return fail (create)

Here, in case of an already existing node, an error should be returned. In this example, no existing indexed node is found and a new node is created.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348130964_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Tobias",
  "properties" : {
    "name" : "Tobias",
    "sequence" : 1
  }
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/index_1480348130964_1/name/Tobias/381

{
  "extensions" : { },
  "metadata" : {
    "id" : 381,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/381/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/381/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/381/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/381/relationships",
  "labels" : "http://localhost:7474/db/data/node/381/labels",
  "traverse" : "http://localhost:7474/db/data/node/381/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/381/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/381/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/381/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/381",
  "incoming_relationships" : "http://localhost:7474/db/data/node/381/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/381/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/381/relationships/in/{-list|&|types}",
  "data" : {
    "sequence" : 1,
    "name" : "Tobias"
  },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348130964_1/name/Tobias/381"
}

Create a unique node or return fail (fail)

Here, in case of an already existing node, an error should be returned. In this example, an existing node indexed with the same data is found and an error is returned.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348129059_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Peter",
  "properties" : {
    "name" : "Peter",
    "sequence" : 2
  }
}

Example response

  • 409: Conflict

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 366,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/366/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/366/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/366/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/366/relationships",
  "labels" : "http://localhost:7474/db/data/node/366/labels",
  "traverse" : "http://localhost:7474/db/data/node/366/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/366/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/366/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/366/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/366",
  "incoming_relationships" : "http://localhost:7474/db/data/node/366/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/366/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/366/relationships/in/{-list|&|types}",
  "data" : {
    "sequence" : 1,
    "name" : "Peter"
  },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348129059_1/name/Peter/366"
}

Add an existing node to unique index (not indexed)

Associates a node with the given key/value pair in the given unique index.

In this example, we are using create_or_fail uniqueness.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348130696_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "value" : "some value",
  "uri" : "http://localhost:7474/db/data/node/377",
  "key" : "some-key"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/node/index_1480348130696_1/some-key/some%20value/377

{
  "extensions" : { },
  "metadata" : {
    "id" : 377,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/377/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/377/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/377/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/377/relationships",
  "labels" : "http://localhost:7474/db/data/node/377/labels",
  "traverse" : "http://localhost:7474/db/data/node/377/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/377/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/377/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/377/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/377",
  "incoming_relationships" : "http://localhost:7474/db/data/node/377/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/377/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/377/relationships/in/{-list|&|types}",
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348130696_1/some-key/some%20value/377"
}

Add an existing node to unique index (already indexed)

In this case, the node already exists in the index, and thus we get a HTTP 409 status response, as we have set the uniqueness to create_or_fail.

Example request

  • POST http://localhost:7474/db/data/index/node/index_1480348130881_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "value" : "some value",
  "uri" : "http://localhost:7474/db/data/node/380",
  "key" : "some-key"
}

Example response

  • 409: Conflict

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 379,
    "labels" : [ ]
  },
  "paged_traverse" : "http://localhost:7474/db/data/node/379/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/379/relationships/out",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/379/relationships/out/{-list|&|types}",
  "create_relationship" : "http://localhost:7474/db/data/node/379/relationships",
  "labels" : "http://localhost:7474/db/data/node/379/labels",
  "traverse" : "http://localhost:7474/db/data/node/379/traverse/{returnType}",
  "all_relationships" : "http://localhost:7474/db/data/node/379/relationships/all",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/379/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/379/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/379",
  "incoming_relationships" : "http://localhost:7474/db/data/node/379/relationships/in",
  "properties" : "http://localhost:7474/db/data/node/379/properties",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/379/relationships/in/{-list|&|types}",
  "data" : {
    "some-key" : "some value"
  },
  "indexed" : "http://localhost:7474/db/data/index/node/index_1480348130881_1/some-key/some%20value/379"
}

Get or create unique relationship (create)

Create a unique relationship in an index. If a relationship matching the given key and value already exists in the index, it will be returned. If not, a new relationship will be created.

The type and direction of the relationship is not regarded when determining uniqueness.

Example request

  • POST http://localhost:7474/db/data/index/relationship/index_1480348126350_1/?uniqueness=get_or_create

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Tobias",
  "start" : "http://localhost:7474/db/data/node/327",
  "end" : "http://localhost:7474/db/data/node/328",
  "type" : "knowledge"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/relationship/index_1480348126350_1/name/Tobias/200

{
  "extensions" : { },
  "metadata" : {
    "id" : 200,
    "type" : "knowledge"
  },
  "start" : "http://localhost:7474/db/data/node/327",
  "property" : "http://localhost:7474/db/data/relationship/200/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/200",
  "end" : "http://localhost:7474/db/data/node/328",
  "type" : "knowledge",
  "properties" : "http://localhost:7474/db/data/relationship/200/properties",
  "data" : {
    "name" : "Tobias"
  },
  "indexed" : "http://localhost:7474/db/data/index/relationship/index_1480348126350_1/name/Tobias/200"
}

Get or create unique relationship (existing)

Here, in case of an already existing relationship, the sent data is ignored and the existing relationship returned.

Example request

  • POST http://localhost:7474/db/data/index/relationship/index_1480348126439_1?uniqueness=get_or_create

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Peter",
  "start" : "http://localhost:7474/db/data/node/331",
  "end" : "http://localhost:7474/db/data/node/332",
  "type" : "KNOWS"
}

Example response

  • 200: OK

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 201,
    "type" : "KNOWS"
  },
  "start" : "http://localhost:7474/db/data/node/329",
  "property" : "http://localhost:7474/db/data/relationship/201/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/201",
  "end" : "http://localhost:7474/db/data/node/330",
  "type" : "KNOWS",
  "properties" : "http://localhost:7474/db/data/relationship/201/properties",
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/relationship/index_1480348126439_1/name/Peter/201"
}

Create a unique relationship or return fail (create)

Here, in case of an already existing relationship, an error should be returned. In this example, no existing relationship is found and a new relationship is created.

Example request

  • POST http://localhost:7474/db/data/index/relationship/index_1480348126864_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Tobias",
  "start" : "http://localhost:7474/db/data/node/339",
  "end" : "http://localhost:7474/db/data/node/340",
  "type" : "KNOWS"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/relationship/index_1480348126864_1/name/Tobias/204

{
  "extensions" : { },
  "metadata" : {
    "id" : 204,
    "type" : "KNOWS"
  },
  "start" : "http://localhost:7474/db/data/node/339",
  "property" : "http://localhost:7474/db/data/relationship/204/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/204",
  "end" : "http://localhost:7474/db/data/node/340",
  "type" : "KNOWS",
  "properties" : "http://localhost:7474/db/data/relationship/204/properties",
  "data" : {
    "name" : "Tobias"
  },
  "indexed" : "http://localhost:7474/db/data/index/relationship/index_1480348126864_1/name/Tobias/204"
}

Create a unique relationship or return fail (fail)

Here, in case of an already existing relationship, an error should be returned. In this example, an existing relationship is found and an error is returned.

Example request

  • POST http://localhost:7474/db/data/index/relationship/index_1480348126008_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Peter",
  "start" : "http://localhost:7474/db/data/node/319",
  "end" : "http://localhost:7474/db/data/node/320",
  "type" : "KNOWS"
}

Example response

  • 409: Conflict

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 196,
    "type" : "KNOWS"
  },
  "start" : "http://localhost:7474/db/data/node/317",
  "property" : "http://localhost:7474/db/data/relationship/196/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/196",
  "end" : "http://localhost:7474/db/data/node/318",
  "type" : "KNOWS",
  "properties" : "http://localhost:7474/db/data/relationship/196/properties",
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/relationship/index_1480348126008_1/name/Peter/196"
}

Add an existing relationship to a unique index (not indexed)

If a relationship matching the given key and value already exists in the index, it will be returned. If not, an HTTP 409 (conflict) status will be returned in this case, as we are using create_or_fail.

It’s possible to use get_or_create uniqueness as well.

The type and direction of the relationship is not regarded when determining uniqueness.

Example request

  • POST http://localhost:7474/db/data/index/relationship/index_1480348125937_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Peter",
  "uri" : "http://localhost:7474/db/data/relationship/195"
}

Example response

  • 201: Created

  • Content-Type: application/json; charset=UTF-8

  • Location: http://localhost:7474/db/data/index/relationship/index_1480348125937_1/name/Peter/195

{
  "extensions" : { },
  "metadata" : {
    "id" : 195,
    "type" : "KNOWS"
  },
  "start" : "http://localhost:7474/db/data/node/315",
  "property" : "http://localhost:7474/db/data/relationship/195/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/195",
  "end" : "http://localhost:7474/db/data/node/316",
  "type" : "KNOWS",
  "properties" : "http://localhost:7474/db/data/relationship/195/properties",
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/relationship/index_1480348125937_1/name/Peter/195"
}

Add an existing relationship to a unique index (already indexed)

Example request

  • POST http://localhost:7474/db/data/index/relationship/index_1480348126117_1?uniqueness=create_or_fail

  • Accept: application/json; charset=UTF-8

  • Content-Type: application/json

{
  "key" : "name",
  "value" : "Peter",
  "uri" : "http://localhost:7474/db/data/relationship/198"
}

Example response

  • 409: Conflict

  • Content-Type: application/json; charset=UTF-8

{
  "extensions" : { },
  "metadata" : {
    "id" : 197,
    "type" : "KNOWS"
  },
  "start" : "http://localhost:7474/db/data/node/321",
  "property" : "http://localhost:7474/db/data/relationship/197/properties/{key}",
  "self" : "http://localhost:7474/db/data/relationship/197",
  "end" : "http://localhost:7474/db/data/node/322",
  "type" : "KNOWS",
  "properties" : "http://localhost:7474/db/data/relationship/197/properties",
  "data" : { },
  "indexed" : "http://localhost:7474/db/data/index/relationship/index_1480348126117_1/name/Peter/197"
}

WADL Support

The Neo4j REST API is a truly RESTful interface relying on hypermedia controls (links) to advertise permissible actions to users. Hypermedia is a dynamic interface style where declarative constructs (semantic markup) are used to inform clients of their next legal choices just in time.

RESTful APIs cannot be modeled by static interface description languages like WSDL or WADL.

However for some use cases, developers may wish to expose WADL descriptions of the Neo4j REST API, particularly when using tooling that expects such.

In those cases WADL generation may be enabled by adding to neo4j.conf:

unsupported.dbms.wadl_generation_enabled=true
WADL is not an officially supported part of the Neo4j server API because WADL is insufficiently expressive to capture the set of potential interactions a client can drive with Neo4j server. Expect the WADL description to be incomplete, and in some cases contradictory to the real API. In any cases where the WADL description disagrees with the REST API, the REST API should be considered authoritative. WADL generation may be withdrawn at any point in the Neo4j release cycle.

Using the REST API from WebLogic

When deploying an application to WebLogic you may run into problems when Neo4j responds with an HTTP status of 204 No Content. The response does not contain an entity body in such cases.

This can cause WebLogic to throw java.net.SocketTimeoutException: Read timed out for no obvious reason.

If you encounter this, please try setting UseSunHttpHandler to true. You can for example do this by adding the following to the WebLogic startup script:

-DUseSunHttpHandler=true

The WebLogic startup script is called bin\startWebLogic.sh (bin/startWebLogic.cmd on Windows).