一行代码,即刻分析

一个 POST /graph 入口,覆盖查询、算法、GNN 与实例管理,无需额外依赖

🔀

Cypher + SQL 融合查询

Cypher 做路径、SELECT 做统计、CALL 调算法、图函数内联,四种方式自由组合

⚡

统一入口

所有操作统一 POST /graph,查询、算法、GNN 训练、实例管理,一个接口全搞定

📡

SSE 流式进度

长时间算法支持 SSE 实时推送进度,CALL ASYNC + SSE 让大任务不再黑盒等待

🤖

GNN 训练推理

CALL ASYNC gnn_training / CALL ASYNC gnn_predict,端到端图学习,训练后模型自动部署

概览
REST API
语言 SDK
🐍 Python
☕ Java
📜 JavaScript
POST /graph

所有操作统一走 POST /graph,Cypher 查询、算法调用、实例管理,一个接口搞定

curl -X POST http://localhost:8080/graph \
  -H "Content-Type: application/json" \
  -H "user: your_username" \
  -H "pwd: your_password" \
  -d '{"query": "MATCH (a)-[r]->(b) RETURN a,b,r LIMIT 10", "title": "mygraph"}'

# 算法调用
curl -X POST http://localhost:8080/graph \
  -H "Content-Type: application/json" \
  -H "user: your_username" -H "pwd: your_password" \
  -d '{"query": "CALL pagerank(10)", "title": "mygraph"}'
Python

纯 requests 封装,零额外依赖

import requests, json

class DeepGraph:
    def __init__(self, base_url, user="", pwd=""):
        self.url = base_url.rstrip("/") + "/graph"
        self.headers = {"Content-Type": "application/json", "user": user, "pwd": pwd}

    def _post(self, query, title=""):
        r = requests.post(self.url, json={"query": query, "title": title}, headers=self.headers)
        return r.json()

    def query(self, cypher, graph):
        return self._post(cypher, title=graph)

    def pagerank(self, graph, top=10):
        return self._post(f"CALL pagerank({top})", title=graph)

# 使用
dg = DeepGraph("http://localhost:8080")
result = dg.query("MATCH (a)-[r]->(b) RETURN a,b,r LIMIT 10", "mygraph")
print(result["data"])
Java

JDK 11+ HttpClient,零额外依赖

import java.net.URI;
import java.net.http.*;
import com.google.gson.Gson;

public class DeepGraph {
    private final String url;
    private final HttpClient client = HttpClient.newHttpClient();
    private final String user, pwd;

    public DeepGraph(String baseUrl, String user, String pwd) {
        this.url = baseUrl.replaceAll("/$", "") + "/graph";
        this.user = user; this.pwd = pwd;
    }

    private Map post(String query, String title) throws Exception {
        var json = new Gson().toJson(Map.of("query", query, "title", title));
        var req = HttpRequest.newBuilder().uri(URI.create(url))
            .header("Content-Type", "application/json")
            .header("user", user).header("pwd", pwd)
            .POST(HttpRequest.BodyPublishers.ofString(json)).build();
        var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        return new Gson().fromJson(resp.body(), Map.class);
    }

    public Map query(String cypher, String graph) throws Exception {
        return post(cypher, graph);
    }
}

// 使用
var dg = new DeepGraph("http://localhost:8080", "admin", "123456");
var r = dg.query("MATCH (a)-[r]->(b) RETURN a,b LIMIT 10", "mygraph");
System.out.println(r.get("data"));
JavaScript

fetch 封装,浏览器 / Node.js 通用,零依赖

class DeepGraph {
  constructor(baseUrl, user = '', pwd = '') {
    this.url = baseUrl.replace(/\/$/, '') + '/graph'
    this.headers = { 'Content-Type': 'application/json', user, pwd }
  }

  async _post(query, title = '') {
    const r = await fetch(this.url, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify({ query, title })
    })
    return r.json()
  }

  async query(cypher, graph) {
    return this._post(cypher, graph)
  }

  async pagerank(graph, top = 10) {
    return this._post(`CALL pagerank(${top})`, graph)
  }
}

// 使用
const dg = new DeepGraph('http://localhost:8080')
const r = await dg.query('MATCH (a)-[r]->(b) RETURN a,b LIMIT 10', 'mygraph')
console.log(r.data)