Handling Vertices

Examples will explain the REST API to the graph module on the social graph:

Social Example Graph

Create a vertex

create a new vertex

POST /_api/gharial/{graph-name}/vertex/{collection-name}

Adds a vertex to the given collection.

Example:

shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/male <<EOF
{ 
  "name" : "Francis" 
}
EOF

HTTP/1.1 202 Accepted
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47NdC--_

{ 
  "error" : false, 
  "vertex" : { 
    "_id" : "male/8068", 
    "_key" : "8068", 
    "_rev" : "_WQ47NdC--_" 
  }, 
  "code" : 202 
}

Path Parameters

  • graph-name (required): The name of the graph.
  • collection-name (required): The name of the vertex collection the vertex belongs to.

Query Parameters

  • waitForSync (optional): Define if the request should wait until synced to disk.

Request Body (required)

The body has to be the JSON object to be stored.

Return Codes

  • 201: Returned if the vertex could be added and waitForSync is true.
  • 202: Returned if the request was successful but waitForSync is false.
  • 404: Returned if no graph or no vertex collection with this name could be found.

Examples

shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/male <<EOF
{ 
  "name" : "Francis" 
}
EOF

HTTP/1.1 202 Accepted
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47NdC--_

show response body

Get a vertex

fetches an existing vertex

GET /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}

Gets a vertex from the given collection.

Example:

shell> curl --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47Qx6--_

{ 
  "error" : false, 
  "vertex" : { 
    "_key" : "alice", 
    "_id" : "female/alice", 
    "_rev" : "_WQ47Qx6--_", 
    "name" : "Alice" 
  }, 
  "code" : 200 
}

Path Parameters

  • graph-name (required): The name of the graph.
  • collection-name (required): The name of the vertex collection the vertex belongs to.
  • vertex-key (required): The _key attribute of the vertex.

Header Parameters

  • if-match (optional): If the "If-Match" header is given, then it must contain exactly one Etag. The document is returned, if it has the same revision as the given Etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the Etag in an attribute rev in the URL.

Return Codes

  • 200: Returned if the vertex could be found.
  • 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
  • 412: Returned if if-match header is given, but the documents revision is different.

Examples

shell> curl --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice

HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47Qx6--_

show response body

Modify a vertex

replace an existing vertex

PATCH /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}

Updates the data of the specific vertex in the collection.

Example:

shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{ 
  "age" : 26 
}
EOF

HTTP/1.1 202 Accepted
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47SSm--_

{ 
  "error" : false, 
  "vertex" : { 
    "_id" : "female/alice", 
    "_key" : "alice", 
    "_rev" : "_WQ47SSm--_", 
    "_oldRev" : "_WQ47SSa--B" 
  }, 
  "code" : 202 
}

Path Parameters

  • graph-name (required): The name of the graph.
  • collection-name (required): The name of the vertex collection the vertex belongs to.
  • vertex-key (required): The _key attribute of the vertex.

Query Parameters

  • waitForSync (optional): Define if the request should wait until synced to disk.
  • keepNull (optional): Define if values set to null should be stored. By default the key is not removed from the document.

Header Parameters

  • if-match (optional): If the "If-Match" header is given, then it must contain exactly one Etag. The document is updated, if it has the same revision as the given Etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the Etag in an attribute rev in the URL.

Request Body (required)

The body has to contain a JSON object containing exactly the attributes that should be replaced.

Return Codes

  • 200: Returned if the vertex could be updated.
  • 202: Returned if the request was successful but waitForSync is false.
  • 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
  • 412: Returned if if-match header is given, but the documents revision is different.

Examples

shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{ 
  "age" : 26 
}
EOF

HTTP/1.1 202 Accepted
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47SSm--_

show response body

Replace a vertex

replaces an existing vertex

PUT /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}

Replaces the data of a vertex in the collection.

Example:

shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{ 
  "name" : "Alice Cooper", 
  "age" : 26 
}
EOF

HTTP/1.1 202 Accepted
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47TpK--_

{ 
  "error" : false, 
  "vertex" : { 
    "_id" : "female/alice", 
    "_key" : "alice", 
    "_rev" : "_WQ47TpK--_", 
    "_oldRev" : "_WQ47Toy--B" 
  }, 
  "code" : 202 
}

Path Parameters

  • graph-name (required): The name of the graph.
  • collection-name (required): The name of the vertex collection the vertex belongs to.
  • vertex-key (required): The _key attribute of the vertex.

Query Parameters

  • waitForSync (optional): Define if the request should wait until synced to disk.

Header Parameters

  • if-match (optional): If the "If-Match" header is given, then it must contain exactly one Etag. The document is updated, if it has the same revision as the given Etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the Etag in an attribute rev in the URL.

Request Body (required)

The body has to be the JSON object to be stored.

Return Codes

  • 200: Returned if the vertex could be replaced.
  • 202: Returned if the request was successful but waitForSync is false.
  • 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
  • 412: Returned if if-match header is given, but the documents revision is different.

Examples

shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice <<EOF
{ 
  "name" : "Alice Cooper", 
  "age" : 26 
}
EOF

HTTP/1.1 202 Accepted
x-content-type-options: nosniff
content-type: application/json; charset=utf-8
etag: _WQ47TpK--_

show response body

Remove a vertex

removes a vertex from a graph

DELETE /_api/gharial/{graph-name}/vertex/{collection-name}/{vertex-key}

Removes a vertex from the collection.

Example:

shell> curl -X DELETE --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice

HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

{ 
  "error" : false, 
  "removed" : true, 
  "code" : 202 
}

Path Parameters

  • graph-name (required): The name of the graph.
  • collection-name (required): The name of the vertex collection the vertex belongs to.
  • vertex-key (required): The _key attribute of the vertex.

Query Parameters

  • waitForSync (optional): Define if the request should wait until synced to disk.

Header Parameters

  • if-match (optional): If the "If-Match" header is given, then it must contain exactly one Etag. The document is updated, if it has the same revision as the given Etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the Etag in an attribute rev in the URL.

Return Codes

  • 200: Returned if the vertex could be removed.
  • 202: Returned if the request was successful but waitForSync is false.
  • 404: Returned if no graph with this name, no vertex collection or no vertex with this id could be found.
  • 412: Returned if if-match header is given, but the documents revision is different.

Examples

shell> curl -X DELETE --dump - http://localhost:8529/_api/gharial/social/vertex/female/alice

HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8
x-content-type-options: nosniff

show response body