Skip to main content

pyTigerGraph

pyTigerGraph is a Python client for TigerGraph databases. It wraps the REST++ and GSQL APIs and provides both a synchronous and an asynchronous interface.

Full documentation: https://docs.tigergraph.com/pytigergraph/current/intro/

Downloads: Total Downloads | Monthly Downloads | Weekly Downloads


Installation

Base package

Install via pip:

pip install pyTigerGraph

Or via conda from the tigergraph channel:

conda install -c tigergraph pytigergraph

Optional extras

Extra What it adds Install command
gds Graph Data Science — data loaders for PyTorch Geometric, DGL, and Pandas pip install 'pyTigerGraph[gds]'
mcp Model Context Protocol server — installs pyTigerGraph-mcp (convenience alias) pip install 'pyTigerGraph[mcp]'
fast orjson JSON backend — 2–10× faster parsing, releases the GIL under concurrent load pip install 'pyTigerGraph[fast]'

Extras can be combined:

pip install 'pyTigerGraph[fast,gds,mcp]'

[gds] prerequisites

Install torch before installing the gds extra:

  1. Install Torch
  2. Optionally Install PyTorch Geometric or Install DGL
  3. pip install 'pyTigerGraph[gds]'

[fast] — orjson JSON backend

orjson is a Rust-backed JSON library that is detected and used automatically when installed. No code changes are required. It improves throughput in two ways:

  • Faster parsing — 2–10× vs stdlib json
  • GIL release — threads parse responses concurrently instead of serialising on the GIL

If orjson is not installed the library falls back to stdlib json transparently.


Quickstart

Synchronous connection

from pyTigerGraph import TigerGraphConnection

conn = TigerGraphConnection(
    host="http://localhost",
    graphname="my_graph",
    username="tigergraph",
    password="tigergraph",
)

print(conn.echo())

Use as a context manager to ensure the underlying HTTP session is closed:

with TigerGraphConnection(host="http://localhost", graphname="my_graph") as conn:
    result = conn.runInstalledQuery("my_query", {"param": "value"})

Asynchronous connection

AsyncTigerGraphConnection exposes the same API as TigerGraphConnection but with async/await syntax. It uses aiohttp internally and shares a single connection pool across all concurrent tasks, making it significantly more efficient than threaded sync code at high concurrency.

import asyncio
from pyTigerGraph import AsyncTigerGraphConnection

async def main():
    async with AsyncTigerGraphConnection(
        host="http://localhost",
        graphname="my_graph",
        username="tigergraph",
        password="tigergraph",
    ) as conn:
        result = await conn.runInstalledQuery("my_query", {"param": "value"})
        print(result)

asyncio.run(main())

Token-based authentication

conn = TigerGraphConnection(
    host="http://localhost",
    graphname="my_graph",
    gsqlSecret="my_secret",   # generates a session token automatically
)

HTTPS / TigerGraph Cloud

conn = TigerGraphConnection(
    host="https://my-instance.i.tgcloud.io",
    graphname="my_graph",
    username="tigergraph",
    password="tigergraph",
    tgCloud=True,
)

Connection parameters

Parameter Type Default Description
host str "http://127.0.0.1" Server URL including scheme (http:// or https://)
graphname str "" Target graph name
username str "tigergraph" Database username
password str "tigergraph" Database password
gsqlSecret str "" GSQL secret for token-based auth (preferred over username/password)
apiToken str "" Pre-obtained REST++ API token
jwtToken str "" JWT token for customer-managed authentication
restppPort int|str "9000" REST++ port (auto-fails over to 14240/restpp for TigerGraph 4.x)
gsPort int|str "14240" GSQL server port
certPath str None Path to CA certificate for HTTPS
tgCloud bool False Set to True for TigerGraph Cloud instances

Performance notes

Synchronous mode (TigerGraphConnection)

  • Each thread gets its own dedicated HTTP session and connection pool, so concurrent threads never block each other.
  • Install pyTigerGraph[fast] to activate the orjson backend and reduce JSON parsing overhead under concurrent load.
  • Use ThreadPoolExecutor to run queries in parallel:
from concurrent.futures import ThreadPoolExecutor, as_completed

with TigerGraphConnection(...) as conn:
    with ThreadPoolExecutor(max_workers=16) as executor:
        futures = [executor.submit(conn.runInstalledQuery, "q", {"p": v}) for v in values]
        for f in as_completed(futures):
            print(f.result())

Asynchronous mode (AsyncTigerGraphConnection)

  • Uses a single aiohttp.ClientSession per event loop, with an unbounded connection pool shared across all concurrent coroutines — no GIL, no thread-scheduling overhead.
  • Typically achieves higher QPS and lower tail latency than the threaded sync mode for I/O-bound workloads.
  • A connection may be used from more than one event loop: reused across separate asyncio.run() calls, or shared by threads that each run their own loop. Each loop gets its own session and pool. Use async with (or await conn.aclose()) to release sockets when finished.
import asyncio
from pyTigerGraph import AsyncTigerGraphConnection

async def main():
    async with AsyncTigerGraphConnection(...) as conn:
        tasks = [conn.runInstalledQuery("q", {"p": v}) for v in values]
        results = await asyncio.gather(*tasks)

asyncio.run(main())

Graph Data Science (GDS)

The gds sub-module provides data loaders that stream vertex and edge data from TigerGraph directly into PyTorch Geometric, DGL, or Pandas DataFrames for machine learning workflows.

Install requirements, then access via conn.gds:

conn = TigerGraphConnection(host="...", graphname="...")
loader = conn.gds.vertexLoader(attributes=["feat", "label"], batch_size=1024)
for batch in loader:
    train(batch)

See the GDS documentation for full details.


MCP Server

The TigerGraph MCP server is now a standalone package: pyTigerGraph-mcp. It exposes TigerGraph operations as tools for AI agents and LLM applications (Claude Desktop, Cursor, Copilot, etc.).

# Recommended — install the standalone package directly
pip install pyTigerGraph-mcp

# Or via the pyTigerGraph convenience alias (installs pyTigerGraph-mcp automatically)
pip install 'pyTigerGraph[mcp]'

# Start the server (reads connection config from environment variables)
tigergraph-mcp

For full setup instructions, available tools, configuration examples, and multi-profile support, see the pyTigerGraph-mcp README.

Migrating from pyTigerGraph.mcp? Update your imports:

# Old
from pyTigerGraph.mcp import serve, ConnectionManager
# New
from tigergraph_mcp import serve, ConnectionManager

Getting started video

pyTigerGraph 101

Companion notebook: Google Colab


Metadata

Release files for pyTigerGraph 2.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyTigerGraph 2.0.5
File Size Uploaded
pytigergraph-2.0.5.tar.gz 277.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyTigerGraph 2.0.5
File Interpreter ABI Platform
pytigergraph-2.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 535.4 kB

Release files / pytigergraph-2.0.5.tar.gz

Download URL pytigergraph-2.0.5.tar.gz
Size 277.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c21d4606cfb1f33ed2ca15b05569b3d367b9a7f75ee3076f01b54beb377a0104
BLAKE2b-256 checksum
How to use checksums
f5e8006bdb412d207f43d2c5ce589bb9efadcf4c91249e09d4174f3cba5e6c40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Release files / pytigergraph-2.0.5-py3-none-any.whl

Download URL pytigergraph-2.0.5-py3-none-any.whl
Size 257.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d03d59bf689d5a2ce6b02969b5929889637258685b36d4543ebbe66ee09bdd30
BLAKE2b-256 checksum
How to use checksums
72231dcb34d48ff7a0d1a06d918df3060bdc41a6b77fe5999d9a3de017cc66a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

2.0.5 This release

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

1.8.5

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

2 release files

1.1

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6.8

1 release file

0.0.6.7

1 release file

0.0.6.6

1 release file

0.0.6.5

1 release file

0.0.6.2

1 release file

0.0.6.1

1 release file

0.0.5.5

1 release file

0.0.5.4

1 release file

0.0.5.3

1 release file

0.0.5.2

1 release file

0.0.5.1

1 release file

0.0.5

1 release file

0.0.4.5

1 release file

0.0.4

1 release file

0.0.3

2 release files

0.0.2

1 release file

0.0.0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page