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:

  1. Java 1.8+

  2. 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

createDataloadingJob

POST /v1/graph/{graph_id}/dataloading

AdminServiceGraphManagementApi

createGraph

POST /v1/graph

AdminServiceGraphManagementApi

deleteGraph

DELETE /v1/graph/{graph_id}

AdminServiceGraphManagementApi

getGraph

GET /v1/graph/{graph_id}

AdminServiceGraphManagementApi

getSchema

GET /v1/graph/{graph_id}/schema

AdminServiceGraphManagementApi

listGraphs

GET /v1/graph

AdminServiceJobManagementApi

deleteJobById

DELETE /v1/job/{job_id}

AdminServiceJobManagementApi

getJobById

GET /v1/job/{job_id}

AdminServiceJobManagementApi

listJobs

GET /v1/job

AdminServiceProcedureManagementApi

createProcedure

POST /v1/graph/{graph_id}/procedure

AdminServiceProcedureManagementApi

deleteProcedure

DELETE /v1/graph/{graph_id}/procedure/{procedure_id}

AdminServiceProcedureManagementApi

getProcedure

GET /v1/graph/{graph_id}/procedure/{procedure_id}

AdminServiceProcedureManagementApi

listProcedures

GET /v1/graph/{graph_id}/procedure

AdminServiceProcedureManagementApi

updateProcedure

PUT /v1/graph/{graph_id}/procedure/{procedure_id}

AdminServiceServiceManagementApi

getServiceStatus

GET /v1/service/status

AdminServiceServiceManagementApi

restartService

POST /v1/service/restart

AdminServiceServiceManagementApi

startService

POST /v1/service/start

AdminServiceServiceManagementApi

stopService

POST /v1/service/stop

GraphServiceEdgeManagementApi

addEdge

POST /v1/graph/{graph_id}/edge

Add edge to the graph

GraphServiceEdgeManagementApi

deleteEdge

DELETE /v1/graph/{graph_id}/edge

Remove edge from the graph

GraphServiceEdgeManagementApi

getEdge

GET /v1/graph/{graph_id}/edge

Get the edge’s properties with src and dst vertex primary keys.

GraphServiceEdgeManagementApi

updateEdge

PUT /v1/graph/{graph_id}/edge

Update edge’s property

GraphServiceVertexManagementApi

addVertex

POST /v1/graph/{graph_id}/vertex

Add vertex to the graph

GraphServiceVertexManagementApi

deleteVertex

DELETE /v1/graph/{graph_id}/vertex

Remove vertex from the graph

GraphServiceVertexManagementApi

getVertex

GET /v1/graph/{graph_id}/vertex

Get the vertex’s properties with vertex primary key.

GraphServiceVertexManagementApi

updateVertex

PUT /v1/graph/{graph_id}/vertex

Update vertex’s property

QueryServiceApi

procCall

POST /v1/graph/{graph_id}/query

run queries on graph

Documentation for Data Structures

Documentation for Authorization

Authentication is not supported yet, and we will be introducing authorization-related implementation in the near future.