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)
JavaCypher [source,cypher] —- MATCH (j:JavaVersion)-[rel:INCLUDES]->(f:Feature)-[rel2:BELONGS_TO]->(c:Category {name: "lang"}) WHERE toInteger(j.version) >= 24 RETURN *; —- Java [source,java] —- public 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()); }
Build Graph + AI Powered Apps
Build AI Agents
Design your agents long-term memory and contextual reasoning by storing knowledge in a Neo4j graph. Query relationships directly so agents can ground responses in connected data, with runnable code samples to get started fast.
Get StartedGraph Retrieval-Augmented Generation
(GraphRAG)
Retrieve relationship-aware answers grounded in your LLM’s entities and connections
Model Content Protocol
(MCP)
Enable LLMs with MCP to reason over entities and relationships, not unstructured, disconnected data.
Graph Academy
Become a subject expert, or browse our learning pathways, to find the right course for you.
Graph Academy Courses
Are you a beginner or just getting started? Build your Neo4j foundation with an some of these courses.
Neo4j Certifications
Are you a beginner or just getting started? Build your Neo4j foundation with an some of these courses.
Generative AI
Cypher
Development
Processing
Analytics
Community Forum
Join in-depth technical Q&As and discussions, and connect with fellow Neo4j Developers in real-time
Join the DiscussionNeo4j Documentation
Join in-depth technical Q&As and discussions, and connect with fellow Neo4j Developers in real-time
View DocsNeo4j Text2Cypher: Analyzing Model Struggles and Dataset Imporvements
5 Min Read
Neo4j Text2Cypher: Analyzing Model Struggles and Dataset Imporvements
5 Min Read
Neo4j Text2Cypher: Analyzing Model Struggles and Dataset Imporvements
5 Min Read
- Neo4j Transaction Graph Demo: How to Uncover Fraud
- Smarter GenAI with Neo4j AuraDB and Google Cloud
- Neo4j Transaction Graph Demo: How to Uncover Fraud
- Learn: How to Get Your Data AI-Ready with Knowledge Graphs & GraphRAG
- Learn: What Is a Knowledge Graph, and the Core Skills to Integrate It into Your AI Stack
Learn: How to Get Your Data AI‑Ready with Knowledge Graphs & GraphRAG
As teams move GenAI from prototype to production, they hit real‑world challenges — like boosting accuracy, making outputs explainable, and connecting LLMs to internal data and systems.
This session calls for AI‑ready data — connected data that’s contextual, flexible, and standardized. Learn how to get your data ready to build more reliable AI agents and apps by pairing a knowledge graph with RAG to create a GraphRAG architecture.
RegisterLearn: How to Get Your Data AI-Ready with Knowledge Graphs & GraphRAG
- Understand the fundamentals of nodes, relationships, and properties.
- See how knowledge graphs improve retrieval and grounding for LLMs.
- Explore patterns for ingestion, modeling, and query (Cypher).
Learn: What Is a Knowledge Graph, and the Core Skills to Integrate It into Your AI Stack
- Understand the fundamentals of nodes, relationships, and properties.
- See how knowledge graphs improve retrieval and grounding for LLMs.
- Explore patterns for ingestion, modeling, and query (Cypher).
Python