GraphDB Web API

GraphDB is a graph database geared towards knowledge management, collaboration and graph mining.

Learn more »


How does it work?

Download the GraphDB client library for HTML as well as the jQuery library and create an HTML page with the following basic structure:

More information can be found on the GraphDB Github repository and the associated wiki

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
        <meta charset="utf-8" />
        <title>GraphDB HTML example</title>
        <script type="text/javascript" src="/downloads/jquery.js"></script>
        <script type="text/javascript" src="/downloads/GraphDB.js"></script>
        <style>
        .output {
        margin: 50px;
        background-color: rgb(239, 250, 255);
        border: 1px solid rgb(142, 176, 186);
        border-radius: 5px;
        padding: 10px;
        max-width: 600px;
        }
        </style>
</head>
<body>
        <div id="results" class="output"></div>
        <script>
        var hello = {
            Title: "Hello world!",
            Description: "From GraphDB to the world, with love."
        }
        $.when(GraphDB.addEntity(hello)).then(function (id) {
            $.when(GraphDB.getEntity(id)).then(function (entity) {
                $("#results").html("<h3>" + entity.Title + "</h3><p>" + entity.Description + "</p>");
        }
        );
        });
        </script>
</body>
</html>

The GraphDB client library is just a useful wrapper around the jQuery ajax calls and you can use any other library or method you like to access the web API. The library is also a useful way to see what methods are available on the web API.

The very same web API can also be accessed via .Net of course and it's as simple as the following bits:

var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("ApiKey", "Of no importance currently");
var response = await client.GetAsync("http://graphdb.azurewebsites.net/TakeRandomEntity");
response.EnsureSuccessStatusCode();
var content = response.Content;
Console.WriteLine(await content.ReadAsStringAsync());