Accessing Neo4j from Python using the REST bindings

The REST interface is widely used and in this recipe, we will learn how to access Neo4j from Python using the REST Bindings.

Getting ready

The py2neo module (http://py2neo.org/2.0/) is an excellent Python binding module used to connect to the Neo4j REST API server.

The py2neo module can be installed from both pip and easy_install, as shown here:

$ pip install py2neo
$ easy_install py2neo

How to do it...

The following steps will get you started with this recipe:

  1. First, we will create our first node assuming the default installation, as shown in the following code:
    from py2neo import neo4j
    graph = neo4j.GraphDatabaseService(ENDPOINT_URL)
    graph.create(node(name="A")
  2. Next, let's create our first relation ...

Get Neo4j Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.