GraphSpace
Create account

API

GraphSpace provides a RESTful API for managing your graphs. Graphs are represented in JSON format.

Here is a minimal example graph:

{
   "metadata" : {
      "name" : "foo graph",
   },
   "graph" : {
      "data" : {
         "edges" : [
            { "source" : "2", "target" : "1", "id" : "2-1" }
         ],
         "nodes" : [
            { "label" : "A", "id" : "1" },
            { "label" : "B", "id" : "2" }
         ]
      }
   }
}

To add the above graph to GraphSpace, you will need a http client. On debian based systems you can install LWP for example:

sudo apt-get install libwww-perl

Save the above graph to a file name foo.json and run the following command:

POST -C username:password http://graph-space-server/api/graphs < foo.json

Nodes can have the following attributes:

Name Type
id string
label string
popup string
color string
size float
shape string
graph_id int
labelFontWeight string

Edges can have the following attributes:

Name Type
id string
label string
popup string
color string
width float
graph_id int
labelFontWeight string

Get Graph

Method Path
GET /api/graphs/[graph-id]

Example response:

{
   "metadata" : {
      "name" : "foo graph",
   },
   "graph" : {
      "data" : {
         "edges" : [
            { "source" : "2", "target" : "1", "id" : "2-1" }
         ],
         "nodes" : [
            { "label" : "A", "id" : "1" },
            { "label" : "B", "id" : "2" }
         ]
      }
   }
}

Create Graph

Method Path
POST /api/graphs

Example request:

{
   "metadata" : {
      "name" : "foo graph",
      "tags" : ["foo", "bar"]
   },
   "graph" : {
      "data" : {
         "edges" : [
            {
               "source" : "2",
               "target" : "1",
               "id" : "2-1",
               "label" : "2 to 1"
            }
         ],
         "nodes" : [
            { "label" : "A", "id" : "1" },
            { "label" : "B", "id" : "2" }
         ]
      }
   }
}

Example response:

{  
   "id" : "6038",
   "url" : "http://foo.com/graphs/6038"
}

Example response headers:

 Location: "http://foo.com/api/graphs/6038"