Database Reference
In-Depth Information
Neo4j as a REST-based application
Neo4j exposes various REST endpoints for performing CRUD and search operations over
the Neo4j database. In order to work with these REST endpoints, we need to have a run-
ning Neo4j server and develop a REST client that can invoke these different services.
Let's understand and perform the following steps to deploy the Neo4j server and develop
the REST client for invoking REST APIs exposed by the Neo4j server:
1. Open your console and execute $NEO4J_HOME/bin/neo4j . Wait for success-
ful execution of the command and open your browser and type ht-
tp://localhost:7474/ . You will see the default Neo4j browser.
Note
In case something goes wrong, then check for errors in $NEO4J_HOME/data/
messages.log .
2. Let's extend our MyNeo4jSamples project, which we created in the previous
section. Create Java REST clients, and then invoke the REST APIs exposed by the
Neo4j server.
3. Open the MyNeo4jSamples/pom.xml file and add the following dependencies
under the <dependencies> section:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
4. Add a new package called neo4j.rest.client and a Java class
MyRestClient.java , and import the following packages:
import org.json.JSONObject;
import javax.ws.rs.core.MediaType;
Search WWH ::




Custom Search