Skip to content

HugeGraph Python Client Quick Start

hugegraph-python-client is the Python SDK for Apache HugeGraph. It provides schema management, graph data manipulation, Gremlin execution, real-time traversals, and asynchronous whole-graph computing. HugeGraph-LLM and HugeGraph-ML also use this client for database operations.

The client source code is hosted in the hugegraph-ai repository under hugegraph-python-client/. The import package name is pyhugegraph.

Requirements

  • Python >= 3.12 (Python 3.12–3.14 supported).
  • HugeGraph Server 1.5.0 or later (Server 1.7+ recommends GraphSpace mode; 1.5/1.6 uses legacy routing).
  • pip or uv package manager.

Runtime dependencies include decorator, requests, urllib3, and rich.

Installation

The client provides two installation methods depending on whether you require the stable PyPI release or development features from the master branch.

Note

Version & Feature Boundary: The published PyPI release (hugegraph-python 1.7.x) provides the baseline client supporting CamelCase methods with legacy snake_case aliases. The modern features demonstrated in this guide — including native snake_case APIs, client.olap() whole-graph algorithms, client.task().wait(), client.close(), and updated traverser signatures — align with the master development branch. For testing these features, install the client from source.

PyPI (Stable 1.7.x)
1pip install hugegraph-python
2# Or using uv:
3# uv pip install hugegraph-python
Source (Master)
1git clone https://github.com/apache/hugegraph-ai.git
2cd hugegraph-ai/hugegraph-python-client
3pip install -e .
Workspace (uv)
1git clone https://github.com/apache/hugegraph-ai.git
2cd hugegraph-ai
3uv sync --extra python-client
4source .venv/bin/activate

Connect and Write Data

 1from pyhugegraph.client import PyHugeClient
 2
 3client = PyHugeClient(
 4    url="http://127.0.0.1:8080",
 5    graph="hugegraph",
 6    user="admin",
 7    pwd="admin",
 8    graphspace=None,
 9)
10
11schema = client.schema()
12schema.property_key("name").as_text().if_not_exist().create()
13schema.property_key("birthDate").as_text().if_not_exist().create()
14schema.vertex_label("Person").properties("name", "birthDate") \
15      .use_primary_key_id().primary_keys("name").if_not_exist().create()
16schema.vertex_label("Movie").properties("name") \
17      .use_primary_key_id().primary_keys("name").if_not_exist().create()
18schema.edge_label("ActedIn").source_label("Person").target_label("Movie") \
19      .if_not_exist().create()
20
21graph = client.graph()
22person = graph.add_vertex(
23    "Person", {"name": "Al Pacino", "birthDate": "1940-04-25"}
24)
25movie = graph.add_vertex("Movie", {"name": "The Godfather"})
26edge = graph.add_edge("ActedIn", person.id, movie.id, {})
27
28print(graph.get_vertex_by_id(person.id))
29print(graph.get_edge_by_id(edge.id))
30
31client.close()

Client Parameters

PyHugeClient(url, graph, user, pwd, graphspace=None, timeout=None, *, token=None)

ParameterTypeDefaultDescription
urlstrrequiredBase URL of HugeGraph Server. Prepends http:// if no scheme is provided (e.g. 127.0.0.1:8080).
graphstrrequiredTarget graph name. Second positional parameter.
userstrrequiredUsername sent via HTTP Basic Auth.
pwdstrrequiredPassword sent via HTTP Basic Auth.
graphspacestr or NoneNoneGraphSpace name. When None, resolved automatically via version probe.
timeoutfloat, tuple[float, float] or NoneNone(connect, read) timeouts in seconds, or a single float for both. Defaults to (0.5, 15.0).
tokenstr or NoneNoneExplicit Bearer token; overrides Basic Auth when provided.

Idempotent requests retry on 500, 502, and 504 responses up to three times with a 0.1 backoff factor. Task waiting automatically manages its polling budget without extra HTTP retries.

Server Version and GraphSpace

The client resolves GraphSpace routing at initialization:

  • When an explicit graphspace string is passed, GraphSpace routing is activated immediately.
  • When graphspace=None, the client checks GET {url}/versions to determine the server core version.
  • HugeGraph Server 1.7+ defaults to GraphSpace DEFAULT.
  • HugeGraph Server 1.5 / 1.6 uses legacy non-GraphSpace routing.
  • Servers prior to 1.5.0 are not supported and raise RuntimeError.
  • If the version probe fails and no GraphSpace was specified, client initialization raises an error rather than assuming an invalid route layout.

The routing mode determines request path prefixes: /graphspaces/<graphspace>/graphs/<graph>/... when GraphSpace is enabled, or /graphs/<graph>/... when disabled.

Client Accessors

PyHugeClient maintains a shared HTTP session across all accessors. Accessors cache their managers lazily:

AccessorManagerPurpose
client.schema()SchemaManagerProperty keys, vertex labels, edge labels, index labels
client.graph()GraphManagerVertex and edge CRUD, batch ingestion, paging
client.gremlin()GremlinManagerGremlin script execution
client.traverser()TraverserManagerReal-time graph traversals and paths (OLTP)
client.rank()RankManagerReal-time personalized recommendation ranking (OLTP)
client.olap()OlapManagerAsynchronous whole-graph computing algorithms (OLAP)
client.task()TaskManagerAsynchronous task status, polling, cancellation, and deletion
client.graphs()GraphsManagerGraph metadata, configuration, graph list, data clearing
client.graphspaces()GraphspaceManagerMulti-graphspace management
client.schema_templates()SchemaTemplateManagerReusable schema templates
client.auth()AuthManagerUsers, groups, targets, belongs, and access privileges
client.variable()VariableManagerGraph-level persistent key-value variables
client.metrics()MetricsManagerServer monitoring metrics
client.version()VersionManagerServer component versions
client.rest()RestClientDirect REST API calls and extended operations

Common Operations

Build the Schema

Schema builders are fluent. Call create() to apply, or use append(), eliminate(), and remove() to update existing definitions:

 1schema = client.schema()
 2
 3# Property keys: as_text / as_int / as_long / as_float / as_double / as_bool / as_date
 4# Cardinality: value_single / value_list / value_set
 5schema.property_key("age").as_int().value_single().if_not_exist().create()
 6
 7# Vertex labels: use_automatic_id / use_customize_string_id / use_primary_key_id
 8schema.vertex_label("person").properties("name", "age", "city") \
 9      .primary_keys("name").nullable_keys("city").if_not_exist().create()
10
11# Edge labels: link() specifies source and target vertex labels
12schema.edge_label("knows").link("person", "person").multi_times() \
13      .properties("date", "city").sort_keys("date").nullable_keys("city") \
14      .if_not_exist().create()
15
16# Index labels: on_v / on_e, secondary / range / search / shard / unique
17schema.index_label("personByCity").on_v("person").by("city") \
18      .secondary().if_not_exist().create()

Query the Schema

 1schema = client.schema()
 2print(schema.get_schema())            # Returns whole schema definition dictionary
 3print(schema.get_property_keys())
 4print(schema.get_vertex_labels())
 5print(schema.get_edge_labels())
 6print(schema.get_index_labels())
 7
 8# Query single definitions by name
 9print(schema.get_property_key("name"))
10print(schema.get_vertex_label("person"))
11print(schema.get_edge_label("knows"))
12print(schema.get_index_label("personByCity"))
13
14# Edge relations formatted as "Person--ActedIn-->Movie"
15print(schema.get_relations())

Read, Update, and Delete Graph Data

The graph API accepts property dictionaries:

1graph = client.graph()
2graph.append_vertex(person.id, {"birthDate": "1940-04-25"})    # Append properties
3graph.eliminate_vertex(person.id, {"birthDate": "1940-04-25"}) # Drop properties
4graph.append_edge(edge.id, {"city": "Beijing"})
5graph.eliminate_edge(edge.id, {"city": "Beijing"})
6graph.remove_edge_by_id(edge.id)
7graph.remove_vertex_by_id(person.id)

add_vertex returns a VertexData instance containing id, label, type, and properties. add_edge returns an EdgeData instance containing id, label, type, outV, outVLabel, inV, inVLabel, and properties.

Vertex IDs passed to the client may be strings, integers, or uuid.UUID objects. Booleans are rejected, and integer values must fall within the 64-bit signed range.

Batch Writes

add_vertices accepts (label, properties) tuples, and add_edges accepts (label, out_id, in_id, out_label, in_label, properties) tuples:

1graph = client.graph()
2vertices = graph.add_vertices([
3    ("person", {"name": "Alice", "age": 20}),
4    ("person", {"name": "Bob", "age": 23}),
5])
6edges = graph.add_edges([
7    ("knows", vertices[0].id, vertices[1].id, "person", "person", {"date": "2012-01-10"}),
8])

Paging and Conditional Queries

 1graph = client.graph()
 2
 3# Paging with next_page token
 4vertices, next_page = graph.get_vertex_by_page("person", limit=10)
 5vertices, next_page = graph.get_vertex_by_page("person", limit=10, page=next_page)
 6
 7# Server-side property predicates
 8older = graph.get_vertex_by_condition("person", properties={"age": "P.gt(29)"})
 9
10# Edge paging. When vertex_id is provided, direction is required
11edges, next_page = graph.get_edge_by_page(label="knows", limit=10)
12edges, next_page = graph.get_edge_by_page(vertex_id=person.id, direction="OUT", limit=10)
13
14# Batch lookup by ID list
15graph.get_vertices_by_id([v1.id, v2.id])
16graph.get_edges_by_id([e1.id, e2.id])

Execute Gremlin

1gremlin = client.gremlin()
2result = gremlin.exec("g.V().limit(5)")
3print(result)

exec() automatically binds the graph and g aliases according to the target graph name and resolved GraphSpace.

Traverse the Graph (OLTP)

client.traverser() wraps the server’s real-time traverser endpoints for neighborhood, path, and similarity queries:

 1traverser = client.traverser()
 2
 3traverser.k_out(marko_id, 2)
 4traverser.k_neighbor(marko_id, 2)
 5traverser.same_neighbors(marko_id, josh_id)
 6traverser.jaccard_similarity(marko_id, josh_id)
 7traverser.shortest_path(marko_id, ripple_id, 3)
 8traverser.all_shortest_paths(marko_id, ripple_id, 3)
 9traverser.weighted_shortest_path(marko_id, ripple_id, "weight", 3)
10traverser.single_source_shortest_path(marko_id, 2)
11traverser.multi_node_shortest_path([marko_id, josh_id], max_depth=2)
12traverser.paths(marko_id, josh_id, 2)
13traverser.crosspoints(marko_id, josh_id, 2)
14traverser.rings(marko_id, 3)
15traverser.rays(marko_id, 2)
16traverser.vertices(marko_id)
17traverser.edges(edge_id)

The POST-based variants accept complex request bodies: advanced_paths, customized_paths, template_paths, customized_crosspoints, and fusiform_similarity.

OLAP Whole-Graph Computing

For heavy full-graph algorithms (such as PageRank, Louvain, or Centrality), use client.olap(). These jobs run asynchronously on the server and are tracked through task IDs:

 1# 1. Submit an asynchronous computation task
 2receipt = client.olap().count_vertex()
 3task_id = receipt["task_id"]
 4
 5# 2. Wait for completion and retrieve results
 6task = client.task().wait(task_id, timeout=300, poll_interval=1)
 7result = client.task().result(task)
 8print(result)
 9
10# Or combine submit, wait, and decode in one step:
11result = client.olap().run("count_vertex", timeout=60)

Supported OLAP Algorithms

The server provides 17 unique whole-graph algorithm endpoints:

CategoryAlgorithm Names
Statisticscount_edge, count_vertex, subgraph_stat, triangle_count, rings
Centralitybetweenness_centrality, closeness_centrality, degree_centrality, eigenvector_centrality, stress_centrality
Community & Clusteringcluster_coefficient, k_core, louvain, lpa, weak_connected_component
Ranking & Similaritypage_rank, fusiform_similarity
Tip

Algorithms like page_rank write calculated rank properties back to the graph. For graphs requiring strict schema definitions, declare a nullable DOUBLE property named r_rank on participating vertex labels prior to execution.

Task Lifecycle Management

The TaskManager provides control over asynchronous jobs:

 1task = client.task()
 2
 3# List recent tasks
 4task.list_tasks(status="success", limit=10)
 5
 6# Poll and wait for a task to complete
 7record = task.wait(task_id, timeout=300, poll_interval=1)
 8
 9# Decode task results (parses JSON response once)
10result = task.result(record)
11
12# Cancel or delete tasks
13task.cancel_task(task_id)
14task.delete_task(task_id, force=False)
  • wait(id, timeout=300, poll_interval=1) polls status without fetching the full result payload on every tick.
  • TaskTimeoutError indicates client-side polling timed out; the background job on the server continues running.
  • To terminate a running server task, invoke cancel_task(id) explicitly.

Graph Variables, Metrics, and Metadata

 1# Graph variables
 2variable = client.variable()
 3variable.set("owner", "mary")
 4print(variable.get("owner"))
 5print(variable.all())
 6variable.remove("owner")
 7
 8# Server metrics
 9metrics = client.metrics()
10metrics.get_all_basic_metrics()
11metrics.get_system_metrics()
12metrics.get_backend_metrics()
13
14# Graph management and version
15graphs = client.graphs()
16print(graphs.list())
17print(client.version().version())

Authentication and Authorization

PyHugeClient supports both HTTP Basic Auth and Bearer Token authentication:

1# Switch session to Bearer Token authentication
2client.use_token("your-jwt-token")
3
4# Revert back to HTTP Basic Auth credentials
5client.use_token(None)

AuthManager manages users, groups, targets, belongs, and access privileges:

 1auth = client.auth()
 2
 3user = auth.create_user("test_user", "password")
 4auth.modify_user(user["id"], user_email="hugegraph@apache.org")
 5auth.get_user(user["id"])
 6auth.list_users(limit=10)
 7
 8group = auth.create_group("test_group", "read only")
 9auth.modify_group(group["id"], group_description="updated")
10auth.list_groups()
11
12target = auth.create_target("target1", "hugegraph", "127.0.0.1:8080", [])
13auth.update_target(target["id"], "target1", "hugegraph", "127.0.0.1:8080", [])
14auth.list_targets()
15
16belong = auth.create_belong(user["id"], group["id"])
17auth.update_belong(belong["id"], "description")
18auth.list_belongs()
19
20access = auth.grant_accesses(group["id"], target["id"], "READ")
21auth.modify_accesses(access["id"], "description")
22auth.list_accesses()
23
24# Clean up in reverse dependency order
25auth.revoke_accesses(access["id"])
26auth.delete_belong(belong["id"])
27auth.delete_target(target["id"])
28auth.delete_group(group["id"])
29auth.delete_user(user["id"])

Method Naming and Migration

  • Preferred style: New code should use snake_case methods (add_vertex, property_key, etc.).
  • Backward compatibility: Existing public CamelCase methods (addVertex, propertyKey, etc.) remain supported as direct aliases.
  • Client lifecycle: Use client.close() to release connection pool resources rather than closing individual managers.
  • Return contracts:
    • Legacy convenience helpers get_all_graphs(), get_version(), and get_graph_info() retain JSON strings for backwards compatibility.
    • Modern accessors client.graphs().list(), client.version().version(), and client.graphs().get(graph_name) return parsed Python dictionaries.
    • Weighted and single-source shortest path methods no longer accept max_depth (unsupported by the server endpoint); use capacity, max_degree, and skip_degree controls instead.

Direct REST API Reference

For raw endpoint interactions, batch operations, or capabilities not wrapped by high-level managers, client.rest() exposes the full REST surface:

1rest = client.rest()
2print(rest.vertex.list(label="person", offset=0, limit=20))
3print(rest.task.list(status="success", page="", limit=20))

The table below lists all 194 supported operations aligned with the server contract:

Python REST entryMethodPathQuery parameters
rest.access.create()POST/graphspaces/{graphspace}/auth/accesses—
rest.access.delete()DELETE/graphspaces/{graphspace}/auth/accesses/{id}—
rest.access.get()GET/graphspaces/{graphspace}/auth/accesses/{id}—
rest.access.list()GET/graphspaces/{graphspace}/auth/accessesgroup, target, limit
rest.access.update()PUT/graphspaces/{graphspace}/auth/accesses/{id}—
rest.adamic_adar.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/adamicadarvertex, other, direction, label, max_degree, limit
rest.algorithm.post()POST/graphspaces/{graphspace}/graphs/{graph}/jobs/algorithm/{name}—
rest.all_shortest_paths.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/allshortestpathssource, target, direction, label, max_depth, max_degree, skip_degree, with_vertex, with_edge, capacity
rest.arthas.start_arthas()PUT/arthas—
rest.belong.create()POST/graphspaces/{graphspace}/auth/belongs—
rest.belong.delete()DELETE/graphspaces/{graphspace}/auth/belongs/{id}—
rest.belong.get()GET/graphspaces/{graphspace}/auth/belongs/{id}—
rest.belong.list()GET/graphspaces/{graphspace}/auth/belongsuser, group, limit
rest.belong.update()PUT/graphspaces/{graphspace}/auth/belongs/{id}—
rest.computer.post()POST/graphspaces/{graphspace}/graphs/{graph}/jobs/computer/{name}—
rest.count.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/count—
rest.crosspoints.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/crosspointssource, target, direction, label, max_depth, max_degree, capacity, limit
rest.customized_crosspoints.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/customizedcrosspoints—
rest.customized_paths.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/customizedpaths—
rest.cypher.post()POST/graphspaces/{graphspace}/graphs/{graph}/cypher—
rest.cypher.query()GET/graphspaces/{graphspace}/graphs/{graph}/cyphercypher
rest.edge.create()POST/graphspaces/{graphspace}/graphs/{graph}/graph/edges—
rest.edge.create_batch()POST/graphspaces/{graphspace}/graphs/{graph}/graph/edges/batchcheck_vertex
rest.edge.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/graph/edges/{id}label
rest.edge.get()GET/graphspaces/{graphspace}/graphs/{graph}/graph/edges/{id}—
rest.edge.list()GET/graphspaces/{graphspace}/graphs/{graph}/graph/edgesvertex_id, direction, label, properties, keep_start_p, offset, page, limit
rest.edge.update_batch()PUT/graphspaces/{graphspace}/graphs/{graph}/graph/edges/batch—
rest.edge.update_by_id()PUT/graphspaces/{graphspace}/graphs/{graph}/graph/edges/{id}action
rest.edge_existence.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/edgeexistsource, target, label, sort_values, limit
rest.edge_label.create()POST/graphspaces/{graphspace}/graphs/{graph}/schema/edgelabels—
rest.edge_label.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/schema/edgelabels/{name}—
rest.edge_label.get()GET/graphspaces/{graphspace}/graphs/{graph}/schema/edgelabels/{name}—
rest.edge_label.list()GET/graphspaces/{graphspace}/graphs/{graph}/schema/edgelabelsnames
rest.edge_label.update()PUT/graphspaces/{graphspace}/graphs/{graph}/schema/edgelabels/{name}action
rest.edges.list()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/edgesids
rest.edges.scan()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/edges/scanstart, end, page, page_limit
rest.edges.shards()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/edges/shardssplit_size
rest.exception_trace.get()GET/exception/trace—
rest.exception_trace.trace()PUT/exception/trace—
rest.fusiform_similarity.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/fusiformsimilarity—
rest.graph_space.check_default_role()GET/graphspaces/{graphspace}/roleuser, role, graph
rest.graph_space.create()POST/graphspaces—
rest.graph_space.delete()DELETE/graphspaces/{name}—
rest.graph_space.delete_default_role()DELETE/graphspaces/{graphspace}/roleuser, role, graph
rest.graph_space.get()GET/graphspaces/{graphspace}—
rest.graph_space.list()GET/graphspaces—
rest.graph_space.list_profile()GET/graphspaces/profileprefix
rest.graph_space.manage()PUT/graphspaces/{name}—
rest.graph_space.set_default_role()POST/graphspaces/{graphspace}/role—
rest.graph_space_group.create()POST/graphspaces/{graphspace}/auth/groups—
rest.graph_space_group.delete()DELETE/graphspaces/{graphspace}/auth/groups/{id}—
rest.graph_space_group.get()GET/graphspaces/{graphspace}/auth/groups/{id}—
rest.graph_space_group.list()GET/graphspaces/{graphspace}/auth/groupslimit
rest.graph_space_group.update()PUT/graphspaces/{graphspace}/auth/groups/{id}—
rest.graphs.clear()DELETE/graphspaces/{graphspace}/graphs/{name}/clearconfirm_message
rest.graphs.clone_schema()POST/graphspaces/{graphspace}/graphs/{name}/schema-clonesource
rest.graphs.compact()PUT/graphspaces/{graphspace}/graphs/{name}/compact—
rest.graphs.create()POST/graphspaces/{graphspace}/graphs/{name}clone_graph_name
rest.graphs.create_by_text()POST/graphspaces/{graphspace}/graphs/{name}clone_graph_name
rest.graphs.create_snapshot()PUT/graphspaces/{graphspace}/graphs/{name}/snapshot_create—
rest.graphs.drop()DELETE/graphspaces/{graphspace}/graphs/{name}confirm_message
rest.graphs.get()GET/graphspaces/{graphspace}/graphs/{name}—
rest.graphs.get_conf()GET/graphspaces/{graphspace}/graphs/{name}/conf—
rest.graphs.get_default()GET/graphspaces/{graphspace}/graphs/default—
rest.graphs.graph_read_mode_get()GET/graphspaces/{graphspace}/graphs/{name}/graph_read_mode—
rest.graphs.graph_read_mode_set()PUT/graphspaces/{graphspace}/graphs/{name}/graph_read_mode—
rest.graphs.list()GET/graphspaces/{graphspace}/graphs—
rest.graphs.list_profile()GET/graphspaces/{graphspace}/graphs/profileprefix
rest.graphs.loading_mode_get()GET/graphspaces/{graphspace}/graphs/{name}/mode/owners—
rest.graphs.loading_mode_set()PUT/graphspaces/{graphspace}/graphs/{name}/mode/owners—
rest.graphs.manage()PUT/graphspaces/{graphspace}/graphs/{name}—
rest.graphs.mode_get()GET/graphspaces/{graphspace}/graphs/{name}/mode—
rest.graphs.mode_set()PUT/graphspaces/{graphspace}/graphs/{name}/mode—
rest.graphs.reload()PUT/graphspaces/{graphspace}/graphs/manage—
rest.graphs.resume_snapshot()PUT/graphspaces/{graphspace}/graphs/{name}/snapshot_resume—
rest.graphs.set_default()POST/graphspaces/{graphspace}/graphs/{name}/default—
rest.graphs.unset_default()DELETE/graphspaces/{graphspace}/graphs/{name}/default—
rest.gremlin.get()GET/gremlingremlin, language; additional query map
rest.gremlin.post()POST/gremlin—
rest.gremlin_job.post()POST/graphspaces/{graphspace}/graphs/{graph}/jobs/gremlin—
rest.group.create()POST/auth/groups—
rest.group.delete()DELETE/auth/groups/{id}—
rest.group.get()GET/auth/groups/{id}—
rest.group.list()GET/auth/groupslimit
rest.group.update()PUT/auth/groups/{id}—
rest.index_label.create()POST/graphspaces/{graphspace}/graphs/{graph}/schema/indexlabels—
rest.index_label.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/schema/indexlabels/{name}—
rest.index_label.get()GET/graphspaces/{graphspace}/graphs/{graph}/schema/indexlabels/{name}—
rest.index_label.list()GET/graphspaces/{graphspace}/graphs/{graph}/schema/indexlabelsnames
rest.index_label.update()PUT/graphspaces/{graphspace}/graphs/{graph}/schema/indexlabels/{name}action
rest.jaccard_similarity.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/jaccardsimilarityvertex, other, direction, label, max_degree
rest.jaccard_similarity.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/jaccardsimilarity—
rest.kneighbor.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/kneighborsource, direction, label, max_depth, count_only, max_degree, limit
rest.kneighbor.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/kneighbor—
rest.kout.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/koutsource, direction, label, max_depth, nearest, count_only, max_degree, capacity, limit
rest.kout.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/kout—
rest.login.login()POST/auth/login—
rest.login.logout()DELETE/auth/logout—
rest.login.verify_token()GET/auth/verify—
rest.manager.check_default_role()GET/graphspaces/{graphspace}/auth/managers/defaultrole, graph
rest.manager.check_role()GET/graphspaces/{graphspace}/auth/managers/checktype
rest.manager.create_manager()POST/graphspaces/{graphspace}/auth/managers—
rest.manager.delete()DELETE/graphspaces/{graphspace}/auth/managersuser, type
rest.manager.get_roles_in_gs()GET/graphspaces/{graphspace}/auth/managers/roleuser
rest.manager.list()GET/graphspaces/{graphspace}/auth/managerstype
rest.metrics.all()GET/metricstype
rest.metrics.backend()GET/metrics/backend—
rest.metrics.counters()GET/metrics/counters—
rest.metrics.gauges()GET/metrics/gauges—
rest.metrics.histograms()GET/metrics/histograms—
rest.metrics.meters()GET/metrics/meters—
rest.metrics.statistics()GET/metrics/statisticstype
rest.metrics.system()GET/metrics/system—
rest.metrics.timers()GET/metrics/timers—
rest.multi_node_shortest_path.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/multinodeshortestpath—
rest.neighbor_rank.neighbor_rank()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/neighborrank—
rest.paths.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/pathssource, target, direction, label, max_depth, max_degree, capacity, limit
rest.paths.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/paths—
rest.personal_rank.personal_rank()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/personalrank—
rest.profile.get_profile()GET/—
rest.profile.show_all_apis()GET/apis—
rest.project.create()POST/graphspaces/{graphspace}/auth/projects—
rest.project.delete()DELETE/graphspaces/{graphspace}/auth/projects/{id}—
rest.project.get()GET/graphspaces/{graphspace}/auth/projects/{id}—
rest.project.list()GET/graphspaces/{graphspace}/auth/projectslimit
rest.project.update()PUT/graphspaces/{graphspace}/auth/projects/{id}action
rest.property_key.create()POST/graphspaces/{graphspace}/graphs/{graph}/schema/propertykeys—
rest.property_key.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/schema/propertykeys/{name}—
rest.property_key.get()GET/graphspaces/{graphspace}/graphs/{graph}/schema/propertykeys/{name}—
rest.property_key.list()GET/graphspaces/{graphspace}/graphs/{graph}/schema/propertykeysnames
rest.property_key.update()PUT/graphspaces/{graphspace}/graphs/{graph}/schema/propertykeys/{name}action
rest.raft.add_peer()POST/graphspaces/{graphspace}/graphs/{graph}/raft/add_peergroup, endpoint
rest.raft.get_leader()GET/graphspaces/{graphspace}/graphs/{graph}/raft/get_leadergroup
rest.raft.list_peers()GET/graphspaces/{graphspace}/graphs/{graph}/raft/list_peersgroup
rest.raft.remove_peer()POST/graphspaces/{graphspace}/graphs/{graph}/raft/remove_peergroup, endpoint
rest.raft.set_leader()POST/graphspaces/{graphspace}/graphs/{graph}/raft/set_leadergroup, endpoint
rest.raft.transfer_leader()POST/graphspaces/{graphspace}/graphs/{graph}/raft/transfer_leadergroup, endpoint
rest.rays.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/rayssource, direction, label, max_depth, max_degree, capacity, limit, with_vertex, with_edge
rest.rebuild.edge_label_rebuild()PUT/graphspaces/{graphspace}/graphs/{graph}/jobs/rebuild/edgelabels/{name}—
rest.rebuild.index_label_rebuild()PUT/graphspaces/{graphspace}/graphs/{graph}/jobs/rebuild/indexlabels/{name}—
rest.rebuild.vertex_label_rebuild()PUT/graphspaces/{graphspace}/graphs/{graph}/jobs/rebuild/vertexlabels/{name}—
rest.resource_allocation.create()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/resourceallocationvertex, other, direction, label, max_degree, limit
rest.rings.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/ringssource, direction, label, max_depth, source_in_ring, max_degree, capacity, limit, with_vertex, with_edge
rest.same_neighbors.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/sameneighborsvertex, other, direction, label, max_degree, limit
rest.same_neighbors.same_neighbors()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/sameneighbors—
rest.same_neighbors_batch.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/sameneighborsbatch—
rest.schema.list()GET/graphspaces/{graphspace}/graphs/{graph}/schema—
rest.schema_template.create()POST/graphspaces/{graphspace}/schematemplates—
rest.schema_template.delete()DELETE/graphspaces/{graphspace}/schematemplates/{name}—
rest.schema_template.get()GET/graphspaces/{graphspace}/schematemplates/{name}—
rest.schema_template.list()GET/graphspaces/{graphspace}/schematemplates—
rest.schema_template.update()PUT/graphspaces/{graphspace}/schematemplates/{name}—
rest.shortest_path.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/shortestpathsource, target, direction, label, max_depth, max_degree, skip_degree, with_vertex, with_edge, capacity
rest.single_source_shortest_path.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/singlesourceshortestpathsource, direction, label, weight, max_degree, skip_degree, with_vertex, with_edge, capacity, limit
rest.target.create()POST/graphspaces/{graphspace}/auth/targets—
rest.target.delete()DELETE/graphspaces/{graphspace}/auth/targets/{id}—
rest.target.get()GET/graphspaces/{graphspace}/auth/targets/{id}—
rest.target.list()GET/graphspaces/{graphspace}/auth/targetslimit
rest.target.update()PUT/graphspaces/{graphspace}/auth/targets/{id}—
rest.task.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/tasks/{id}force
rest.task.get()GET/graphspaces/{graphspace}/graphs/{graph}/tasks/{id}with_result
rest.task.list()GET/graphspaces/{graphspace}/graphs/{graph}/tasksstatus, ids, limit, page
rest.task.update()PUT/graphspaces/{graphspace}/graphs/{graph}/tasks/{id}action
rest.template_paths.post()POST/graphspaces/{graphspace}/graphs/{graph}/traversers/templatepaths—
rest.user.create()POST/graphspaces/{graphspace}/auth/users—
rest.user.delete()DELETE/graphspaces/{graphspace}/auth/users/{id}—
rest.user.get()GET/graphspaces/{graphspace}/auth/users/{id}—
rest.user.list()GET/graphspaces/{graphspace}/auth/usersname, limit
rest.user.role()GET/graphspaces/{graphspace}/auth/users/{id}/role—
rest.user.update()PUT/graphspaces/{graphspace}/auth/users/{id}—
rest.variables.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/variables/{key}—
rest.variables.get()GET/graphspaces/{graphspace}/graphs/{graph}/variables/{key}—
rest.variables.list()GET/graphspaces/{graphspace}/graphs/{graph}/variables—
rest.variables.update()PUT/graphspaces/{graphspace}/graphs/{graph}/variables/{key}—
rest.version.list()GET/versions—
rest.vertex.create()POST/graphspaces/{graphspace}/graphs/{graph}/graph/vertices—
rest.vertex.create_batch()POST/graphspaces/{graphspace}/graphs/{graph}/graph/vertices/batch—
rest.vertex.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/graph/vertices/{id}label
rest.vertex.get()GET/graphspaces/{graphspace}/graphs/{graph}/graph/vertices/{id}—
rest.vertex.list()GET/graphspaces/{graphspace}/graphs/{graph}/graph/verticeslabel, properties, keep_start_p, offset, page, limit
rest.vertex.update_batch()PUT/graphspaces/{graphspace}/graphs/{graph}/graph/vertices/batch—
rest.vertex.update_by_id()PUT/graphspaces/{graphspace}/graphs/{graph}/graph/vertices/{id}action
rest.vertex_label.create()POST/graphspaces/{graphspace}/graphs/{graph}/schema/vertexlabels—
rest.vertex_label.delete()DELETE/graphspaces/{graphspace}/graphs/{graph}/schema/vertexlabels/{name}—
rest.vertex_label.get()GET/graphspaces/{graphspace}/graphs/{graph}/schema/vertexlabels/{name}—
rest.vertex_label.list()GET/graphspaces/{graphspace}/graphs/{graph}/schema/vertexlabelsnames
rest.vertex_label.update()PUT/graphspaces/{graphspace}/graphs/{graph}/schema/vertexlabels/{name}action
rest.vertices.list()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/verticesids
rest.vertices.scan()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/vertices/scanstart, end, page, page_limit
rest.vertices.shards()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/vertices/shardssplit_size
rest.weighted_shortest_path.get()GET/graphspaces/{graphspace}/graphs/{graph}/traversers/weightedshortestpathsource, target, direction, label, weight, max_degree, skip_degree, with_vertex, with_edge, capacity
rest.white_ip_list.list()GET/whiteiplist—
rest.white_ip_list.update_status()PUT/whiteipliststatus
rest.white_ip_list.update_white_ips()POST/whiteiplist—

Error Handling

Exceptions reside in pyhugegraph.utils.exceptions:

ExceptionRaised when
NotAuthorizedErrorServer responds with HTTP 401
NotFoundErrorServer responds with HTTP 404
ServerErrorNon-2xx server response (attaches server error payload)
ResponseParseErrorResponse body cannot be decoded to the expected structure
ServiceUnavailableErrorServer is temporarily unavailable
InvalidParameterError, CreateError, RemoveError, UpdateError, DataFormatErrorRaised on client-side validation failures

Sensitive fields (passwords, tokens, secrets) are masked automatically in logs.

1from pyhugegraph.utils.exceptions import NotFoundError
2
3try:
4    graph.get_vertex_by_id("missing-id")
5except NotFoundError:
6    print("Vertex not found")

Development and Verification

Run code quality and test suites from the root of the HugeGraph-AI repository:

  1. Format and lint checks:

    1uv run --extra dev ruff format --check .
    2uv run --extra dev ruff check .
    3uv run --extra dev ty check hugegraph-python-client/src/pyhugegraph
  2. Run unit and contract tests:

    1uv run pytest hugegraph-python-client/src/tests -m "unit or contract"
  3. Run integration tests against a HugeGraph Server:

    1HUGEGRAPH_URL=http://127.0.0.1:8080 \
    2HUGEGRAPH_GRAPH=hugegraph \
    3HUGEGRAPH_USER=admin \
    4HUGEGRAPH_PASSWORD=admin \
    5uv run pytest hugegraph-python-client/src/tests -m "integration and hugegraph"

Upstream CI validates against hugegraph/hugegraph:latest and regression tests against 1.7.0. Source code and test suites reside in hugegraph-python-client/src/pyhugegraph/ and hugegraph-python-client/src/tests/.

Table reader