O'Reilly logo

Neo4j Cookbook by Ankur Goel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required