6.3. Relationships

6.3.1. Create relationship
6.3.2. Delete relationship
6.3.3. Get all relationships
6.3.4. Get incoming relationships
6.3.5. Get outgoing relationships
6.3.6. Get typed relationships
6.3.7. Get relationships on a node without relationships

The general pattern to get relationships 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.

6.3.1. Create relationship

Example request

  • POST http://0.0.0.0:7474/db/data/node/3/relationships
  • Accept: application/json
  • Content-Type: application/json
{"to" : "http://0.0.0.0:7474/db/data/node/4", "type" : "LOVES"}

Example response

  • 201: Created
  • Content-Type: application/json
  • Location: http://0.0.0.0:7474/db/data/relationship/2
{
  "start" : "http://0.0.0.0:7474/db/data/node/3",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/2",
  "property" : "http://0.0.0.0:7474/db/data/relationship/2/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/2/properties",
  "type" : "LOVES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/4"
}

6.3.2. Delete relationship

Starting Graph:

Final Graph:

Example request

  • DELETE http://localhost:7474/db/data/relationship/3
  • Accept: application/json

Example response

  • 204: No Content

6.3.3. Get all relationships

Example request

  • GET http://0.0.0.0:7474/db/data/node/6/relationships/all
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
[ {
  "start" : "http://0.0.0.0:7474/db/data/node/6",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/3",
  "property" : "http://0.0.0.0:7474/db/data/relationship/3/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/3/properties",
  "type" : "LIKES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/7"
}, {
  "start" : "http://0.0.0.0:7474/db/data/node/8",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/4",
  "property" : "http://0.0.0.0:7474/db/data/relationship/4/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/4/properties",
  "type" : "LIKES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/6"
}, {
  "start" : "http://0.0.0.0:7474/db/data/node/6",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/5",
  "property" : "http://0.0.0.0:7474/db/data/relationship/5/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/5/properties",
  "type" : "HATES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/9"
} ]

6.3.4. Get incoming relationships

Example request

  • GET http://0.0.0.0:7474/db/data/node/11/relationships/in
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
[ {
  "start" : "http://0.0.0.0:7474/db/data/node/13",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/7",
  "property" : "http://0.0.0.0:7474/db/data/relationship/7/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/7/properties",
  "type" : "LIKES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/11"
} ]

6.3.5. Get outgoing relationships

Example request

  • GET http://0.0.0.0:7474/db/data/node/16/relationships/out
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
[ {
  "start" : "http://0.0.0.0:7474/db/data/node/16",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/9",
  "property" : "http://0.0.0.0:7474/db/data/relationship/9/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/9/properties",
  "type" : "LIKES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/17"
}, {
  "start" : "http://0.0.0.0:7474/db/data/node/16",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/11",
  "property" : "http://0.0.0.0:7474/db/data/relationship/11/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/11/properties",
  "type" : "HATES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/19"
} ]

6.3.6. Get typed relationships

Note that the "&" needs to be escaped for example when using cURL from the terminal.

Example request

  • GET http://0.0.0.0:7474/db/data/node/21/relationships/all/LIKES&HATES
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
[ {
  "start" : "http://0.0.0.0:7474/db/data/node/21",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/12",
  "property" : "http://0.0.0.0:7474/db/data/relationship/12/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/12/properties",
  "type" : "LIKES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/22"
}, {
  "start" : "http://0.0.0.0:7474/db/data/node/23",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/13",
  "property" : "http://0.0.0.0:7474/db/data/relationship/13/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/13/properties",
  "type" : "LIKES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/21"
}, {
  "start" : "http://0.0.0.0:7474/db/data/node/21",
  "data" : {
  },
  "self" : "http://0.0.0.0:7474/db/data/relationship/14",
  "property" : "http://0.0.0.0:7474/db/data/relationship/14/properties/{key}",
  "properties" : "http://0.0.0.0:7474/db/data/relationship/14/properties",
  "type" : "HATES",
  "extensions" : {
  },
  "end" : "http://0.0.0.0:7474/db/data/node/24"
} ]

6.3.7. Get relationships on a node without relationships

Example request

  • GET http://0.0.0.0:7474/db/data/node/40/relationships/all
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
[ ]