Permalink
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (57 sloc) 2.47 KB

neo4j-rest-client's documentation

synopsis:Object-oriented Python library to interact with Neo4j standalone REST server.

The main goal of neo4j-rest-client was to enable Python programmers already using Neo4j locally through python-embedded, to use the Neo4j REST server. So the syntax of neo4j-rest-client's API is fully compatible with python-embedded. However, a new syntax is introduced in order to reach a more pythonic style and to enrich the API with the new features the Neo4j team introduces.

Getting started

The main class is GraphDatabase, exactly how in python-embedded:

>>> from neo4jrestclient.client import GraphDatabase
>>> gdb = GraphDatabase("http://localhost:7474/db/data/")

If /db/data/ is not added, neo4j-rest-client will do an extra request in order to know the endpoint for data.

And now we are ready to create nodes and relationhips:

>>> alice = gdb.nodes.create(name="Alice", age=30)
>>> bob = gdb.nodes.create(name="Bob", age=30)
>>> alice.relationships.create("Knows", bob, since=1980)

Although using labels is usually easier:

>>> people = gdb.labels.create("Person")
>>> people.add(alice, bob)
>>> carl = people.create(name="Carl", age=25)

Now we can list and filter nodes according to the labels they are associated to:

>>> people.filter(Q("age", "gte", 30))

Installation

Available through Python Package Index:

$ pip install neo4jrestclient

Contents: