19.7. Nodes
Create node
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/291
{ "extensions" : { }, "outgoing_relationships" : "http://localhost:7474/db/data/node/291/relationships/out", "labels" : "http://localhost:7474/db/data/node/291/labels", "all_typed_relationships" : "http://localhost:7474/db/data/node/291/relationships/all/{-list|&|types}", "traverse" : "http://localhost:7474/db/data/node/291/traverse/{returnType}", "self" : "http://localhost:7474/db/data/node/291", "property" : "http://localhost:7474/db/data/node/291/properties/{key}", "properties" : "http://localhost:7474/db/data/node/291/properties", "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/291/relationships/out/{-list|&|types}", "incoming_relationships" : "http://localhost:7474/db/data/node/291/relationships/in", "create_relationship" : "http://localhost:7474/db/data/node/291/relationships", "paged_traverse" : "http://localhost:7474/db/data/node/291/paged/traverse/{returnType}{?pageSize,leaseTime}", "all_relationships" : "http://localhost:7474/db/data/node/291/relationships/all", "incoming_typed_relationships" : "http://localhost:7474/db/data/node/291/relationships/in/{-list|&|types}", "metadata" : { "id" : 291, "labels" : [ ] }, "data" : { } }
Create node with properties
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:
1239
-
Content-Type:
application/json; charset=UTF-8
-
Location:
http://localhost:7474/db/data/node/287
{ "extensions" : { }, "outgoing_relationships" : "http://localhost:7474/db/data/node/287/relationships/out", "labels" : "http://localhost:7474/db/data/node/287/labels", "all_typed_relationships" : "http://localhost:7474/db/data/node/287/relationships/all/{-list|&|types}", "traverse" : "http://localhost:7474/db/data/node/287/traverse/{returnType}", "self" : "http://localhost:7474/db/data/node/287", "property" : "http://localhost:7474/db/data/node/287/properties/{key}", "properties" : "http://localhost:7474/db/data/node/287/properties", "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/287/relationships/out/{-list|&|types}", "incoming_relationships" : "http://localhost:7474/db/data/node/287/relationships/in", "create_relationship" : "http://localhost:7474/db/data/node/287/relationships", "paged_traverse" : "http://localhost:7474/db/data/node/287/paged/traverse/{returnType}{?pageSize,leaseTime}", "all_relationships" : "http://localhost:7474/db/data/node/287/relationships/all", "incoming_typed_relationships" : "http://localhost:7474/db/data/node/287/relationships/in/{-list|&|types}", "metadata" : { "id" : 287, "labels" : [ ] }, "data" : { "foo" : "bar" } }
Get node
Note that the response contains URI/templates for the available operations for getting properties and relationships.
Example request
-
GET
http://localhost:7474/db/data/node/357
-
Accept:
application/json; charset=UTF-8
Example response
-
200:
OK
-
Content-Type:
application/json; charset=UTF-8
{ "extensions" : { }, "outgoing_relationships" : "http://localhost:7474/db/data/node/357/relationships/out", "labels" : "http://localhost:7474/db/data/node/357/labels", "all_typed_relationships" : "http://localhost:7474/db/data/node/357/relationships/all/{-list|&|types}", "traverse" : "http://localhost:7474/db/data/node/357/traverse/{returnType}", "self" : "http://localhost:7474/db/data/node/357", "property" : "http://localhost:7474/db/data/node/357/properties/{key}", "properties" : "http://localhost:7474/db/data/node/357/properties", "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/357/relationships/out/{-list|&|types}", "incoming_relationships" : "http://localhost:7474/db/data/node/357/relationships/in", "create_relationship" : "http://localhost:7474/db/data/node/357/relationships", "paged_traverse" : "http://localhost:7474/db/data/node/357/paged/traverse/{returnType}{?pageSize,leaseTime}", "all_relationships" : "http://localhost:7474/db/data/node/357/relationships/all", "incoming_typed_relationships" : "http://localhost:7474/db/data/node/357/relationships/in/{-list|&|types}", "metadata" : { "id" : 357, "labels" : [ ] }, "data" : { } }
Get non-existent node
Example request
-
GET
http://localhost:7474/db/data/node/36100000
-
Accept:
application/json; charset=UTF-8
Example response
-
404:
Not Found
-
Content-Type:
application/json; charset=UTF-8
{ "message": "Cannot find node with id [36100000] in database.", "exception": "NodeNotFoundException", "fullname": "org.neo4j.server.rest.web.NodeNotFoundException", "stacktrace": [ "org.neo4j.server.rest.web.DatabaseActions.node(DatabaseActions.java:183)", "org.neo4j.server.rest.web.DatabaseActions.getNode(DatabaseActions.java:228)", "org.neo4j.server.rest.web.RestfulGraphDatabase.getNode(RestfulGraphDatabase.java:265)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:744)" ] }
Delete node
Example request
-
DELETE
http://localhost:7474/db/data/node/288
-
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.
Example request
-
DELETE
http://localhost:7474/db/data/node/295
-
Accept:
application/json; charset=UTF-8
Example response
-
409:
Conflict
-
Content-Type:
application/json; charset=UTF-8
{ "message": "The node with id 295 cannot be deleted. Check that the node is orphaned before deletion.", "exception": "OperationFailureException", "fullname": "org.neo4j.server.rest.web.OperationFailureException", "stacktrace": [ "org.neo4j.server.rest.web.DatabaseActions.deleteNode(DatabaseActions.java:237)", "org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNode(RestfulGraphDatabase.java:279)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:744)" ] }