### GET {gs}/gsql/v1/queries/install/{requestId} Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets the installation status of a query installation request. ```APIDOC ## GET {gs}/gsql/v1/queries/install/{requestId} ### Description Gets the installation status of a query installation request. ### Method GET ### Endpoint {gs}/gsql/v1/queries/install/{requestId} ### Parameters #### Path Parameters - **requestId** (string) - Required - The request ID. ``` -------------------------------- ### Example: Create connection and run query Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/tigergraph-connection.md Example of creating a TigerGraphConnection for a TigerGraph Cloud instance and using it as a context manager to run an installed query. ```python conn = TigerGraphConnection( host="https://my-instance.i.tgcloud.io", graphname="my_graph", username="tigergraph", password="tigergraph", tgCloud=True, ) print(conn.echo()) with TigerGraphConnection(host="http://localhost", graphname="my_graph") as c: c.runInstalledQuery("my_query", {"param": "value"}) ``` -------------------------------- ### Install a GSQL query with conn.gsql Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Installs the 'RecommendMovies' query on the 'movie' graph using conn.gsql. Installation may take 1-3 minutes. ```python print(conn.gsql(''' USE GRAPH movie INSTALL QUERY RecommendMovies''')) ``` -------------------------------- ### Get installed queries with getInstalledQueries Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Prints all installed queries in a formatted JSON. This is an easier way to get the same information as 'GSQL SHOW QUERIES *'. ```python print(json.dumps(conn.getInstalledQueries(),indent=2)) ``` -------------------------------- ### GET {gs}/gsql/v1/queries/install Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Installs queries in a graph. ```APIDOC ## GET {gs}/gsql/v1/queries/install ### Description Installs queries in a graph. ### Method GET ### Endpoint {gs}/gsql/v1/queries/install ### Parameters #### Query Parameters - **graph** (string) - Required - The graph name. - **queries** (string) - Required - The queries to install. - **flag** (string) - Required - The installation flag. ``` -------------------------------- ### Run Algorithm Examples Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-featurizer.md Examples showing how to run an algorithm synchronously and asynchronously. ```python feat = conn.gds.featurizer() res = feat.runAlgorithm("tg_pagerank", params={"v_type": "Paper", "e_type": "CITES"}) print(res) async_res = feat.runAlgorithm("tg_shortest_ss", params={...}, runAsync=True) results = async_res.wait() # blocks until available ``` -------------------------------- ### Install and start the TigerGraph MCP server Source: https://github.com/tigergraph/pytigergraph/blob/master/README.md Install the standalone pyTigerGraph-mcp package via pip, optionally using the convenience alias that also installs pyTigerGraph. Start the server with the tigergraph-mcp command, which reads connection configuration from environment variables. ```sh # 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 ``` -------------------------------- ### Run schema change and job examples Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/schema.md Example calls to runSchemaChange with a dict and runSchemaChangeJob with force=True. ```python conn.runSchemaChange({"addVertexTypes": [{"Name": "Person", "PrimaryId": {"AttributeType": "STRING", "AttributeName": "id"}, "Attributes": [{"AttributeName": "name", "AttributeType": {"Name": {"Name": "STRING", "Value": ""}, "SchemaName": {}}}]}]}) conn.runSchemaChangeJob("my_job", force=True) ``` -------------------------------- ### Installation commands for pyTigerGraph-mcp Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/mcp.md Recommended installation via pip install pyTigerGraph-mcp, or via the pyTigerGraph convenience alias with the mcp extra. ```sh # Recommended — the standalone package pip install pyTigerGraph-mcp # Or via the pyTigerGraph convenience alias (installs pyTigerGraph-mcp automatically) pip install 'pyTigerGraph[mcp]' ``` -------------------------------- ### installQueries Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Installs one or more GSQL queries into the graph. Supports flags for installation options and can wait for completion. ```APIDOC ## POST /gsql/v1/queries/install ### Description Installs one or more GSQL queries into the graph. Supports flags for installation options and can wait for completion. ### Method POST ### Endpoint /gsql/v1/queries/install ### Parameters #### Query Parameters - **graph** (string) - Required - The name of the graph. - **queries** (string or list) - Required - The query name(s) to install. Use `'*'` or `'all'` to install all queries. - **flag** (string or list) - Optional - Installation flags, comma-joinable. Supported flags: `-single`, `-legacy`, `-debug`, `-cost`, `-force`. - **wait** (boolean) - Optional - If `true`, polls the installation status until complete. Defaults to `true`. ### Request Example ``` POST /gsql/v1/queries/install?graph=myGraph&queries=myQuery&flag=-force&wait=true ``` ### Response #### Success Response (200) - **requestId** (string) - The ID of the installation request. #### Response Example ``` { "requestId": "12345" } ``` ### Error Handling - If `wait=true` and the installation times out after 360 retries (1 hour), a `TigerGraphException` is raised. - Requires TigerGraph version 4.1 or later; otherwise, a `TigerGraphException` with code `0` is raised. ``` -------------------------------- ### shortestPath usage examples Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/pathfinding.md Examples of calling shortestPath with basic parameters and with filters and allShortestPaths enabled. ```python path = conn.shortestPath(("account", "10"), ("person", "50"), maxLength=3) print(path) path = conn.shortestPath( ("account", "10"), ("person", "50"), allShortestPaths=True, vertexFilters=("transfer", "amount>950"), edgeFilters=("receive", "type=4"), ) ``` -------------------------------- ### Example: runLoadingJobWithFile call Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/loading.md Example call to runLoadingJobWithFile with a local file 'data.csv', fileTag 'f1', and jobName 'load_person'. ```python conn.runLoadingJobWithFile("data.csv", fileTag="f1", jobName="load_person") ``` -------------------------------- ### installAlgorithm Method Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-featurizer.md Method to install algorithm query files into the database. ```python def installAlgorithm( self, query_name: str, query_path: str = None, global_change: bool = False, distributed_query: bool = False ) -> str ``` -------------------------------- ### Run installed query with parameters and parse output Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Runs the installed 'RecommendMovies' query with parameters for person 'p', number of similar people 'k1', and number of recommendations 'k2'. Parses the output using parseQueryOutput and prints it as JSON. ```python parameters = { "p": "Dan", "k1": 50, "k2": 10 } results = conn.runInstalledQuery("RecommendMovies", params=parameters) parsed = conn.parseQueryOutput(results) print(json.dumps(parsed, indent=2)) # print(json.dumps(results, indent=2)) ``` -------------------------------- ### Install pyTigerGraph via pip Source: https://github.com/tigergraph/pytigergraph/blob/master/README.md Installs the base pyTigerGraph package using pip. Use this command to get the core client without optional extras. ```sh pip install pyTigerGraph ``` -------------------------------- ### Reserved keyword usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gsql.md Shows how to get reserved keywords and check if a word is reserved. ```python from pyTigerGraph import TigerGraphConnection conn = TigerGraphConnection(...) keywords = conn.getReservedKeywords() print(conn.isReservedKeyword("select")) # True ``` -------------------------------- ### allPaths usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/pathfinding.md Example of calling allPaths with a maximum length and edge filters. ```python paths = conn.allPaths(("account", "10"), ("person", "50"), maxLength=5, edgeFilters={"type": "transfer", "condition": "amount>100"}) ``` -------------------------------- ### Trainer usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-models-trainer.md Example of creating a Trainer with a model, training and eval loaders, a learning rate of 1e-3, and a PrinterCallback, then training for 50 epochs. ```python from pyTigerGraph.gds.trainer import Trainer, PrinterCallback trainer = Trainer(model=model, training_dataloader=train_loader, eval_dataloader=eval_loader, optimizer_kwargs={"lr": 1e-3}, callbacks=[PrinterCallback]) trainer.train(num_epochs=50) ``` -------------------------------- ### Create an S3 data source example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/loading.md Example call to createDataSource with an S3 configuration. The config must include a "type" key. ```python conn.createDataSource("my_s3", {"type": "s3", "access.key": "…", "secret.key": "…", "bucket": "my-bucket"}) ``` -------------------------------- ### Install pyTigerGraph with combined extras Source: https://github.com/tigergraph/pytigergraph/blob/master/README.md Installs pyTigerGraph with the fast, gds, and mcp extras combined. Use this command to enable all optional features at once. ```sh pip install 'pyTigerGraph[fast,gds,mcp]' ``` -------------------------------- ### GET {gs}/gsql/v1/loading-jobs?graph= Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets the list of loading jobs. ```APIDOC ## GET {gs}/gsql/v1/loading-jobs?graph= ### Description Gets the list of loading jobs. ### Method GET ### Endpoint {gs}/gsql/v1/loading-jobs?graph= ### Parameters #### Query Parameters - **graph** (string) - Required - The graph name. ``` -------------------------------- ### PUT {gs}/gsql/v1/udt/files/{ExprFunctions|ExprUtil} Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Installs a user-defined function file using the 4.x path. Used by `installUDF()`. ```APIDOC ## PUT {gs}/gsql/v1/udt/files/{ExprFunctions|ExprUtil} ### Description Installs a user-defined function file using the 4.x path. Used by `installUDF()`. ### Method PUT ### Endpoint `{gs}/gsql/v1/udt/files/{ExprFunctions|ExprUtil}` ### Parameters #### Path Parameters - **ExprFunctions|ExprUtil** (string) - Required - The file name (either ExprFunctions or ExprUtil). #### Request Body - **fileText** (string) - Required - The file text. ### Request Example ``` function body... ``` ### Response #### Success Response (200) - **result** (string) - Installation result. #### Response Example ``` { "result": "Success" } ``` ``` -------------------------------- ### GET {gs}/gsql/v1/loading-jobs/{job}[?verbose=] Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets information about a loading job. ```APIDOC ## GET {gs}/gsql/v1/loading-jobs/{job}[?verbose=] ### Description Gets information about a loading job. ### Method GET ### Endpoint {gs}/gsql/v1/loading-jobs/{job}[?verbose=] ### Parameters #### Path Parameters - **job** (string) - Required - The job name. #### Query Parameters - **verbose** (string) - Optional - Verbose flag. ``` -------------------------------- ### echo() Function Signature and Usage Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/utilities.md Defines the echo method that pings the database using GET or POST /echo/ endpoint depending on usePost. Returns 'Hello GSQL' on success. The usage example asserts that the result is 'Hello GSQL'. ```python def echo(self, usePost: bool = False) -> str ``` ```python conn = TigerGraphConnection(host="http://localhost", graphname="g") assert conn.echo() == "Hello GSQL" ``` -------------------------------- ### runInstalledQuery usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Example usage of runInstalledQuery: synchronous call with parameters, asynchronous call returning a request_id, and later retrieval of the result using checkQueryStatus and getQueryResult. ```python result = conn.runInstalledQuery("my_query", {"p": (1,), "limit": 10}) request_id = conn.runInstalledQuery("big_query", runAsync=True) # fetch result of a detached run later: status = conn.checkQueryStatus(request_id) res = conn.getQueryResult(request_id) ``` -------------------------------- ### installUDF Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gsql.md Installs user-defined functions from local file paths or URLs. ```APIDOC ## installUDF ### Description Installs user-defined functions. Each argument is a local file path or http(s) URL whose content is PUT to the server. ### Method PUT ### Endpoint `/gsqlserver/gsql/userdefinedfunction?filename=…` (3.x) or `/gsql/v1/udt/files/…` (4.x) ### Parameters #### Path Parameters - None #### Query Parameters - `filename` - Required - The name of the file to install. #### Request Body - `ExprFunctions` (str) - Optional - Local file path or URL to expression functions. - `ExprUtil` (str) - Optional - Local file path or URL to expression utilities. ### Request Example ```python conn.installUDF(ExprFunctions="path/to/functions.py", ExprUtil="path/to/util.py") ``` ### Response #### Success Response (200) - Returns `0` on success. #### Response Example ```python 0 ``` ### Error Handling - Raises `TigerGraphException(res["message"])` when the server reports an error. ``` -------------------------------- ### Get query execution statistics with getStatistics Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Prints statistics of query execution over the last timespan in seconds. The example uses 8,640,000 seconds (100 days) and default segments. ```python print(json.dumps(conn.getStatistics(seconds=8640000), indent=2)) ``` -------------------------------- ### getToken usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/authentication.md Example usage of getToken. It creates a TigerGraphConnection with host, graphname, username, and password, then calls getToken with a newly created secret and prints the token. This example assumes the connection is set up with credentials that permit password-based tokens. ```python conn = TigerGraphConnection(host="http://localhost", graphname="g", username="tigergraph", password="tigergraph") token = conn.getToken(conn.createSecret()) print(token) ``` -------------------------------- ### GET {gs}/gsql/v1/description?graph=&query= Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets the description of a query. ```APIDOC ## GET {gs}/gsql/v1/description?graph=&query= ### Description Gets the description of a query. ### Method GET ### Endpoint {gs}/gsql/v1/description?graph=&query= ### Parameters #### Query Parameters - **graph** (string) - Required - The graph name. - **query** (string) - Required - The query name. ``` -------------------------------- ### GET {gs}/gsql/v1/data-sources/{name} Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets a data source. ```APIDOC ## GET {gs}/gsql/v1/data-sources/{name} ### Description Gets a data source. ### Method GET ### Endpoint {gs}/gsql/v1/data-sources/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The data source name. ``` -------------------------------- ### getQueryInstallationStatus Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Retrieves the status of a query installation request. ```APIDOC ## GET /gsql/v1/queries/install/{requestId} ### Description Retrieves the status of a query installation request. ### Method GET ### Endpoint /gsql/v1/queries/install/{requestId} ### Parameters #### Path Parameters - **requestId** (string) - Required - The ID of the installation request. ### Request Example ``` GET /gsql/v1/queries/install/12345 ``` ### Response #### Success Response (200) - **status** (string) - The installation status. #### Response Example ``` { "status": "success" } ``` ### Error Handling - Requires TigerGraph version 4.1 or later; otherwise, a `TigerGraphException` with code `0` is raised. ``` -------------------------------- ### installQueries method signature Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Installs one or more GSQL queries. Supports flags like '-single', '-legacy', '-debug', '-cost', '-force'. When wait=True, polls installation status every 10 seconds for up to 360 retries (1 hour), raising TigerGraphException on timeout. Requires TG >= 4.1. ```python def installQueries(self, queries: Union[str, list], flag: Union[str, list] = None, wait: bool = True) -> str ``` -------------------------------- ### PUT {gs}/gsqlserver/gsql/userdefinedfunction Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Installs a user-defined function file using the 3.x path. Used by `installUDF()`. ```APIDOC ## PUT {gs}/gsqlserver/gsql/userdefinedfunction ### Description Installs a user-defined function file using the 3.x path. Used by `installUDF()`. ### Method PUT ### Endpoint `{gs}/gsqlserver/gsql/userdefinedfunction` ### Parameters #### Query Parameters - **filename** (string) - Required - The name of the function file. #### Request Body - **fileContents** (string) - Required - The contents of the file. ### Request Example ``` function body... ``` ### Response #### Success Response (200) - **result** (string) - Installation result. #### Response Example ``` { "result": "Success" } ``` ``` -------------------------------- ### Accuracy metric usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-metrics-splitters.md Example of using the Accuracy metric: create an instance, update it with prediction-label batches, and print the accumulated accuracy. ```python from pyTigerGraph.gds.metrics import Accuracy acc = Accuracy() for preds, labels in eval_batches: acc.update(preds, labels) print("accuracy:", acc.value) ``` -------------------------------- ### getVertices example call Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/vertices.md Example call to retrieve vertices with filtering, sorting, and limit, returning a pandas DataFrame. ```python vertices = conn.getVertices("Person", select="name", where="age>18", limit=10, sort="age", fmt="df") ``` -------------------------------- ### getVertexTypes usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/vertices.md Example call to getVertexTypes showing the returned list of vertex type names. ```python conn.getVertexTypes() # ['Person', 'Account', ...] ``` -------------------------------- ### installUDF method signature Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gsql.md Installs user-defined functions from local file paths or URLs. Returns 0 on success, raises TigerGraphException on server error. ```python def installUDF(self, ExprFunctions: str = "", ExprUtil: str = "") -> None ``` -------------------------------- ### refreshToken usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/authentication.md Shows how to call refreshToken on a connection object to obtain a new token. ```python new_token = conn.refreshToken() ``` -------------------------------- ### VertexLoader usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-dataloaders.md Creates a vertex loader and iterates over batches, printing the shape of each batch, then stops the loader. ```python loader = conn.gds.vertexLoader(attributes=["feat"], num_batches=10, batch_size=512) for batch in loader: # pandas DataFrame batches (vertexLoader) print(batch.shape) stop = loader.stop() ``` -------------------------------- ### Abort all loading jobs example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/loading.md Retrieves all loading jobs and aborts them by extracting their IDs from the 'jobNames' key. This example shows a typical usage pattern for aborting all jobs. ```python jobs = conn.getLoadingJobs() conn.abortLoadingJobs([j["id"] for j in jobs.get("jobNames", [])]) ``` -------------------------------- ### Get Edges DataFrame Example: conn.getEdgesDataFrame call Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/edges.md Example call to getEdgesDataFrame with fmt="df". ```python df = conn.getEdgesDataFrame("Account", "17", edgeType="transfer", fmt="df") ``` -------------------------------- ### Using conn.mcp and start_mcp_server() Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/mcp.md Example of accessing conn.mcp to register the connection as default and calling start_mcp_server() to register an async twin. Catches exceptions when the mcp extra is missing. ```python try: conn.mcp # register self as default connection ok = conn.start_mcp_server() # register an async twin as default except Exception as e: print("MCP unavailable:", e) ``` -------------------------------- ### GET {gs}/gsql/v1/auth/simple Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Verifies JWT authentication. ```APIDOC ## GET {gs}/gsql/v1/auth/simple ### Description Verifies JWT authentication. ### Method GET ### Endpoint {gs}/gsql/v1/auth/simple ``` -------------------------------- ### Upsert example calls Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/vertices.md Example calls for upserting a single vertex and bulk upserting multiple vertices. All upserts POST `{restpp}/graph/{graph}` and read `[0]["accepted_vertices"]`. ```python conn.upsertVertex("Person", "1", {"name": "Thorin", "points": (10, "+")}) conn.upsertVertices("Person", [("2", {"name": "Balin"}), ("3", {"name": "Dwalin"})], atomic=True) ``` -------------------------------- ### Example: check directed edge and get reverse edge Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/edges.md Example usage of isDirected and getReverseEdge for an edge named "transfer". ```python if conn.isDirected("transfer"): print(conn.getReverseEdge("transfer")) ``` -------------------------------- ### AsyncFeaturizerResult Error Handling Example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-featurizer.md Demonstrates how to run an algorithm asynchronously and handle potential exceptions during the wait process. ```python async_res = feat.runAlgorithm("tg_pagerank", params={...}, runAsync=True) try: out = async_res.wait(refresh=2) except TigerGraphException as e: print("algorithm failed:", e.message) ``` -------------------------------- ### GET {gs}/gsql/v1/loading-jobs/abort?graph=&job_id=&pauseJob= Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Aborts loading jobs. ```APIDOC ## GET {gs}/gsql/v1/loading-jobs/abort?graph=&job_id=&pauseJob= ### Description Aborts loading jobs. ### Method GET ### Endpoint {gs}/gsql/v1/loading-jobs/abort?graph=&job_id=&pauseJob= ### Parameters #### Query Parameters - **graph** (string) - Required - The graph name. - **job_id** (string) - Required - The job ID. - **pauseJob** (string) - Required - Pause job flag. ``` -------------------------------- ### runInstalledQuery Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Documentation for the runInstalledQuery method, which executes an installed query on the TigerGraph server. ```APIDOC ## runInstalledQuery ### Description Runs an installed query on the TigerGraph server and returns the results. Supports synchronous and asynchronous execution, with configurable timeout, size limit, and HA replica selection. ### Method GET or POST ### Endpoint `GET/POST {restpp}/query/{graph}/{query}` ### Parameters #### Path Parameters - `graph` (string) - Required - The graph name (part of the endpoint URL). - `query` (string) - Required - The query name (part of the endpoint URL). #### Query Parameters (when using GET) - `params` (string) - Optional - URL-encoded `key=value&...` string of query parameters. #### Request Body (when using POST) - `params` (object) - Optional - JSON object of query parameters. #### Function Parameters - `queryName` (string) - Required - Name of an installed query. - `params` (string or dict) - Optional - `key=value&...` string or dict (encoding rules in types.md). - `timeout` (int) - Optional - Query timeout in milliseconds (GSQL-TIMEOUT). - `sizeLimit` (int) - Optional - Maximum response bytes (RESPONSE-LIMIT). - `usePost` (bool) - Optional - True = POST body, False = GET query-string, None = auto (str params → GET; dict/None → POST). - `runAsync` (bool) - Optional - Detached mode; response becomes the `request_id` (header GSQL-ASYNC: true). - `replica` (int) - Optional - HA replica in [1, replication_factor] (GSQL-REPLICA). - `threadLimit` (int) - Optional - GSQL-THREAD-LIMIT. - `memoryLimit` (int) - Optional - MB limit, TG >= 3.8 (GSQL-QueryLocalMemLimitMB). ### Request Example ```python result = conn.runInstalledQuery("my_query", {"p": (1,), "limit": 10}) request_id = conn.runInstalledQuery("big_query", runAsync=True) ``` ### Response #### Success Response - Returns a list of output elements, or with `runAsync=True` the `request_id` value (resKey="request_id"). #### Response Example ```python result = conn.runInstalledQuery("my_query", {"p": (1,), "limit": 10}) ``` ### Error Handling - Throws `TigerGraphException` when `usePost=True` with string params. - When POST fails with `REST-30000` "'id' is not found in the VERTEX parameter…" the call is transparently retried with GET (deprecated bare-id format, warning emitted). ``` -------------------------------- ### POST {gs}/informant/metrics/get/{category} Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets system metrics. ```APIDOC ## POST {gs}/informant/metrics/get/{category} ### Description Gets system metrics. ### Method POST ### Endpoint {gs}/informant/metrics/get/{category} ### Parameters #### Path Parameters - **category** (string) - Required - The metric category (cpu-memory, diskspace, network, qps). #### Request Body - **TimeRange** (string) - Required - The time range. - **LatestNum** (string) - Required - The latest number. - **HostID** (string) - Required - The host ID. ``` -------------------------------- ### Example: list and instantiate datasets Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/datasets.md Shows two usages: Datasets() prints available datasets and does nothing else; Datasets(name="Cora") downloads the Cora dataset and marks it as ingest_ready=True. ```python Datasets() # prints "Available datasets: …" and nothing else Datasets(name="Cora") # downloads and marks ingest_ready=True ``` -------------------------------- ### Run a GSQL statement with conn.gsql Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gsql.md Example usage of the gsql method to create a vertex type in a graph. ```python out = conn.gsql("USE GRAPH my_graph CREATE VERTEX Person(PRIMARY_ID id STRING, name STRING)") ``` -------------------------------- ### initializeServer, initializeGraphRAG, initializeSupportAI methods Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/ai.md Initializes the NLQS server in either `graphrag` or `supportai` mode. The underlying HTTP call is `POST {nlqs}/{graph}/{server}/initialize`. ```python def initializeServer(self, server="graphrag") def initializeGraphRAG(self) def initializeSupportAI(self) ``` -------------------------------- ### Synchronous parallel query execution with ThreadPoolExecutor Source: https://github.com/tigergraph/pytigergraph/blob/master/README.md Use this snippet to run installed queries in parallel with a thread pool. Each thread gets its own HTTP session and connection pool, so concurrent threads do not block each other. Install pyTigerGraph[fast] to activate the orjson backend for reduced JSON parsing overhead. ```python 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()) ``` -------------------------------- ### getSchema usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/schema.md Calls getSchema and prints the names of all vertex types from the returned schema dictionary. ```python schema = conn.getSchema() print([vt["Name"] for vt in schema["VertexTypes"]]) ``` -------------------------------- ### getInstalledQueries Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Retrieves a list of installed queries, optionally formatted as JSON, DataFrame, or list. ```APIDOC ## GET /query/{graph}/ ### Description Retrieves a list of installed queries, optionally formatted as JSON, DataFrame, or list. ### Method GET ### Endpoint /query/{graph}/ ### Parameters #### Path Parameters - **graph** (string) - Required - The name of the graph. #### Query Parameters - **fmt** (string) - Optional - Output format. Allowed values: `"py"`, `"json"`, `"df"`, `"list"`. Defaults to `"py"`. ### Request Example ``` GET /query/myGraph/?fmt=json ``` ### Response #### Success Response (200) - **queries** (array) - List of installed queries. #### Response Example ``` { "queries": ["query1", "query2"] } ``` ``` -------------------------------- ### POST {nlqs}/{graph}/{server}/initialize Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/ai.md Initializes a GraphRAG or SupportAI server for the specified graph. ```APIDOC ## POST {nlqs}/{graph}/{server}/initialize ### Description Initializes a GraphRAG or SupportAI server for the specified graph. ### Method POST ### Endpoint {nlqs}/{graph}/{server}/initialize ### Parameters #### Path Parameters - **server** (string) - Required - The server type to initialize. Values: "graphrag" or "supportai". ### Request Example None ### Response #### Success Response (200) - **status** (string) - Initialization status. #### Response Example { "status": "initialized" } ``` -------------------------------- ### Inspect edges with getEdgeCountFrom and getEdges Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Inspects edges connected to a starting vertex. getEdgeCountFrom counts edges, optionally filtered by edgeType, and getEdges returns all edges. The example shows counting all edges, counting only 'Likes' edges, and retrieving all edges for person 'Nick'. ```python results = conn.getEdgeCountFrom("Person", "Nick") print("Number of edges connected to person 'Nick'") print(results) print("--------------") # Can also specify edge type and/or target vertex type and target vertex id results = conn.getEdgeCountFrom("Person", "Nick", edgeType="Likes") print("Number of 'rate' edges connected to person 'Nick'") print(results) print("--------------") # Get all edges connected to a starting vertex results = conn.getEdges("Person", "Nick") print("All edges connected to person 'Nick'") print(json.dumps(results, indent=2)) ``` -------------------------------- ### Context manager usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/base.md Uses TigerGraphConnection as a context manager; the session is closed after the block. ```python with TigerGraphConnection(host="http://localhost", graphname="g") as conn: assert conn.echo() == "Hello GSQL" # session closed after block ``` -------------------------------- ### Using start_mcp_server Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/tigergraph-connection.md Calls start_mcp_server on a connection and prints a message if it returns True. ```python if conn.start_mcp_server(): print("MCP server registered with this connection") ``` -------------------------------- ### GET {gs}/gsql/v1/data-sources Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets all data sources. ```APIDOC ## GET {gs}/gsql/v1/data-sources ### Description Gets all data sources. ### Method GET ### Endpoint {gs}/gsql/v1/data-sources ``` -------------------------------- ### GET {gs}/gsql/v1/udt/files/{ExprFunctions|ExprUtil} Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Retrieves a user-defined function file using the 4.x path. Used by `getUDF()`. ```APIDOC ## GET {gs}/gsql/v1/udt/files/{ExprFunctions|ExprUtil} ### Description Retrieves a user-defined function file using the 4.x path. Used by `getUDF()`. ### Method GET ### Endpoint `{gs}/gsql/v1/udt/files/{ExprFunctions|ExprUtil}` ### Parameters #### Path Parameters - **ExprFunctions|ExprUtil** (string) - Required - The file name (either ExprFunctions or ExprUtil). ### Response #### Success Response (200) - **content** (string) - The file content. #### Response Example ``` { "content": "..." } ``` ``` -------------------------------- ### Async HTTP method wrappers Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/async.md Convenience async wrappers for GET, POST, PUT, and DELETE requests. ```python async def _get(...) / async def _post(...) / async def _put(...) / async def _delete(...) ``` -------------------------------- ### GET {gs}/gsql/v1/loading-jobs/status[?graph=&job_id=] Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Gets the status of loading jobs. ```APIDOC ## GET {gs}/gsql/v1/loading-jobs/status[?graph=&job_id=] ### Description Gets the status of loading jobs. ### Method GET ### Endpoint {gs}/gsql/v1/loading-jobs/status[?graph=&job_id=] ### Parameters #### Query Parameters - **graph** (string) - Optional - The graph name. - **job_id** (string) - Optional - The job ID. ``` -------------------------------- ### listAlgorithms Method Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/gds-featurizer.md Method to print available algorithms from the repository manifest. ```python def listAlgorithms(self, category: str = None) -> None ``` -------------------------------- ### POST {gs}/gsql/v1/loading-jobs/run?graph= Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Runs a loading job. ```APIDOC ## POST {gs}/gsql/v1/loading-jobs/run?graph= ### Description Runs a loading job. ### Method POST ### Endpoint {gs}/gsql/v1/loading-jobs/run?graph= ### Parameters #### Query Parameters - **graph** (string) - Required - The graph name. #### Request Body - **JSON body** (object) - Required - The JSON body from _prep_run_loading_job. ``` -------------------------------- ### Get version info with getVersion and getVer Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Prints version information for all components using getVersion, and then prints the version for a specific component (e.g., 'gle') using getVer. ```python print(json.dumps(conn.getVersion(), indent=2)) print("-----------------") print(json.dumps(conn.getVer("gle"), indent=2)) ``` -------------------------------- ### GET {restpp}/requesttoken Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Legacy token endpoint for retrieving a token using GET method. ```APIDOC ## GET {restpp}/requesttoken ### Description Retrieves a token for authentication. Used by `getToken()`, `refreshToken()`, and `deleteToken()` for TigerGraph versions before 3.5 or when using the GET-method path. ### Method GET ### Endpoint `{restpp}/requesttoken` ### Parameters #### Query Parameters - **secret** (string) - Required - The secret used for authentication. - **lifetime** (integer) - Optional - Token lifetime. - **token** (string) - Optional - Existing token to refresh or delete. ### Response #### Success Response (200) - **token** (string) - The requested token. #### Response Example { "token": "string" } ``` -------------------------------- ### Find All Paths with conn.allPaths() Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Gets all paths between selected vertices. Requires an upper limit on edge traversals due to many possible combinations. ```python results = conn.allPaths([("Person", "Dan")], [("Person", "Ben")], 4) print(json.dumps(results, indent=2)) ``` -------------------------------- ### Upsert Edge Example: conn.upsertEdge call Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/edges.md Example call to upsertEdge with attributes as (value, operator) tuples. ```python conn.upsertEdge("Account", "17", "transfer", "Account", "42", {"amount": (500, "+"), "ts": 1234567890}) ``` -------------------------------- ### Query metadata methods signatures Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md These methods list query names, get query info, and check query semantics. They require TG >= 4.0 and use the endpoints GET /gsql/v1/queries, GET /queries/info, and POST /gsql/v1/internal/check/query respectively. ```python def listQueryNames(self) -> list def getQueryInfo(self, queryName: str = None, status: str = None) -> dict def checkQuerySemantic(self, queryCode: str) -> dict ``` -------------------------------- ### echo Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/utilities.md Pings the database to verify connectivity. Returns the string 'Hello GSQL' when successful. ```APIDOC ## echo ### Description Pings the database to verify connectivity. Returns the string "Hello GSQL" when successful. ### Method GET or POST ### Endpoint `GET {restpp}/echo/` or `POST {restpp}/echo/` ### Parameters #### Query Parameters - **usePost** (bool) - Optional - Use `POST /echo/` instead of `GET /echo/`. ### Request Example ```python conn = TigerGraphConnection(host="http://localhost", graphname="g") assert conn.echo() == "Hello GSQL" ``` ### Response #### Success Response (200) - Returns: `"Hello GSQL"` (as string) when everything works. #### Response Example ``` "Hello GSQL" ``` ``` -------------------------------- ### POST {gs}/gsql/v1/sample-data Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Previews sample data. ```APIDOC ## POST {gs}/gsql/v1/sample-data ### Description Previews sample data. ### Method POST ### Endpoint {gs}/gsql/v1/sample-data ### Parameters #### Request Body - **JSON body** (object) - Required - The sample data request body. ``` -------------------------------- ### start_mcp_server method definition Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/tigergraph-connection.md Defines the sync-only start_mcp_server method. It creates an AsyncTigerGraphConnection from the current connection's parameters and registers it as the MCP default connection. Returns True on success, throws Exception if the mcp extra is not installed. ```python def start_mcp_server(self): ``` -------------------------------- ### runInterpretedQuery usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/queries.md Example call to runInterpretedQuery with an INTERPRET QUERY statement and a parameter dictionary. The query prints the value of n. ```python res = conn.runInterpretedQuery( "INTERPRET QUERY (INT n) FOR GRAPH $graphname { PRINT n; }", {"n": 5}) ``` -------------------------------- ### Install pyTigerGraph via conda Source: https://github.com/tigergraph/pytigergraph/blob/master/README.md Installs the base pyTigerGraph package from the tigergraph conda channel. Use this command if you manage packages with conda. ```sh conda install -c tigergraph pytigergraph ``` -------------------------------- ### Example: delete all Person vertices permanently Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/vertices.md Example call to delVerticesByType that deletes all Person vertices permanently with ack set to "all". ```python deleted = conn.delVerticesByType("Person", permanent=True, ack="all") ``` -------------------------------- ### Add vertex and edge types and commit changes (short example) Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/schema-oo.md Shows a minimal workflow: create a Graph, add a Paper vertex and CITES edge, then commit changes. ```python g = Graph(conn) g.add_vertex_type(Paper) g.add_edge_type(CITES) g.commit_changes() ``` -------------------------------- ### POST {gs}/gsql/v1/loading-jobs?graph= Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Creates a loading job. ```APIDOC ## POST {gs}/gsql/v1/loading-jobs?graph= ### Description Creates a loading job. ### Method POST ### Endpoint {gs}/gsql/v1/loading-jobs?graph= ### Parameters #### Query Parameters - **graph** (string) - Required - The graph name. #### Request Body - **GSQL DDL text** (string) - Required - The GSQL DDL text. ``` -------------------------------- ### POST {gs}/gsql/v1/data-sources[?graph=] Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/endpoints.md Creates a data source. ```APIDOC ## POST {gs}/gsql/v1/data-sources[?graph=] ### Description Creates a data source. ### Method POST ### Endpoint {gs}/gsql/v1/data-sources[?graph=] ### Parameters #### Query Parameters - **graph** (string) - Optional - The graph name. #### Request Body - **name** (string) - Required - The data source name. - **config** (object) - Required - The data source configuration. ``` -------------------------------- ### Async version helper method signatures Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/async.md Lists the async version helper methods: getVersion, getVer, customizeHeader, and _version_greater_than_4_0. The latter caches its result until the connection object is recreated. ```python async def getVersion(self, raw: bool = False) -> Union[str, list] async def getVer(self, component: str = "product", full: bool = False) -> str async def customizeHeader(self, timeout: int = 16_000, responseSize: int = 3.2e+7, threadLimit: int = None, memoryLimit: int = None) async def _version_greater_than_4_0(self) -> bool ``` -------------------------------- ### Constructor Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/base.md Initializes a connection to a TigerGraph instance with configurable host, graph name, credentials, ports, and authentication tokens. ```APIDOC ## Constructor ### Description Initializes a connection to a TigerGraph instance with configurable host, graph name, credentials, ports, and authentication tokens. ### Method Constructor ### Endpoint `__init__` ### Parameters - **host** (str) - Optional - Default: `"http://127.0.0.1"` - The base URL of the TigerGraph instance. - **graphname** (str) - Optional - Default: `"MyGraph"` (deprecated, warns) - The name of the graph to use. - **gsqlSecret** (str) - Optional - Default: `""` - The GSQL secret for authentication. - **username** (str) - Optional - Default: `"tigergraph"` - The username for authentication. - **password** (str) - Optional - Default: `"tigergraph"` - The password for authentication. - **tgCloud** (bool) - Optional - Default: `False` - Whether the instance is on TigerGraph Cloud. - **restppPort** (Union[int, str]) - Optional - Default: `None` - The RESTPP port. - **gsPort** (Union[int, str]) - Optional - Default: `None` - The GSQL port. - **gsqlVersion** (str) - Optional - Default: `""` - The GSQL version. - **version** (str) - Optional - Default: `""` - The database version (deprecated). - **apiToken** (str) - Optional - Default: `""` - The API token for authentication. - **useCert** (bool) - Optional - Default: `None` - Whether to use SSL certificates. - **certPath** (str) - Optional - Default: `None` - The path to the SSL certificate. - **debug** (bool) - Optional - Default: `None` - Whether to enable debug mode. - **sslPort** (Union[int, str]) - Optional - Default: `"443"` - The SSL port. - **gcp** (bool) - Optional - Default: `False` - Whether the instance is on GCP. - **jwtToken** (str) - Optional - Default: `""` - The JWT token for authentication. ### Request Example ```python conn = pyTigerGraph(host="http://127.0.0.1", graphname="MyGraph", username="tigergraph", password="tigergraph") ``` ### Response No return value. Sets instance attributes as described in the public instance state table. ``` -------------------------------- ### delEdges usage example Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/edges.md Example call to delEdges that deletes edges of type 'transfer' from vertex '17' of type 'Account'. The method returns a dictionary with the deleted count. ```python deleted = conn.delEdges("Account", "17", edgeType="transfer") ``` -------------------------------- ### Async connection usage example from README Source: https://github.com/tigergraph/pytigergraph/blob/master/_autodocs/api-reference/async.md Demonstrates using AsyncTigerGraphConnection as an async context manager, running a query, and performing high-concurrency fan-out with asyncio.gather. ```python 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) # high-concurrency fan-out: tasks = [conn.runInstalledQuery("q", {"p": v}) for v in values] results = await asyncio.gather(*tasks) asyncio.run(main()) ``` -------------------------------- ### Get all UDTs and a specific UDT with getUDTs and getUDT Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Prints all user-defined types (UDTs) and then attempts to get a UDT by name. Since there are no UDTs in the current graph, both commands should return empty. ```python print(conn.getUDTs()) print(conn.getUDT(udtName="")) ``` -------------------------------- ### Import pyTigerGraph library Source: https://github.com/tigergraph/pytigergraph/blob/master/examples/pyTigergraph_101.ipynb Initial import of the pyTigerGraph package. ```python import pyTigerGraph as tg ```