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.

free style json body

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
etag: _Uxfmh12---
content-type: application/json; charset=utf-8

{ 
  "error" : false, 
  "vertex" : { 
    "_id" : "male/7785", 
    "_key" : "7785", 
    "_rev" : "_Uxfmh12---" 
  }, 
  "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.

Post Body

storeThisObject (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
etag: _Uxfmh12---
content-type: application/json; charset=utf-8

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
etag: _UxfmlWW---
content-type: application/json; charset=utf-8

{ 
  "error" : false, 
  "vertex" : { 
    "_key" : "alice", 
    "_id" : "female/alice", 
    "_rev" : "_UxfmlWW---", 
    "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
etag: _UxfmlWW---
content-type: application/json; charset=utf-8

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.

free style json body

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
etag: _Uxfmncu---
content-type: application/json; charset=utf-8

{ 
  "error" : false, 
  "vertex" : { 
    "_id" : "female/alice", 
    "_key" : "alice", 
    "_rev" : "_Uxfmncu---", 
    "_oldRev" : "_Uxfmnc----" 
  }, 
  "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.

Post Body

replaceAttributes (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
etag: _Uxfmncu---
content-type: application/json; charset=utf-8

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.

free style json body

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
etag: _Uxfmpsm---
content-type: application/json; charset=utf-8

{ 
  "error" : false, 
  "vertex" : { 
    "_id" : "female/alice", 
    "_key" : "alice", 
    "_rev" : "_Uxfmpsm---", 
    "_oldRev" : "_UxfmpsG---" 
  }, 
  "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.

Post Body

storeThisJsonObject (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
etag: _Uxfmpsm---
content-type: application/json; charset=utf-8

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

{ 
  "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

show response body