ArangoDB Manual Pages


HTTP Interface for Graphs
POST /_api/graph
(create graph)
POST /_api/graph
Creates a new graph.The call expects a JSON hash array as body with the following attributes:
  • _key: The name of the new graph.
  • vertices: The name of the vertices collection.
  • edges: The name of the egde collection.
Returns an object with an attribute graph containing a list of all graph properties.
Examples
> curl --data @- -X POST --dump - http://localhost:8529/_api/graph
{"_key" : "graph1", "vertices" : "v", "edges" : "e"}

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

{
  "graph": {
    "_id": "_graphs/graph1",
    "_rev": "11767958",
    "_key": "graph1",
    "vertices": "v",
    "edges": "e"
  },
  "error": false,
  "code": 201
}

GET /_api/graph
(get graph properties)
GET /_api/graph/graph-name
Returns an object with an attribute graph containing a list of all graph properties.
Examples
get graph by name
> curl -X GET --dump - http://localhost:8529/_api/graph/graph1

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "graph": {
    "_id": "_graphs/graph1",
    "_rev": "11767958",
    "_key": "graph1",
    "vertices": "v",
    "edges": "e"
  },
  "error": false,
  "code": 200
}

DELETE /_api/graph
(delete graph)
DELETE /_api/graph/graph-name
Deletes graph, edges and vertices
Examples
> curl -X DELETE --dump - http://localhost:8529/_api/graph/graph1

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "deleted": true,
  "error": false,
  "code": 200
}

POST /_api/graph/graph-name/vertex
(create vertex)
POST /_api/graph/graph-name/vertex
Creates a vertex in a graph.The call expects a JSON hash array as body with the vertex properties:
  • _key: The name of the vertex (optional).
  • further optional attributes.
Returns an object with an attribute vertex containing a list of all vertex properties.
Examples
> curl --data @- -X POST --dump - http://localhost:8529/_api/graph/graph1/vertex
{"_key" : "v1", "optional1" : "val1", "optional2" : "val2"}

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

{
  "vertex": {
    "_id": "v/v1",
    "_rev": "24332177",
    "_key": "v1",
    "optional1": "val1",
    "optional2": "val2"
  },
  "error": false,
  "code": 201
}

GET /_api/graph/graph-name/vertex
(get vertex)
GET /_api/graph/graph-name/vertex/ vertex-name
Returns an object with an attribute vertex containing a list of all vertex properties.
Examples
get vertex properties by name
> curl -X GET --dump - http://localhost:8529/_api/graph/graph1/vertex/v1

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "vertex": {
    "_id": "v/v1",
    "_rev": "24332177",
    "_key": "v1",
    "optional1": "val1",
    "optional2": "val2"
  },
  "error": false,
  "code": 200
}

PUT /_api/graph/graph-name/vertex
(update vertex)
PUT /_api/graph/graph-name/vertex/ vertex-name
Replaces the vertex properties.The call expects a JSON hash array as body with the new vertex properties.Returns an object with an attribute vertex containing a list of all vertex properties.
Examples
> curl --data @- -X PUT --dump - http://localhost:8529/_api/graph/graph1/vertex/v1
{"optional1" : "val2"}

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "vertex": {
    "_id": "v/v1",
    "_rev": "24332190",
    "_key": "v1",
    "optional1": "val2"
  },
  "error": false,
  "code": 200
}

PATCH /_api/graph/graph-name/vertex
(update vertex)
PATCH /_api/graph/graph-name/vertex/ vertex-name
Partially updates the vertex properties.The call expects a JSON hash array as body with the properties to patch.Setting an attribute value to null in the patch document will cause a value of null be saved for the attribute by default. If the intention is to delete existing attributes with the patch command, the URL parameter keepNull can be used with a value of false. This will modify the behavior of the patch command to remove any attributes from the existing document that are contained in the patch document with an attribute value of null. Returns an object with an attribute vertex containing a list of all vertex properties.
Examples
> curl --data @- -X PATCH --dump - http://localhost:8529/_api/graph/graph1/vertex/v1
{"optional2" : "vertexPatch2"}

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "vertex": {
    "_id": "v/v1",
    "_rev": "24332193",
    "_key": "v1",
    "optional1": "val2",
    "optional2": "vertexPatch2"
  },
  "error": false,
  "code": 200
}

> curl --data @- -X PATCH --dump - http://localhost:8529/_api/graph/graph1/vertex/v1?keepNull=false
{"optional2" : null}

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "vertex": {
    "_id": "v/v1",
    "_rev": "24332199",
    "_key": "v1",
    "optional1": "val2"
  },
  "error": false,
  "code": 200
}

DELETE /_api/graph/graph-name/vertex
(delete vertex)
DELETE /_api/graph/graph-name/vertex/ vertex-name
Deletes vertex and all in and out edges of the vertex
Examples
> curl -X DELETE --dump - http://localhost:8529/_api/graph/graph1/vertex/v1

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "deleted": true,
  "error": false,
  "code": 200
}

POST /_api/graph/graph-name/edge
(create edge)
POST /_api/graph/graph-name/edge
Creates an edge in a graph.The call expects a JSON hash array as body with the edge properties:
  • _key: The name of the edge.
  • _from: The name of the from vertex.
  • _to: The name of the to vertex.
  • $label: A label for the edge (optional).
  • further optional attributes.
Returns an object with an attribute edge containing the list of all edge properties.
Examples
> curl --data @- -X POST --dump - http://localhost:8529/_api/graph/graph1/edge
{"_key" : "edge1", "_from" : "vert2", "_to" : "vert1", "optional1" : "val1"}

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

{
  "edge": {
    "_id": "e/edge1",
    "_rev": "57595366",
    "_key": "edge1",
    "_from": "v/vert2",
    "_to": "v/vert1",
    "$label": null,
    "optional1": "val1"
  },
  "error": false,
  "code": 201
}

GET /_api/graph/graph-name/edge
(get edge)
GET /_api/graph/graph-name/edge/ edge-name
Returns an object with an attribute edge containing a list of all edge properties.
Examples
> curl -X GET --dump - http://localhost:8529/_api/graph/graph1/edge/edge1

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "edge": {
    "_id": "e/edge1",
    "_rev": "57595366",
    "_key": "edge1",
    "_from": "v/vert2",
    "_to": "v/vert1",
    "$label": null,
    "optional1": "val1"
  },
  "error": false,
  "code": 200
}

PUT /_api/graph/graph-name/edge
(update edge)
PUT /_api/graph/graph-name/edge/ edge-name
Replaces the optional edge properties.The call expects a JSON hash array as body with the new edge properties.Returns an object with an attribute edge containing a list of all edge properties.
Examples
> curl --data @- -X PUT --dump - http://localhost:8529/_api/graph/graph1/edge/edge1
{"optional2" : "val2"}

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "edge": {
    "_id": "e/edge1",
    "_rev": "57595391",
    "_key": "edge1",
    "_from": "v/vert2",
    "_to": "v/vert1",
    "$label": null,
    "optional2": "val2"
  },
  "error": false,
  "code": 200
}

PATCH /_api/graph/graph-name/edge
(update edge)
PATCH /_api/graph/graph-name/edge/ vertex-name
Partially updates the edge properties.The call expects a JSON hash array as body with the properties to patch.Setting an attribute value to null in the patch document will cause a value of null be saved for the attribute by default. If the intention is to delete existing attributes with the patch command, the URL parameter keepNull can be used with a value of false. This will modify the behavior of the patch command to remove any attributes from the existing document that are contained in the patch document with an attribute value of null. Returns an object with an attribute edge containing a list of all edge properties.
Examples
> curl --data @- -X PATCH --dump - http://localhost:8529/_api/graph/graph1/edge/edge1
{"optional3" : "val3"}

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "edge": {
    "_id": "e/edge1",
    "_rev": "57595398",
    "_key": "edge1",
    "_from": "v/vert2",
    "_to": "v/vert1",
    "$label": null,
    "optional2": "val2",
    "optional3": "val3"
  },
  "error": false,
  "code": 200
}

DELETE /_api/graph/graph-name/edge
(delete edge)
DELETE /_api/graph/graph-name/edge/ edge-name
Deletes an edge of the graph
Examples
> curl -X DELETE --dump - http://localhost:8529/_api/graph/graph1/edge/edge1

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{
  "deleted": true,
  "error": false,
  "code": 200
}

POST /_api/graph/graph-name/vertices/ vertice-name
(get vertices)
POST /_api/graph/graph-name/vertices/ vertice-name
Returns a cursor.The call expects a JSON hash array as body to filter the result:
  • batchSize: the batch size of the returned cursor
  • limit: limit the result size
  • count: return the total number of results (default "false")
  • filter: a optional filter
The attributes of filter

  • direction: Filter for inbound (value "in") or outbound (value "out") neighbors. Default value is "any".
  • labels: filter by an array of edge labels (empty array means no restriction)
  • properties: filter neighbors by an array of edge properties
The attributes of a property filter

  • key: filter the result vertices by a key value pair
  • value: the value of the key
  • compare: a compare operator
Examples
Select all vertices
> curl --data @- -X POST --dump - http://localhost:8529/_api/grap/graph1/vertices/id2
{"batchSize" : 100 }

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

{
  "result": [
    {
      "_id": "v/id3",
      "_rev": "47810529",
      "_key": "id3",
      "optional2": 2,
      "optional1": "val1"
    },
    {
      "_id": "v/id1",
      "_rev": "47548385",
      "_key": "id1",
      "optional2": 1,
      "optional1": "val1"
    }
  ],
  "hasMore": false,
  "error": false,
  "code": 201
}

> curl --data @- -X POST --dump - http://localhost:8529/_api/grap/graph1/vertices/id2
{"batchSize" : 100, "filter" : { "direction" : "out" } }

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

{
  "result": [
    {
      "_id": "v/id3",
      "_rev": "47810529",
      "_key": "id3",
      "optional2": 2,
      "optional1": "val1"
    }
  ],
  "hasMore": false,
  "error": false,
  "code": 201
}

POST /_api/graph/graph-name/edges/ vertex-name
(get edges)
POST /_api/graph/graph-name/edges/ vertex-name
Returns a cursor.The call expects a JSON hash array as body to filter the result:
  • batchSize: the batch size of the returned cursor
  • limit: limit the result size
  • count: return the total number of results (default "false")
  • filter: a optional filter
The attributes of filter

  • direction: Filter for inbound (value "in") or outbound (value "out") neighbors. Default value is "any".
  • labels: filter by an array of edge labels
  • properties: filter neighbors by an array of properties
The attributes of a property filter

  • key: filter the result vertices by a key value pair
  • value: the value of the key
  • compare: a compare operator
Examples
Select all edges
> curl --data @- -X POST --dump - http://localhost:8529/_api/graph/graph1/edges/id2
{"batchSize" : 100}

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

{
  "result": [
    {
      "_id": "e/edge1",
      "_rev": "125407382",
      "_key": "edge1",
      "_from": "v/id1",
      "_to": "v/id2",
      "$label": null,
      "optional1": "val1a"
    },
    {
      "_id": "e/edge2",
      "_rev": "125800598",
      "_key": "edge2",
      "_from": "v/id2",
      "_to": "v/id3",
      "$label": null,
      "optional1": "val1b"
    }
  ],
  "hasMore": false,
  "error": false,
  "code": 201
}