CTRL + K
Tooling
Client

Client

The client library provides a programmatic interface to the various REST endpoints on the server. With it you can build rich tooling on top of your existing installation of Grai.

Installation

Install dbt Grai package with pip

pip install grai-client

Usage

Most interactions with the server will start with a client instance like so

from grai_client.endpoints.v1.client import ClientV1
 
client = ClientV1(host='api.grai.io', port='443', insecure=True, username='[your_username]', password='[your_password]')

Now that you have an instance of a client and have authenticated the client with the server you can begin playing with the library. It offers the start REST verb interface of GET, POST, DELETE, and PATCH. e.g.

# Gets a list of nodes in your lineage graph
client.get('nodes')

Each verb operation can take a variety of arguments like node, edge, and workspace but is primarily designed to work with structured objects from the grai_schemas library. For example, if you wanted to create a new node in your lineage you could do the following

from grai_schemas.v1 import NodeV1
 
my_node = NodeV1.from_spec({
    'name': 'node01',
    'namespace': 'default',
    'is_active': True,
    'data_source': 'dbt',
    'display_name': 'A Super Cool Node',
})
 
client.post(my_node)