Class TigerGraph

class TigerGraph ( host: str = 'http://localhost', graph: str = None,
    username: str= None, password: str = None, rest_port: str = '9000',
    gs_port: str = '14240', token_auth: bool = True, max_retries: int = 3)

Connection to the TigerGraph database. This class represents the graph stored in the database. It stores the necessary information to communicate with the TigerGraph database.

It can read username and password from environment variables TGUSERNAME and TGPASSWORD. Hence, we recommend storing those credentials in the environment variables or in a .env file instead of hardcoding them in code. However, if you do provide username and password to this class constructor, the environment variables will be ignored.

For the first time you initialize this class on a graph in TigerGraph, the initialization might take a minute as it installs the corresponding queries to the database and optimizes them. However, the query installation only needs to be done once, so it will take no time when you initialize the class on the same TG graph again. For the connection to work, the Graph Data Processing Service (GDPS) has to be running on the TigerGraph server.


host : str, optional

Address of the server. Defaults to http://localhost.

graph : str, optional

Name of the graph. Defaults to None.

username : str, optional

Username. Defaults to None.

password : str, optional

Password for the user. Defaults to None.

rest_port : str, optional

Port for the REST endpoint. Defaults to "9000".

gs_port : str, optional

Port for GraphStudio. Defaults to "14240".

token_auth : bool, optional

Whether to use token authentication. Defaults to True.

max_retries : int, optional

Maximal number of retries when a request fails. Defaults to 3.



def info (self) ‑> None

Return information about graph schema and other metadata.


def number_of_edges
(self, edge_type: str = None) ‑> int

Get number of edges (by type).


edge_type : str, optional

Get number of edges for a specific type. If None, all types of edges will be counted. Defaults to None.

Return value


Number of edges.


def number_of_vertices
(self, vertex_type: str = None, filter_by: str = None) ‑> int


vertex_type : str, optional

Get number of vertices for a specific type. If None, all types of vertices will be counted. Defaults to None.

filter_by : str, optional

A boolean attribute of vertices. Only vertices with this attribute being true will be counted. Defaults to None.

Return value


Number of vertices