Sony Arouje

a programmer's log

Archive for February 3rd, 2012

Neo4jD–.NET client for Neo4j Graph DB

with 18 comments

Last couple of days I was working on a small light weight .NET client for Neo4j. The client framework is still in progress. This post gives some existing Api’s in Neo4jD to perform basic graph operations. In Neo4j two main entities are Nodes and Relationships. So my initial focus for the client library is to deal with Node and Relationship. The communication between client and Neo4j server is in REST Api’s and the response from the server is in json format.

Let’s go through some of the Neo4j REST Api’s and the equivalent api’s in Neo4jD, you can see more details of Neo4j RestAPi’s here.

The below table will show how to call Neo4j REST Api directly from an application and the right hand will show how to do the same operation using Neo4jD client.

Neo4j Api Equivalent Neo4jD Api
Create Node

POST http://localhost:7474/db/data/node
Accept: application/json
Content-Type: application/json
{"FirstName" : "Sony"}

Response (click here to see full response)

  "outgoing_relationships" : "
  "data" : {
    "foo" : "bar"


Node sony=new Node();

Get Node by ID
GET http://localhost:7474/db/data/node/3

Response (click here to see full response)

  "outgoing_relationships" :
  "data" : {
    "FirstName" : "Sony"
  "traverse" :
http://localhost:7474/db/data. . .{returnType},

Node sony=Node.Get(1);
Assert.AreEqual(“Sony”, sony.GetProperty(“FirstName”);

The Neo4jD will create a Rest request to fetch the Node with Id 1 and parse the json response and set the properties and required field.

Create Relationship between two Nodes

POST http://localhost:7474/db/data/node/1/relationships
Accept: application/json
Content-Type: application/json
{"to" :
http://localhost:7474/db/data/node/2, "type" : "wife"}


(click here to see full response)

Node sony=Node.Get(1); //Get an existing node
//Create a new node
Node viji=new Node();

RelationShip relation=sony.CreateRelationshipTo(viji, “wife”);


Client lib is still missing some basic features and I am working on it.

The next important part of the library is Graph traversing. Neo4j supports REST api, Cypher and Germlin for Graph traversing. I am currently writing a query creator for Germlin. So the initial version of Neo4jD will only support Germlin.

If any one wants to join the project feels free to send me a personal mail or add a comment. You all can have a look at the code in Git.

Neo4jD Part 2  Neo4jD Part 3  How to Persist Static typed Entities


Neo4jD Git Repository

Written by Sony Arouje

February 3, 2012 at 2:28 pm

Posted in .NET

Tagged with , , ,

%d bloggers like this: