Neo4j Developer Guides

Neo4j Developer Resources

All you need to be happy and successful with Neo4j

Getting Started

2. Query Data

Get an example data set, or model and import your own data. Then query your graph to solve your problem.

3. Build your application

Use the Neo4j tools to access your data or develop an application your favorite programming language.

What is a Graph Database (in under 10 Minutes)

Start with an Example

Movie Recommendations

Create a Movie Recommendations Sandbox

Generate personalized real-time recommendations using a dataset of movie reviews.

Network Management

Create a Neo4j Network Management Sandbox

Dependency and root cause analysis for network and IT management.

Fraud Detection

Create a Fraud Detection Sandbox

Fraud detection with a financial transactions dataset, the Neo4j Graph Data Science Library, and Neo4j Bloom visualization.

Code Examples by Language

Neo4j officially supports drivers for .Net, Java, Node.js, GoLang and Python. Our community contributors provide many more, including PHP, Ruby, R, Erlang and Clojure.

// Add your the driver dependency to your pom.xml build.gradle etc.
// Java Driver Dependency: http://search.maven.org/#artifactdetails|org.neo4j.driver|neo4j-java-driver|4.0.1|jar
// Reactive Streams http://search.maven.org/#artifactdetails|org.reactivestreams|reactive-streams|1.0.3|jar
// download jars into current directory
// java -cp "*" Example.java

import org.neo4j.driver.*;
import static org.neo4j.driver.Values.parameters;

public class Example {

  public static void main(String...args) {

    Driver driver = GraphDatabase.driver("neo4j+s://demo.neo4jlabs.com:7687",
              AuthTokens.basic("mUser","s3cr3t"));

    try (Session session = driver.session(SessionConfig.forDatabase("movies"))) {

      String cypherQuery =
        "MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName";

      var result = session.readTransaction(
        tx -> tx.run(cypherQuery, 
                parameters("movieTitle","The Matrix"))
            .list());

      for (Record record : result) {
        System.out.println(record.get("actorName").asString());
      }
    }
    driver.close();
  }
}
Node.js
// npm install --save neo4j-driver
// node example.js
const neo4j = require('neo4j-driver');
const driver = neo4j.driver('neo4j+s://demo.neo4jlabs.com:7687',
                  neo4j.auth.basic('mUser', 's3cr3t'), 
                  {/* encrypted: 'ENCRYPTION_OFF' */});

const query =
  `
  MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
  `;

const params = {"movieTitle": "The Matrix"};

const session = driver.session({database:"movies"});

session.run(query, params)
  .then((result) => {
    result.records.forEach((record) => {
        console.log(record.get('actorName'));
    });
    session.close();
    driver.close();
  })
  .catch((error) => {
    console.error(error);
  });
# pip3 install neo4j-driver
# python3 example.py

from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver(
  "neo4j+s://demo.neo4jlabs.com:7687", 
  auth=basic_auth("mUser", "s3cr3t"))

cypher_query = '''
MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
'''

with driver.session(database="movies") as session:
  results = session.read_transaction(
    lambda tx: tx.run(cypher_query,
      movieTitle="The Matrix").data())

  for record in results:
    print(record['actorName'])

driver.close()
// go mod init main
// go run example.go
package main
import (
	"fmt"
	"github.com/neo4j/neo4j-go-driver/neo4j" //Go 1.8
)
func main() {
	s, err := runQuery("bolt://demo.neo4jlabs.com:7687", "mUser", "s3cr3t")
	if err != nil {
		panic(err)
	}
	fmt.Println(s)
}
func runQuery(uri, username, password string) ([]string, error) {
	configForNeo4j4 := func(conf *neo4j.Config) { conf.Encrypted = false }
	driver, err := neo4j.NewDriver(uri, neo4j.BasicAuth(username, password, ""), configForNeo4j4)
	if err != nil {
		return nil, err
	}
	defer driver.Close()
	sessionConfig := neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead, DatabaseName: "movies"}
	session, err := driver.NewSession(sessionConfig)
	if err != nil {
		return nil, err
	}
	defer session.Close()
	results, err := session.ReadTransaction(func(transaction neo4j.Transaction) (interface{}, error) {
		result, err := transaction.Run(
			`
			MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
			`, map[string]interface{}{
				"movieTitle": "The Matrix",
			})
		if err != nil {
			return nil, err
		}
		var arr []string
		for result.Next() {
			value, found := result.Record().Get("actorName")
			if found {
			  arr = append(arr, value.(string))
			}
		}
		if err = result.Err(); err != nil {
			return nil, err
		}
		return arr, nil
	})
	if err != nil {
		return nil, err
	}
	return results.([]string), err
}
.NET
// install dotnet core on your system
// dotnet new console -o .
// dotnet add package Neo4j.Driver
// paste in this code into Program.cs
// dotnet run

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Neo4j.Driver;
  
namespace dotnet {
  class Example {
  static async Task Main() {
    var driver = GraphDatabase.Driver("neo4j+s://demo.neo4jlabs.com:7687", 
                    AuthTokens.Basic("mUser", "s3cr3t"));

    var cypherQuery =
      @"
      MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
      ";

    var session = driver.AsyncSession(o => o.WithDatabase("movies"));
    var result = await session.ReadTransactionAsync(async tx => {
      var r = await tx.RunAsync(cypherQuery, 
              new { movieTitle="The Matrix"});
      return await r.ToListAsync();
    });

    await session?.CloseAsync();
    foreach (var row in result)
      Console.WriteLine(row["actorName"].As<string>());
	  
    }
  }
}

Neo4j Community Forum and Chat

If you’re ever stuck and need help, head over to the Neo4j Community Site. We have an active community of experts who are more than happy to answer your questions.

Why not join our community and introduce yourself? Do you have a side-project or idea and would like to find collaborators?

We also hang out on our Discord Server where you can get quick answers, discuss interesting topics or just banter.

Learn with GraphAcademy

Learn everything you need to know with free, hands-on courses from Neo4j GraphAcademy.

link::https://graphacademy.neo4j.com/courses/beginners/?ref=guides[Courses for Beginners]

Neo4j Fundamentals

Earn the Neo4j Fundamentals Badge

Learn the basics of Neo4j and the property graph model, regardless of your technical knowledge.

Cypher Fundamentals

Earn the Cypher Fundamentals Badge

A 60 minute introduction to Cypher, the query language used to retrieve data from Neo4j.

Graph Data Modeling

Earn the Graph Data Modeling Badge

Learn how correctly model data in your Neo4j graph using best practices.

Importing CSV Data

Earn the Neo4j Fundamentals Badge

Learn how to import data into Neo4j using the LOAD CSV and the Data Importer tool.