Java SDK Reference¶
The Interactive Java SDK Reference is a comprehensive guide for developers looking to integrate the Interactive service into their Java applications. This SDK allows users to seamlessly connect to Interactive and leverage its powerful features for graph management, stored procedure management, and query execution.
Requirements¶
Building the API client library requires:
Java 1.8+
Maven (3.8.3+)/Gradle (7.2+)
Installation¶
To install the API client library to your local Maven repository, simply execute:
git clone https://github.com/alibaba/GraphScope.git
cd GraphScope/flex/interactive/sdk/java
mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deploy
Refer to the OSSRH Guide for more information.
Maven users¶
Add this dependency to your project’s POM:
<dependency>
<groupId>com.alibaba.graphscope</groupId>
<artifactId>interactive-sdk</artifactId>
<version>0.3</version>
<scope>compile</scope>
</dependency>
Others¶
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/interactive-sdk-0.3.jar
target/lib/*.jar
Getting Started¶
First, install and start the interactive service via Interactive Getting Started, and you will get the endpoint for the Interactive service.
Interactive Service is listening at ${INTERACTIVE_ENDPOINT}.
Then, connect to the interactive endpoint, and try to run a simple query with following code.
package com.alibaba.graphscope;
import com.alibaba.graphscope.interactive.client.Driver;
import com.alibaba.graphscope.interactive.client.Session;
public class GettingStarted {
public static void main(String[] args) {
//get endpoint from command line
if (args.length != 1) {
System.out.println("Usage: <endpoint>");
return;
}
String endpoint = args[0];
Driver driver = Driver.connect(endpoint);
Session session = driver.session();
// start a query
// run cypher query
try (org.neo4j.driver.Session neo4jSession = driver.getNeo4jSession()) {
org.neo4j.driver.Result result = neo4jSession.run("MATCH(a) return COUNT(a);");
System.out.println("result: " + result.toString());
}
return;
}
}
For more a more detailed example, please refer to Java SDK Example
Documentation for Service APIs¶
All URIs are relative to ${INTERACTIVE_ENDPOINT}
Class |
Method |
HTTP request |
Description |
---|---|---|---|
AdminServiceGraphManagementApi |
POST /v1/graph/{graph_id}/dataloading |
||
AdminServiceGraphManagementApi |
POST /v1/graph |
||
AdminServiceGraphManagementApi |
DELETE /v1/graph/{graph_id} |
||
AdminServiceGraphManagementApi |
GET /v1/graph/{graph_id} |
||
AdminServiceGraphManagementApi |
GET /v1/graph/{graph_id}/schema |
||
AdminServiceGraphManagementApi |
GET /v1/graph |
||
AdminServiceJobManagementApi |
DELETE /v1/job/{job_id} |
||
AdminServiceJobManagementApi |
GET /v1/job/{job_id} |
||
AdminServiceJobManagementApi |
GET /v1/job |
||
AdminServiceProcedureManagementApi |
POST /v1/graph/{graph_id}/procedure |
||
AdminServiceProcedureManagementApi |
DELETE /v1/graph/{graph_id}/procedure/{procedure_id} |
||
AdminServiceProcedureManagementApi |
GET /v1/graph/{graph_id}/procedure/{procedure_id} |
||
AdminServiceProcedureManagementApi |
GET /v1/graph/{graph_id}/procedure |
||
AdminServiceProcedureManagementApi |
PUT /v1/graph/{graph_id}/procedure/{procedure_id} |
||
AdminServiceServiceManagementApi |
GET /v1/service/status |
||
AdminServiceServiceManagementApi |
POST /v1/service/restart |
||
AdminServiceServiceManagementApi |
POST /v1/service/start |
||
AdminServiceServiceManagementApi |
POST /v1/service/stop |
||
GraphServiceEdgeManagementApi |
POST /v1/graph/{graph_id}/edge |
Add edge to the graph |
|
GraphServiceEdgeManagementApi |
DELETE /v1/graph/{graph_id}/edge |
Remove edge from the graph |
|
GraphServiceEdgeManagementApi |
GET /v1/graph/{graph_id}/edge |
Get the edge’s properties with src and dst vertex primary keys. |
|
GraphServiceEdgeManagementApi |
PUT /v1/graph/{graph_id}/edge |
Update edge’s property |
|
GraphServiceVertexManagementApi |
POST /v1/graph/{graph_id}/vertex |
Add vertex to the graph |
|
GraphServiceVertexManagementApi |
DELETE /v1/graph/{graph_id}/vertex |
Remove vertex from the graph |
|
GraphServiceVertexManagementApi |
GET /v1/graph/{graph_id}/vertex |
Get the vertex’s properties with vertex primary key. |
|
GraphServiceVertexManagementApi |
PUT /v1/graph/{graph_id}/vertex |
Update vertex’s property |
|
QueryServiceApi |
POST /v1/graph/{graph_id}/query |
run queries on graph |