Node api:
Create empty node:
httpc:request(post, {"http://127.0.0.1:7474/db/data/node", ["application/json"], "application/json", []}, [], []).
Create node with some properties
httpc:request(post, {"http://127.0.0.1:7474/db/data/node", ["application/json"], "application/json", "{\"name\":\"Sasha\"}"}, [], []).
Get node
httpc:request("http://127.0.0.1:7474/db/data/node/4").
- Where 4 - nodeId
Set properties on node
httpc:request(put, {"http://127.0.0.1:7474/db/data/node/2/properties", ["application/json"], "application/json", "{\"name\":\"Sasha5\"}"}, [], []).
Where:
- 2 - node id
*
"{\"name\":\"Sasha5\"}"
- set new property value
Delete properties in node
httpc:request(delete, {"http://127.0.0.1:7474/db/data/node/2/properties",[]}, [], []).
Get property on node
httpc:request(get, {"http://127.0.0.1:7474/db/data/node/3/properties/name",[]}, [], []).
Where:
- 3 - nodeId
- name - properties key
Delete node
httpc:request(delete, {"http://127.0.0.1:7474/db/data/node/2",[]}, [], []).
Where:
- 2 - nodeId
Create relationship
httpc:request(post, {"http://127.0.0.1:7474/db/data/node/5/relationships", ["application/json"], "application/json", "{\"to\": \"http://localhost:7474/db/data/node/4\", \"type\": \"follow\"}"}, [], []).
Where:
- 5 - from relationship
- type - type of relation
- to - to relationship
Delete relationship
httpc:request(delete, {"http://127.0.0.1:7474/db/data/relationships/5", []}, [], []).
Where:
- 5 - relation id
Create more node for 1 time
If we want to make more that 1 node (or other entities) for 1 http request we must use batch request:
Example request
- POST http://localhost:7474/db/data/batch
- Accept: application/json
- Content-Type: application/json
[ {
"method" : "PUT",
"to" : "/node/77/properties",
"body" : {
"age" : 1
},
"id" : 0
}, {
"method" : "GET",
"to" : "/node/77",
"id" : 1
}, {
"method" : "POST",
"to" : "/node",
"body" : {
"age" : 1
},
"id" : 2
}, {
"method" : "POST",
"to" : "/node",
"body" : {
"age" : 1
},
"id" : 3
} ]
Request in erlang
httpc:request(post, {"http://127.0.0.1:7474/db/data/batch/", ["application/json"], "application/json", "[{\"method\" : \"POST\",\"to\" : \"/node\", \"body\" : {\"name\" : \"User1\"},\"id\" : 0},{\"method\" : \"POST\",\"to\" : \"/node\", \"body\" : {\"name\" : \"User2\"},\"id\" : 1}]"}, [], []).
http://components.neo4j.org/neo4j-server/1.3.M02/rest.html#Create_node_with_properties