### Create Multiple Nodes using C# (LiteGraph) Source: https://litegraph.readme.io/reference/create-4 Provides a C# example for creating multiple nodes using the LiteGraph client. The `CreateMany` method on the `Node` repository is demonstrated, which takes tenant and graph GUIDs along with a list of `Node` objects. The example initializes a SqliteGraphRepository. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; using System.Collections.Specialized; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); List response = liteGraph.Node.CreateMany( Guid.Parse(""), Guid.Parse(""), new List() { new Node() { Name = "My test node", Labels = new List { "test", "hello" }, Tags = new NameValueCollection { { "Foo", "Bar" }, { "Bar", "Baz" } }, Data = new { Hello = "World", Foo = new { Data = "hello" } }, } }); ``` -------------------------------- ### Create Multiple Tags with LiteGraph Client (C#) Source: https://litegraph.readme.io/reference/create-7 Illustrates how to create multiple tags using the LiteGraph client library in C#. This example initializes a repository and then calls the `CreateMany` method with a list of `TagMetadata`. It requires specifying tenant and graph GUIDs. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); List response = liteGraph.Tag.CreateMany(Guid.Parse(""), new List() { new TagMetadata() { GraphGUID = Guid.Parse(""), NodeGUID = Guid.Parse(""), EdgeGUID = Guid.Parse(""), Key = "mykey", Value = "myvalue" } }); ``` -------------------------------- ### Enumerate Graphs with LiteGraph SDK (Python) Source: https://litegraph.readme.io/reference/read-and-enumeration-2 Provides an example of enumerating graphs using the LiteGraph SDK in Python. It includes configuring the SDK with endpoint, tenant GUID, and access key, then defining and calling a function to enumerate graphs. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def enumerate_graph(): graphs = litegraph.Graph.enumerate() print(graphs) enumerate_graph() ``` -------------------------------- ### Retrieve All Node Edges (cURL) Source: https://litegraph.readme.io/reference/get-node-edges This example demonstrates how to retrieve all edges connected to a specific node using a cURL command. It requires the tenant GUID, graph GUID, and node GUID. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/nodes/00000000-0000-0000-0000-000000000000/edges' \ --header 'Authorization: ••••••' ``` -------------------------------- ### Quick Start LiteGraph Server Source: https://litegraph.readme.io/reference/running-server-from-source Runs the LiteGraph Server using the compiled DLL. This command initiates the server and its default processes, including creating configuration and database files if they don't exist. ```bash dotnet LiteGraph.Server.dll ``` -------------------------------- ### Create Tenant using C# (LiteGraph SDK) Source: https://litegraph.readme.io/reference/create Provides an example of creating a tenant using the LiteGraph C# SDK. It demonstrates initializing the LiteGraph client with a repository and calling the Tenant.Create method with tenant metadata. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); TenantMetadata response = liteGraph.Tenant.Create(new TenantMetadata { Name = "Another tenant", Active = true, }); ``` -------------------------------- ### Get Node Parents using LiteGraph Client (C#) Source: https://litegraph.readme.io/reference/get-node-parents This C# example demonstrates fetching parent nodes using the LiteGraph client and an SQLite repository. It shows the initialization of the client and the call to the `ReadParents` method with necessary GUIDs and enumeration order. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response = liteGraph.Node.ReadParents(Guid.Parse(""), Guid.Parse(""), Guid.Parse(""), EnumerationOrderEnum.CreatedDescending); ``` -------------------------------- ### Create User using LiteGraph SDK (JavaScript) Source: https://litegraph.readme.io/reference/create-1 Demonstrates creating a user with the LiteGraph SDK in JavaScript. It initializes the SDK with endpoint, tenant GUID, and access key, then calls the User.create method. Error handling is included. ```javascript import { LiteGraphSdk } from "litegraphdb"; var api = new LiteGraphSdk( "http://localhost:8701", "", "*******" ); const createUser = async () => { try { const data = await api.User.create({ FirstName: "Another", LastName: "User", Email: "another@user.com", Password: "pass****", Active: true, }); console.log(data, "check data"); } catch (err) { console.log("err:", JSON.stringify(err)); } }; ``` -------------------------------- ### Get Node Neighbors via Python (litegraph) Source: https://litegraph.readme.io/reference/get-node-neighbors This Python example demonstrates retrieving neighbor nodes using the litegraph library. It configures the SDK with connection details and then calls the neighbors function for a specified graph and node GUID, printing the output. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def get_neighbors_of_node(): neighbors = litegraph.RouteNodes.neighbors( graph_guid="1cbb2bc5-a990-49a8-9975-e0b1c34d1011", node_guid="00000000-0000-0000-0000-000000000000" ) print(neighbors) get_neighbors_of_node() ``` -------------------------------- ### Create Graph using LiteGraph (Python) Source: https://litegraph.readme.io/reference/create-2 Illustrates creating a graph with the LiteGraph library in Python. This example demonstrates the usage of the `litegraph.configure` function to set up the SDK and the `litegraph.Graph.create` method for graph instantiation. It provides a concise way to manage graph creation within Python applications. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def create_graph(): graph = litegraph.Graph.create(name="New Graph") print(graph) create_graph() ``` -------------------------------- ### Get Edges To Node via cURL Source: https://litegraph.readme.io/reference/get-edges-to-node This cURL command demonstrates how to retrieve all incoming edges to a specific node. It requires the tenant GUID, graph GUID, and node GUID as path parameters. The Authorization header should contain the access token. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/nodes/64058009-3ff7-40e0-b6d8-02252137fb55/edges/to' \ --header 'Authorization: ••••••' ``` -------------------------------- ### Retrieve Outgoing Edges from Node (C#) Source: https://litegraph.readme.io/reference/get-edges-from-node This C# example demonstrates fetching outgoing edges from a node using the LiteGraph client. It initializes a LiteGraphClient with an SQLite repository and then calls the ReadEdgesFromNode method, passing tenant, graph, and node GUIDs. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response = liteGraph.Edge.ReadEdgesFromNode(Guid.Parse(""), Guid.Parse(""), Guid.Parse("")); ``` -------------------------------- ### Create Node (SDK Examples) Source: https://litegraph.readme.io/reference/create-4 Examples of creating nodes using various SDKs, demonstrating different programming languages and their usage with the LiteGraph API. ```APIDOC ## SDK Examples for Node Creation ### JavaScript Example ```javascript import { LiteGraphSdk } from "litegraphdb"; var api = new LiteGraphSdk( "http://localhost:8701", "", "*******" ); const createNode = async () => { // Node object to create const node = { GUID: "", GraphGUID: "", Name: "Sample Node", Data: { key1: "value2", }, CreatedUtc: "2024-10-19T14:35:20.351Z", }; try { const createdNode = await api.Node.create(node); console.log(createdNode, "Node created successfully"); } catch (err) { console.log("err: ", err); console.log("Error creating node:", JSON.stringify(err)); } }; ``` ### Python Example ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", graph_guid="Graph-Guid", access_key="******", ) def create_node(): node = litegraph.Node.create(name="Sample Node",data={"type": "service"}) print(node) create_node() ``` ### C# Example ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; using System.Collections.Specialized; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); Node response = liteGraph.Node.Create(new Node { Name = "My test node", Labels = new List { "test", "hello" }, Tags = new NameValueCollection { { "Foo", "Bar" }, { "Bar", "Baz" } }, Data = new { Hello = "World", Foo = new { Data = "hello" } }, Vectors = new List { new VectorMetadata { Model = "all-MiniLM-L6-v2", Dimensionality = 384, Content = "test", Vectors = new List { 0.1f, 0.2f, 0.3f } } } }); ``` ``` -------------------------------- ### Read Multiple Credentials by GUIDs (curl) Source: https://litegraph.readme.io/reference/read-and-enumeration-4 Demonstrates fetching multiple credentials simultaneously by providing a comma-separated list of GUIDs in the query parameters. This uses the `guids` parameter in the GET request. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/credentials?guids=00000000-0000-0000-0000-000000000000%2C00000000-0000-0000-0000-000000000001' \ --header 'Authorization: ••••••' ``` -------------------------------- ### Clone LiteGraph Repository Source: https://litegraph.readme.io/reference/running-server-from-source Clones the LiteGraph repository from GitHub and navigates into the source directory. This is the first step to building the server from source. ```bash git clone https://github.com/jchristn/LiteGraph.git cd LiteGraph/src ``` -------------------------------- ### Create Tenant using Python (LiteGraph SDK) Source: https://litegraph.readme.io/reference/create Illustrates tenant creation using the LiteGraph Python SDK. The code configures the SDK with endpoint and authentication details, then calls the Tenant.create function. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def create_tenant(): tenant = litegraph.Tenant.create(name="Another Tenant") print(tenant) create_tenant() ``` -------------------------------- ### Read Multiple Credentials by GUIDs (C#) Source: https://litegraph.readme.io/reference/read-and-enumeration-4 Provides a C# example for reading multiple credentials by their GUIDs using the LiteGraph client. It initializes the repository and calls `Credential.ReadByGuids` with a list of GUIDs. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response = liteGraph.Credential.ReadByGuids(Guid.Parse(""), new List() { Guid.Parse(""), Guid.Parse(""), }); ``` -------------------------------- ### GET /v1.0/token Source: https://litegraph.readme.io/reference/generate-authentication-token Generates an authentication token using email, password, and tenant GUID. The credentials and tenant GUID are passed as request headers. ```APIDOC ## GET /v1.0/token ### Description Generates an authentication token using email, password, and tenant GUID. The credentials and tenant GUID are passed as request headers. ### Method GET ### Endpoint /v1.0/token ### Parameters #### Header Parameters - **x-email** (string) - Required - The email address of the user. - **x-password** (string) - Required - The password of the user. - **x-tenant-guid** (string) - Required - The GUID of the tenant. ### Request Example ```curl curl --location --request GET 'http://localhost:8701/v1.0/token' \ --header 'x-email: default@user.com' \ --header 'x-password: password' \ --header 'x-tenant-guid: 00000000-0000-0000-0000-000000000000' ``` ### Response #### Success Response (200) - **TimestampUtc** (string) - The UTC timestamp when the token was generated. - **ExpirationUtc** (string) - The UTC timestamp when the token will expire. - **IsExpired** (boolean) - Indicates if the token is currently expired. - **TenantGUID** (string) - The GUID of the tenant associated with the token. - **UserGUID** (string) - The GUID of the user associated with the token. - **Token** (string) - The generated authentication token. - **Valid** (boolean) - Indicates if the token is valid. #### Response Example ```json { "TimestampUtc": "2025-09-09T10:27:10.892667Z", "ExpirationUtc": "2025-09-10T10:27:10.892667Z", "IsExpired": false, "TenantGUID": "00000000-0000-0000-0000-000000000000", "UserGUID": "2bfe8b6e-53ac-4aa6-80fc-905ad154049f", "Token": "*******", "Valid": true } ``` ``` -------------------------------- ### Build LiteGraph Server Project Source: https://litegraph.readme.io/reference/running-server-from-source Builds the LiteGraph Server project using the .NET CLI. Supports both standard and release builds with optimizations. ```bash dotnet build LiteGraph.Server/LiteGraph.Server.csproj ``` ```bash dotnet build LiteGraph.Server/LiteGraph.Server.csproj -c Release ``` -------------------------------- ### Retrieve Multiple Edges by GUIDs (C#) Source: https://litegraph.readme.io/reference/read-and-enumeration-6 Shows a C# example for fetching multiple edges by their GUIDs using the LiteGraph client. The `ReadByGuids` method accepts a list of GUIDs to retrieve specific edges. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response = liteGraph.Edge.ReadByGuids(Guid.Parse(""), new List() { Guid.Parse("edge-guid-1"), Guid.Parse("edge-guid-2") }); ``` -------------------------------- ### Basic LiteGraph Operations in C# Source: https://litegraph.readme.io/reference/index Demonstrates fundamental operations like creating tenants, graphs, nodes, and edges, as well as performing a Depth-First Search for routes using the LiteGraph C# client. Requires the LiteGraph library and a SQLite repository. ```csharp using LiteGraph; LiteGraphClient graph = new LiteGraphClient(new SqliteRepository("litegraph.db")); graph.InitializeRepository(); // Create a tenant TenantMetadata tenant = graph.CreateTenant(new TenantMetadata { Name = "My tenant" }); // Create a graph Graph graph = graph.CreateGraph(new Graph { TenantGUID = tenant.GUID, Name = "This is my graph!" }); // Create nodes Node node1 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = "node1" }); Node node2 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = "node2" }); Node node3 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = "node3" }); // Create edges Edge edge1 = graph.CreateEdge(new Edge { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, From = node1.GUID, To = node2.GUID, Name = "Node 1 to node 2" }); Edge edge2 = graph.CreateEdge(new Edge { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, From = node2.GUID, To = node3.GUID, Name = "Node 2 to node 3" }); // Find routes foreach (RouteDetail route in graph.GetRoutes( SearchTypeEnum.DepthFirstSearch, tenant.GUID, graph.GUID, node1.GUID, node2.GUID)) { Console.WriteLine(...); } ``` -------------------------------- ### Check Graph Existence with LiteGraphClient (C#) Source: https://litegraph.readme.io/reference/exist-2 Utilize the LiteGraphClient in C# to check for graph existence by GUID. This example initializes a LiteGraphClient with an SQLite repository and then uses the `ExistsByGuid` method, requiring both tenant and graph GUIDs to be parsed as Guid objects. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); bool exists = liteGraph.Graph.ExistsByGuid(Guid.Parse("tenant-guid"), Guid.Parse("graph-guid")); ``` -------------------------------- ### Search and Enumerate Labels using LiteGraph SDK (C#) Source: https://litegraph.readme.io/reference/read-and-enumeration-7 Provides an example of how to enumerate labels using the LiteGraphClient in C#. It demonstrates setting up the repository, initializing the client, and making an enumeration request with various parameters. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); EnumerationResult response = liteGraph.Label.Enumerate(new EnumerationRequest() { Ordering = EnumerationOrderEnum.CreatedDescending, IncludeData = true, IncludeSubordinates = true, MaxResults = 5, Skip = 0, ContinuationToken = null, Labels = new List(), Tags = null, Expr = null }); ``` -------------------------------- ### Create User using LiteGraph Library (Python) Source: https://litegraph.readme.io/reference/create-1 Shows how to create a user using the litegraph Python library. It configures the SDK with endpoint, tenant GUID, and access key, then uses the User.create function. The created user object is printed. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def create_user(): user = litegraph.User.create(email="another@user.com", password="pass****", first_name="Another", last_name="User") print(user) create_user() ``` -------------------------------- ### Read Individual Credential (C#) Source: https://litegraph.readme.io/reference/read-and-enumeration-4 Provides a C# example for reading a credential by GUID using the LiteGraph client. It initializes a SQLite repository and then calls `Credential.ReadByGuid` with tenant and credential GUIDs. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); Credential response = liteGraph.Credential.ReadByGuid(Guid.Parse(""), Guid.Parse("")); ``` -------------------------------- ### Create Graph using LiteGraph SDK (C#) Source: https://litegraph.readme.io/reference/create-2 Provides a C# example for creating a graph using the LiteGraph client. This code snippet shows how to initialize the `LiteGraphClient` with a repository and then use the `Graph.Create` method to define and create a graph with various properties like name, labels, tags, data, and vectors. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; using System.Collections.Specialized; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); Graph response = liteGraph.Graph.Create(new Graph { Name = "My graph", Labels = new List { "test" }, Tags = new NameValueCollection { { "Foo", "Bar" } }, Data = new Dictionary { ["Key"] = "Value" }, Vectors = new List { new VectorMetadata { Model = "all-MiniLM-L6-v2", Dimensionality = 384, Content = "test", Vectors = new List{ 0.1f, 0.2f, 0.3f } } } }); ``` -------------------------------- ### Retrieve Edges Between Nodes using cURL Source: https://litegraph.readme.io/reference/get-edges-between-nodes This snippet demonstrates how to fetch all edges directly connecting two specific nodes using a cURL command. It requires the tenant GUID, graph GUID, and the GUIDs of the source and destination nodes. The request includes an Authorization header for authentication. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/edges/between?from=00000000-0000-0000-0000-000000000000&to=00000000-0000-0000-0000-000000000001' \ --header 'Authorization: Bearer litegraphadmin' ``` -------------------------------- ### Running LiteGraph with Provided Shell Scripts Source: https://litegraph.readme.io/reference/running-server-from-docker These snippets demonstrate how to use provided shell scripts (`run.sh` for Linux/macOS and `run.bat` for Windows) to start the LiteGraph container, optionally specifying an image tag. ```bash # Run with default tag (v3.1.0) ./run.sh # Run with specific tag IMG_TAG=v4.1.0 ./run.sh ``` ```batch REM Run with specific tag run.bat v4.1.0 ``` -------------------------------- ### Get Node Children via cURL Source: https://litegraph.readme.io/reference/get-node-children Example of retrieving child nodes of a specific parent node using cURL. This demonstrates the HTTP endpoint and expected parameters for making the request. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/nodes/00000000-0000-0000-0000-000000000000/children' \ --header 'Authorization: ••••••' ``` -------------------------------- ### Create Graph using LiteGraph SDK (JavaScript) Source: https://litegraph.readme.io/reference/create-2 Shows how to create a graph using the LiteGraph SDK in JavaScript. This approach leverages the SDK's methods for interacting with the LiteGraph API, simplifying the process of graph creation. It requires initializing the SDK with endpoint, tenant GUID, and access key. ```javascript import { LiteGraphSdk } from "litegraphdb"; var api = new LiteGraphSdk( "http://localhost:8701/", "", "*******" ); const createGraph = async () => { // Graph object to create try { const createdGraph = await api.Graph.create({ Name: "New Graph" }); console.log(createdGraph, "Graph created successfully"); } catch (err) { console.log("err: ", err); console.log("Error creating graph:", JSON.stringify(err)); } }; ``` -------------------------------- ### Get Node Neighbors via cURL Source: https://litegraph.readme.io/reference/get-node-neighbors This snippet demonstrates how to retrieve all neighbor nodes connected to a specific node using a cURL command. It targets the /neighbors endpoint with required tenant, graph, and node GUIDs. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/nodes/00000000-0000-0000-0000-000000000000/neighbors' \ --header 'Authorization: ••••••' ``` -------------------------------- ### Read Individual Node by GUID (C#) Source: https://litegraph.readme.io/reference/read-and-enumeration-5 Illustrates reading a node by its GUID in C# using the LiteGraph client. This example initializes a SqliteGraphRepository and demonstrates how to call the ReadByGuid method, optionally including data and subordinates. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); Node response = liteGraph.Node.ReadByGuid( Guid.Parse(""), Guid.Parse(""), Guid.Parse(""), includeData: true, includeSubordinates: true); ``` -------------------------------- ### Create Multiple Tags using LiteGraph Library (Python) Source: https://litegraph.readme.io/reference/create-7 Provides a Python example for creating multiple tags using the litegraph library. This function demonstrates how to define and create tags in bulk, printing the results. It requires configuring the SDK with endpoint, tenant GUID, and access key. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def create_multiple_tag(): tags = litegraph.Tag.create_multiple(tags=[ { "Key": "Test Key 1", "Value": "Test Value 1" }, { "Key": "Test Key 2", "Value": "Test Value 2" } ]) print(tags) create_multiple_tag() ``` -------------------------------- ### Delete Single Label using LiteGraph Client (C#) Source: https://litegraph.readme.io/reference/delete-5 Deletes a label by its GUID using the LiteGraph client in C#. This example initializes the repository with SQLite and then calls the DeleteByGuid method with tenant and label GUIDs. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); liteGraph.Label.DeleteByGuid(Guid.Parse(""), Guid.Parse("")); ``` -------------------------------- ### Create Tenant using JavaScript (LiteGraph SDK) Source: https://litegraph.readme.io/reference/create Shows how to create a new tenant programmatically using the LiteGraph JavaScript SDK. This involves initializing the SDK with connection details and calling the Tenant.create method. ```javascript import { LiteGraphSdk } from "litegraphdb"; var api = new LiteGraphSdk( "http://localhost:8701/", "", "*******" ); const createTenant = async () => { try { const created = await api.Tenant.create({ Name: "Another tenant", Active: true, }); console.log(created); } catch (err) { console.log("err:", JSON.stringify(err)); } }; ``` -------------------------------- ### Get Node Parents using cURL Source: https://litegraph.readme.io/reference/get-node-parents This snippet demonstrates how to retrieve all parent nodes connected to a specific child node using a cURL command. It targets the '/parents' endpoint for a given tenant, graph, and node GUID. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/nodes/00000000-0000-0000-0000-000000000000/parents' \ --header 'Authorization: ••••••' ``` -------------------------------- ### LiteGraph Configuration File Example Source: https://litegraph.readme.io/reference/running-server-from-docker This JSON object represents a typical `litegraph.json` configuration file. It specifies settings for logging, the REST API hostname and port, and LiteGraph core parameters like the admin token and database file. ```json { "Logging": { "ConsoleLogging": true, "LogDirectory": "./logs/", "LogFilename": "litegraph.log" }, "Rest": { "Hostname": "*", "Port": 8701 }, "LiteGraph": { "AdminBearerToken": "litegraphadmin", "GraphRepositoryFilename": "litegraph.db", "InMemory": false } } ``` -------------------------------- ### Get Routes using LiteGraph Client in C# Source: https://litegraph.readme.io/reference/get-routes This C# code snippet shows how to use the LiteGraph client to read routes between nodes. It initializes a `LiteGraphClient` with a repository and then calls `ReadRoutes` specifying the search type and node GUIDs. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response= liteGraph.Node.ReadRoutes( SearchTypeEnum.DepthFirstSearch, Guid.Parse(""), Guid.Parse("graph-guid"), Guid.Parse("from-node-guid"), Guid.Parse("to-node-guid")); ``` -------------------------------- ### Create Credential using LiteGraph Python SDK Source: https://litegraph.readme.io/reference/create-3 Provides a Python example for creating user credentials using the LiteGraph library. It configures the SDK with endpoint and tenant details and then calls the Credential.create function. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def create_credential(): credential = litegraph.Credential.create(user_guid="user-guid", name="New credential", bearer_token="foobar") print(credential) create_credential() ``` -------------------------------- ### Get Node Neighbors via C# (LiteGraph) Source: https://litegraph.readme.io/reference/get-node-neighbors This C# code snippet illustrates how to fetch neighbor nodes using the LiteGraph client and a SqliteGraphRepository. It initializes the client, then uses the ReadNeighbors method with specified GUIDs and an enumeration order. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response = liteGraph.Node.ReadNeighbors( Guid.Parse(""), Guid.Parse(""), Guid.Parse(""), EnumerationOrderEnum.CreatedDescending); ``` -------------------------------- ### Starting and Stopping LiteGraph with Docker Compose Source: https://litegraph.readme.io/reference/running-server-from-docker These commands show how to initiate and terminate the LiteGraph service using Docker Compose, both via provided scripts (`compose-up.sh`, `compose-down.sh`, `compose-up.bat`, `compose-down.bat`) and directly using the `docker compose` CLI. ```bash # Linux/macOS: ./compose-up.sh # Windows: compose-up.bat # Manual: docker compose -f compose.yaml up -d ``` ```bash # Linux/macOS: ./compose-down.sh # Windows: compose-down.bat # Manual: docker compose -f compose.yaml down ``` -------------------------------- ### GET /v1.0/tenants/{tenant-id}/graphs?guids=, Source: https://litegraph.readme.io/reference/read-and-enumeration-2 Retrieves multiple specific graphs by their GUIDs. Graphs are specified as a comma-separated list in the `guids` query parameter. Supports additional data inclusion via query parameters. ```APIDOC ## GET /v1.0/tenants/{tenant-id}/graphs?guids=, ### Description Retrieve multiple specific graphs by providing their GUIDs as query parameters using `GET: /v1.0/tenants/{tenant-id}/graphs?guids=,`. This endpoint allows you to fetch several graphs in a single request by specifying comma-separated GUIDs in the URL query string. To include additional information in the response, such as custom data fields and subordinate (child) graphs, use the `incldata` and `inclsub` query parameters in your request. * `incldata=true` will include the `Data` property for each graph in the response. * `inclsub=true` will include subordinate (child) graphs in the response. ### Method GET ### Endpoint `/v1.0/tenants/{tenant-id}/graphs` ### Parameters #### Path Parameters - **tenant-id** (string) - Required - The ID of the tenant. #### Query Parameters - **guids** (string) - Required - A comma-separated list of graph GUIDs to retrieve. - **incldata** (boolean) - Optional - Include the `Data` property for each graph. - **inclsub** (boolean) - Optional - Include subordinate (child) graphs. ### Request Example `GET /v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs?guids=00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001` ### Response #### Success Response (200) - **Graphs** (array) - An array containing the requested graph objects. #### Response Example ```json { "Graphs": [ { "Guid": "some-guid-1", "Name": "Graph One", "Created": "2023-01-01T12:00:00Z", "Modified": "2023-01-01T12:00:00Z", "Data": {}, "Labels": [], "Tags": {}, "Children": [] }, { "Guid": "some-guid-2", "Name": "Graph Two", "Created": "2023-01-02T12:00:00Z", "Modified": "2023-01-02T12:00:00Z", "Data": {}, "Labels": [], "Tags": {}, "Children": [] } ] } ``` ``` -------------------------------- ### Running LiteGraph with Docker Source: https://litegraph.readme.io/reference/index Provides instructions for running LiteGraph using Docker, including pulling the image, setting up with Docker Compose, and running a container with volume mounts for persistent data and configuration. Assumes Docker is installed. ```bash docker run -d \ -p 8701:8701 \ -v /path/to/litegraph.db:/app/litegraph.db \ -v /path/to/litegraph.json:/app/litegraph.json \ jchristn/litegraph ``` -------------------------------- ### Get Node Parents using LiteGraph SDK (JavaScript) Source: https://litegraph.readme.io/reference/get-node-parents This JavaScript example shows how to use the LiteGraph SDK to fetch all parent nodes for a given node. It initializes the SDK with endpoint and authentication details and calls the `getParentsFromNode` method. ```javascript import { LiteGraphSdk } from "litegraphdb"; var api = new LiteGraphSdk( "http://localhost:8701/", "", "*******" ); const getParentsFromNode = async () => { try { const data = await api.Route.getParentsFromNode(graphGuid, nodeGuid); console.log(data, "check data"); } catch (err) { console.log("err:", JSON.stringify(err), err); } }; ``` -------------------------------- ### Check .NET SDK Version (Bash) Source: https://litegraph.readme.io/reference/running-server-from-source Verifies that the .NET 8.0 SDK is installed and accessible in the system's PATH. ```bash dotnet --version ``` -------------------------------- ### Get Node Children using LiteGraph SDK (C#) Source: https://litegraph.readme.io/reference/get-node-children Illustrates how to obtain child nodes of a specified parent node with the LiteGraph SDK in C#. This example utilizes the SqliteGraphRepository and demonstrates reading children with specific enumeration order. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response= liteGraph.Node.ReadChildren(Guid.Parse(""), Guid.Parse(""), Guid.Parse(""), EnumerationOrderEnum.CreatedDescending); ``` -------------------------------- ### Get Node Children using LiteGraph SDK (Python) Source: https://litegraph.readme.io/reference/get-node-children Provides a Python example for retrieving child nodes associated with a parent node using the LiteGraph SDK. It includes SDK configuration and a function to fetch and print the children. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def get_children_of_node(): children = litegraph.RouteNodes.children( graph_guid="graph-guid", node_guid="node-guid" ) print(children) get_children_of_node() ``` -------------------------------- ### Generate and Use Security Token (Bash) Source: https://litegraph.readme.io/reference/running-server-from-source Demonstrates how to generate a 24-hour temporal security token using a curl command and subsequently use this token to authenticate API requests for accessing graphs. Requires email, password, and tenant GUID for token generation. ```bash curl -H "x-email: default@user.com" \ -H "x-password: password" \ -H "x-tenant-guid: 00000000-0000-0000-0000-000000000000" \ http://localhost:8701/v1.0/token curl -H "x-token: [generated-token]" http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs ``` -------------------------------- ### Retrieve Multiple Nodes by GUIDs (cURL) Source: https://litegraph.readme.io/reference/read-and-enumeration-5 Fetches multiple specific nodes by their GUIDs using a GET request to /v1.0/tenants/{tenant-guid}/graphs/{graph-guid}/nodes?guids=,. GUIDs are provided as a comma-separated list in the query string. Optional query parameters incldata and inclsub can include additional node data and child nodes. ```curl curl --location 'http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs/00000000-0000-0000-0000-000000000000/nodes?guids=00000000-0000-0000-0000-000000000000,00000000-0000-0000-0000-000000000001' \ --header 'Authorization: ••••••' ``` -------------------------------- ### Get All Graphs (with authentication) Source: https://litegraph.readme.io/reference/running-server-from-source Retrieves all graphs associated with a tenant, requiring authentication. ```APIDOC ## GET /v1.0/tenants/{tenant_guid}/graphs ### Description Retrieves all graphs associated with a tenant, requiring authentication. ### Method GET ### Endpoint http://localhost:8701/v1.0/tenants/{tenant_guid}/graphs ### Parameters #### Path Parameters - **tenant_guid** (string) - Required - The GUID of the tenant. #### Request Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., "Bearer [generated-token]"). ### Request Example ```bash curl -H "Authorization: Bearer default" \ http://localhost:8701/v1.0/tenants/00000000-0000-0000-0000-000000000000/graphs ``` ### Response #### Success Response (200) - **graphs** (array) - A list of graphs. - **graph_id** (string) - The ID of the graph. - **graph_name** (string) - The name of the graph. ``` -------------------------------- ### Retrieve First Node (Python) Source: https://litegraph.readme.io/reference/read-and-enumeration-5 Employs the litegraph Python library to fetch the first node. It requires configuring the SDK with endpoint, tenant GUID, and access key. The `litegraph.Node.retrieve_first` function is called with the graph GUID to get the node object. ```python import litegraph sdk = litegraph.configure( endpoint="http://localhost:8701", tenant_guid="Tenant-Guid", access_key="******", ) def retrieve_first_node(): node = litegraph.Node.retrieve_first(graph_guid="graph-guid") print(node) retrieve_first_node() ``` -------------------------------- ### Perform Vector Edge Search with C# Source: https://litegraph.readme.io/reference/vector-search-1 This C# example illustrates how to perform a vector-based search for edges using the LiteGraph library. It initializes a LiteGraphClient with an SqliteGraphRepository and then calls the Vector.SearchEdge method, specifying the search type, embeddings, tenant GUID, and graph GUID. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); IEnumerable response = liteGraph.Vector.SearchEdge(VectorSearchTypeEnum.CosineSimilarity, new List() { 0.1f, 0.2f, 0.3f }, Guid.Parse("tenant-guid"), Guid.Parse("graph-guid")); ``` -------------------------------- ### Create User with LiteGraph Client (C#) Source: https://litegraph.readme.io/reference/create-1 Illustrates user creation in C# using the LiteGraphClient. It requires initializing a SqliteGraphRepository and then calling the User.Create method with a UserMaster object containing user details. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); UserMaster response = liteGraph.User.Create(new UserMaster() { FirstName = "test", LastName = "name", Email = "example@gmail.com", Password = "password", Active = true, }); ``` -------------------------------- ### Create Tenant using cURL Source: https://litegraph.readme.io/reference/create Demonstrates how to create a new tenant using a cURL command. This method requires the LiteGraph administrative API key for authentication and sends tenant details in JSON format. ```curl curl --location --request PUT 'http://view.homedns.org:8701/v1.0/tenants' \ --header 'content-type: application/json' \ --header 'Authorization: Bearer ********' \ --data '{ "Name": "Another tenant", "Active": true }' ``` -------------------------------- ### Check Tenant Existence with C# SDK Source: https://litegraph.readme.io/reference/exist Employs the LiteGraph C# SDK to verify tenant existence by its GUID. This example initializes a LiteGraph client with an SQLite repository and checks for the tenant's presence. Requires the tenant GUID to be parsed into a System.Guid object. ```csharp using LiteGraph; using LiteGraph.GraphRepositories.Sqlite; LiteGraphClient liteGraph = new LiteGraphClient(new SqliteGraphRepository("litegraph.db")); liteGraph.InitializeRepository(); bool exists = liteGraph.Tenant.ExistsByGuid(Guid.Parse("")); ```