|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.
The main class is
GraphDatabase, exactly how in python-embedded:
>>> from neo4jrestclient.client import GraphDatabase>>> gdb = GraphDatabase("http://localhost:7474/db/data/")
/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)
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))
Available through Python Package Index:
$ pip install neo4jrestclient