ArangoDB v2.8 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version here: Try latest

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.

@RESTPARAM{graph-name, string, required} The name of the graph.
@RESTPARAM{collection-name, string, required} The name of the vertex collection the vertex belongs to.

@RESTPARAM{waitForSync, boolean, optional} Define if the request should wait until synced to disk.
@RESTALLBODYPARAM{storeThisObject,object,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
content-type: application/json
etag: 545278081

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.

@RESTPARAM{graph-name, string, required} The name of the graph.
@RESTPARAM{collection-name, string, required} The name of the vertex collection the vertex belongs to.
@RESTPARAM{vertex-key, string, required} The _key attribute of the vertex.

@RESTPARAM{if-match, string, 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
content-type: application/json
etag: 573917313

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.

@RESTPARAM{graph-name, string, required} The name of the graph.
@RESTPARAM{collection-name, string, required} The name of the vertex collection the vertex belongs to.
@RESTPARAM{vertex-key, string, required} The _key attribute of the vertex.

@RESTPARAM{waitForSync, boolean, optional} Define if the request should wait until synced to disk.
@RESTPARAM{keepNull, boolean, optional} Define if values set to null should be stored. By default the key is removed from the document.

@RESTPARAM{if-match, string, 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.
@RESTALLBODYPARAM{replaceAttributes,object,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
content-type: application/json
etag: 596985985

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.

@RESTPARAM{graph-name, string, required} The name of the graph.
@RESTPARAM{collection-name, string, required} The name of the vertex collection the vertex belongs to.
@RESTPARAM{vertex-key, string, required} The _key attribute of the vertex.

@RESTPARAM{waitForSync, boolean, optional} Define if the request should wait until synced to disk.

@RESTPARAM{if-match, string, 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.
@RESTALLBODYPARAM{storeThisJsonObject,object,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
content-type: application/json
etag: 620841089

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.

@RESTPARAM{graph-name, string, required} The name of the graph.
@RESTPARAM{collection-name, string, required} The name of the vertex collection the vertex belongs to.
@RESTPARAM{vertex-key, string, required} The _key attribute of the vertex.

@RESTPARAM{waitForSync, boolean, optional} Define if the request should wait until synced to disk.

@RESTPARAM{if-match, string, 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

show response body