Developer Center
Build Smarter Apps, Easier, with Graph Tools For Your Language
Python# Python code example from neo4j import GraphDatabase # Neo4j connection settings URI = "neo4j+s://.databases.neo4j.io" AUTH = ("neo4j", " ") # Replace with your actual password # Create the driver driver = GraphDatabase.driver(URI, auth=AUTH) # Run a simple query using the execute_query API with driver: result = driver.execute_query( """ MATCH pattern=(p1:Project)-[:USES*1..3]->(m:Module)<-[:USES*1..3]-(p2:Project) WHERE p1 <> p2 RETURN pattern """, database_="neo4j", # default database ) for record in result.records: print(record)
Javapublic class App { public static void main(String[] args) { // Create a new Neo4j driver instance try (var driver = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic("javaversions","javaversions") ) { driver.verifyConnectivity(); // Return orders mapped to JavaVersion domain record var javaVersions = driver.executableQuery(""" MATCH (j:JavaVersion)-[rel:INCLUDES]->(f:Feature)-[rel2:BELONGS_TO]->(c:Category {name: "lang"}) WHERE toInteger(j.version) >= 24 WITH j, collect(f.title) as features, c.name as category RETURN j {.*, features: features, category: category} as javaVersion; """) .execute() .records() .stream() .map(record -> record.get("javaVersion").as(JavaVersion.class)) .toList(); for (var javaVersion : javaVersions) { System.out.println(javaVersion); } } record JavaVersion(String version, String status, LocalDate gaDate, LocalDate eolDate, @Relationship("INCLUDES") Listfeatures) { } record Feature(String title, @Relationship("BELONGS_TO") Category category) { } record Category(String name) { } }
JavaScriptconst neo4j = require('neo4j-driver'); // Neo4j connection settings - replace with your connection information const URI = process.env.NEO4J_URI; const USERNAME = process.env.NEO4J_USERNAME; const PASSWORD = process.env.NEO4J_PASSWORD; const DATABASE = process.env.NEO4J_DATABASE; const AUTH = neo4j.auth.basic(USERNAME, PASSWORD); // Create the driver const driver = neo4j.driver(URI, AUTH); // Run a simple query async function main() { try { const result = await driver.executeQuery( ` MATCH (lib:Library)-[:SUPPORTS]->(f:Feature), (lib)-[:BELONGS_TO]->(t:Trend {name: "Edge Ready"}) RETURN lib.name AS library, f.name AS feature, t.name AS trend `, {}, { database: DATABASE } ); for (const record of result.records) { console.log(record.toObject()); } } catch (error) { console.error('Query failed:', error); } finally { await driver.close(); } } main();
C#using Neo4j.Driver; //Create the driver instance var driverInstance = GraphDatabase.Driver(new Uri("neo4j://127.0.0.1:7687"), AuthTokens.Basic("neo4j", "password")); var queryString = @"MATCH (pkg:Package)-[pkgMaintainedBy:MAINTAINED_BY]->(pkgMaintainer:Maintainer{name:'Microsoft'}) MATCH (pkg)-[tWith:TESTS_WITH]->(tPkg:TestPackage)-[tmb:MAINTAINED_BY]->(tm:Maintainer) WHERE pkgMaintainer.name <> tm.name RETURN *;"; //Run the Cypher query, supplying it with a target database, var results = await driverInstance .ExecutableQuery(queryString) .WithConfig(new QueryConfig(database:"neo4j")) .ExecuteAsync(); foreach (var record in results.Result) { // Print the ASCII art for each path. PrintPathAsAscii(record["path"].As()); PrintPathAsAscii(record["testingPath"].As ()); Console.WriteLine("\n"); } void PrintPathAsAscii(IPath path) { var sb = new StringBuilder(); for (int i = 0; i < path.Nodes.Count; i++) { sb.Append($"({path.Nodes[i].Labels.FirstOrDefault()}:{path.Nodes[i].Properties["name"]})"); if (i < path.Relationships.Count) sb.Append($"-[:{path.Relationships[i].Type}]->"); } Console.WriteLine(sb.ToString()); }
- Intro to Graph Database Series: This Intro to Graph Database collection of short videos getting folks started
- Going Meta Video Series: A series on Semantics, Knowledge Graphs and All Things AI
- Nodes 2025 Replay: NODES 2025 is the biggest graph + AI community conference
- Neo4j Live Sessions: Tune in every week to learn all about Neo4j Graph Databases, AI Systems and more!
Build Intelligent AI + Graph Apps
Create context-aware, reasoning AI
Discover how to model a knowledge graph, retrieve context with GraphRAG, and stream it into agents with MCP, and build graph-aware AI that reasons over connected data with patterns and code to get started fast.
Graph Academy
30+ courses and counting from newcomers to advanced graph and AI development.
Generative AI
Cypher
Development
Processing
Analytics
Master graph fundamentals, development patterns, and AI workflows through guided pathways built for real project success. Each module includes hands-on practice, and you can validate your skills through Neo4j’s certification exams, from the Neo4j Certified Professional to the advanced Graph Data Science certification.
Start Learning
Python