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 Edges
Examples will explain the REST API for manipulating edges of the graph module on the knows graph:
Create an edge
Creates an edge in an existing graph
POST /_api/gharial/{graph-name}/edge/{collection-name}
Creates a new edge in the collection.
Within the body the has to contain a _from and _to value referencing to valid vertices in the graph.
Furthermore the edge has to be valid in the definition of this
edge collection.
@RESTPARAM{graph-name, string, required}
The name of the graph.
@RESTPARAM{collection-name, string, required}
The name of the edge collection the edge belongs to.
@RESTPARAM{waitForSync, boolean, optional}
Define if the request should wait until synced to disk.
@RESTPARAM{_from, string, required}
@RESTPARAM{_to, string, required}
@RESTALLBODYPARAM{storeThisJsonObject,object,required}
The body has to be the JSON object to be stored.
Return codes
-
201: Returned if the edge could be created.
-
202: Returned if the request was successful but waitForSync is false.
-
404: Returned if no graph with this name, no edge collection or no edge with this id could be found.
Examples
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/edge/relation <<EOF
{
"type" : "friend",
"_from" : "female/alice",
"_to" : "female/diana"
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json
etag: 536955009
{
"error" : false,
"code" : 202,
"edge" : {
"_id" : "relation/536955009",
"_rev" : "536955009",
"_key" : "536955009"
}
}
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/gharial/social/edge/relation <<EOF
{
"type" : "friend",
"_from" : "female/alice",
"_to" : "female/diana"
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json
etag: 536955009
Get an edge
fetch an edge
GET /_api/gharial/{graph-name}/edge/{collection-name}/{edge-key}
Gets an edge from the given collection.
@RESTPARAM{graph-name, string, required}
The name of the graph.
@RESTPARAM{collection-name, string, required}
The name of the edge collection the edge belongs to.
@RESTPARAM{edge-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 edge could be found.
-
404: Returned if no graph with this name, no edge collection or no edge 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/edge/relation/aliceAndBob
HTTP/1.1 200 OK
content-type: application/json
etag: 569788545
{
"error" : false,
"code" : 200,
"edge" : {
"_id" : "relation/aliceAndBob",
"_key" : "aliceAndBob",
"_rev" : "569788545",
"_from" : "female/alice",
"_to" : "male/bob",
"type" : "married"
}
}
shell> curl --dump - http://localhost:8529/_api/gharial/social/edge/relation/aliceAndBob
HTTP/1.1 200 OK
content-type: application/json
etag: 569788545
Examples will explain the API on the social graph:
Modify an edge
modify an existing edge
PATCH /_api/gharial/{graph-name}/edge/{collection-name}/{edge-key}
Updates the data of the specific edge in the collection.
@RESTPARAM{graph-name, string, required}
The name of the graph.
@RESTPARAM{collection-name, string, required}
The name of the edge collection the edge belongs to.
@RESTPARAM{edge-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.
@RESTALLBODYPARAM{updateAttributes,object,required}
The body has to be a JSON object containing the attributes to be updated.
Return codes
-
200: Returned if the edge could be updated.
-
202: Returned if the request was successful but waitForSync is false.
-
404: Returned if no graph with this name, no edge collection or no edge with this id could be found.
Examples
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/edge/relation/aliceAndBob <<EOF
{
"since" : "01.01.2001"
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json
etag: 600983681
{
"error" : false,
"code" : 202,
"edge" : {
"_id" : "relation/aliceAndBob",
"_rev" : "600983681",
"_oldRev" : "599869569",
"_key" : "aliceAndBob"
}
}
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/gharial/social/edge/relation/aliceAndBob <<EOF
{
"since" : "01.01.2001"
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json
etag: 600983681
Replace an edge
replace the content of an existing edge
PUT /_api/gharial/{graph-name}/edge/{collection-name}/{edge-key}
Replaces the data of an edge in the collection.
@RESTPARAM{graph-name, string, required}
The name of the graph.
@RESTPARAM{collection-name, string, required}
The name of the edge collection the edge belongs to.
@RESTPARAM{edge-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 edge could be replaced.
-
202: Returned if the request was successful but waitForSync is false.
-
404: Returned if no graph with this name, no edge collection or no edge 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/edge/relation/aliceAndBob <<EOF
{
"type" : "divorced"
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json
etag: 604850305
{
"error" : false,
"code" : 202,
"edge" : {
"_id" : "relation/aliceAndBob",
"_rev" : "604850305",
"_oldRev" : "603867265",
"_key" : "aliceAndBob"
}
}
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/gharial/social/edge/relation/aliceAndBob <<EOF
{
"type" : "divorced"
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json
etag: 604850305
Remove an edge
removes an edge from graph
DELETE /_api/gharial/{graph-name}/edge/{collection-name}/{edge-key}
Removes an edge from the collection.
@RESTPARAM{graph-name, string, required}
The name of the graph.
@RESTPARAM{collection-name, string, required}
The name of the edge collection the edge belongs to.
@RESTPARAM{edge-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 edge could be removed.
-
202: Returned if the request was successful but waitForSync is false.
-
404: Returned if no graph with this name, no edge collection or no edge 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/edge/relation/aliceAndBob
HTTP/1.1 202 Accepted
content-type: application/json
{
"error" : false,
"code" : 202,
"removed" : true
}
shell> curl -X DELETE --dump - http://localhost:8529/_api/gharial/social/edge/relation/aliceAndBob
HTTP/1.1 202 Accepted
content-type: application/json