### Get Memory Labels - Go (Example) Source: https://mem.nowledge.co/docs/api/memories/memory_id/labels/get A Go language example for retrieving memory labels. This demonstrates making an HTTP GET request and processing the JSON response, including error handling. ```go // Go example (implementation not provided in source) // package main // // import ( // "fmt" // "net/http" // ) // // func main() { // resp, err := http.Get("http://127.0.0.1:14242/memories/{memory_id}/labels") // if err != nil { // fmt.Println("Error making request:", err) // return // } // defer resp.Body.Close() // // Process response body here // } ``` -------------------------------- ### Get Memory Labels - C# (Example) Source: https://mem.nowledge.co/docs/api/memories/memory_id/labels/get C# code example for fetching memory labels. It demonstrates using HttpClient to make a GET request and process the JSON response, including error management. ```csharp // C# example (implementation not provided in source) // using System; // using System.Net.Http; // using System.Threading.Tasks; // // public class GetMemoryLabels // { // public static async Task Main(string[] args) // { // using (HttpClient client = new HttpClient()) // { // try // { // HttpResponseMessage response = await client.GetAsync("http://127.0.0.1:14242/memories/{memory_id}/labels"); // response.EnsureSuccessStatusCode(); // Throw if HTTP status code is an error // string responseBody = await response.Content.ReadAsStringAsync(); // Console.WriteLine(responseBody); // } // catch (HttpRequestException e) // { // Console.WriteLine($"Error: {e.Message}"); // } // } // } // } ``` -------------------------------- ### Search Threads Full Endpoint - C# Example Source: https://mem.nowledge.co/docs/api/threads/search/get Demonstrates how to call the 'Search Threads Full' endpoint using C#. This example utilizes HttpClient to perform the GET request and process the response. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ThreadSearcher { public static async Task SearchThreadsAsync(string query, string mode = "full", int limit = 20) { using (HttpClient client = new HttpClient()) { string url = $"http://127.0.0.1:14242/threads/search?query={query}&mode={mode}&limit={limit}"; try { HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); // Throws an exception if the response indicates an error string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } } public static void Main(string[] args) { SearchThreadsAsync("example query").Wait(); } } ``` -------------------------------- ### Search Threads Full Endpoint - Python Example Source: https://mem.nowledge.co/docs/api/threads/search/get Provides a Python example for calling the 'Search Threads Full' endpoint. This snippet demonstrates making a GET request and handling the JSON response. ```python import requests def search_threads(query, mode='full', limit=20): url = f"http://127.0.0.1:14242/threads/search" params = { "query": query, "mode": mode, "limit": limit } try: response = requests.get(url, params=params) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error: {e}") return None results = search_threads('example query') if results: print(results) ``` -------------------------------- ### Search Threads Full Endpoint - Java Example Source: https://mem.nowledge.co/docs/api/threads/search/get Shows a Java implementation for querying the 'Search Threads Full' endpoint. This example uses a common HTTP client library to make the GET request. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; public class ThreadSearch { public static void main(String[] args) { HttpClient client = HttpClient.newHttpClient(); String query = "example query"; String url = String.format("http://127.0.0.1:14242/threads/search?query=%s&mode=full&limit=20", query); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .GET() .build(); try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println("Status Code: " + response.statusCode()); System.out.println("Response Body: " + response.body()); } catch (IOException | InterruptedException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Get Thread Coverage Report (Go) Source: https://mem.nowledge.co/docs/api/threads/thread_id/coverage/get Go language example for fetching thread coverage data. It shows how to make an HTTP GET request and parse the JSON response body. ```go package main import ( "fmt" "net/http" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/threads/string/coverage") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() // Process response body here fmt.Println("Status Code:", resp.StatusCode) } ``` -------------------------------- ### Get Memory Labels - Java (Example) Source: https://mem.nowledge.co/docs/api/memories/memory_id/labels/get Java implementation for retrieving memory labels. This example shows how to perform an HTTP GET request and parse the JSON response, including error handling. ```java // Java example (implementation not provided in source) // import java.net.URI; // import java.net.http.HttpClient; // import java.net.http.HttpRequest; // import java.net.http.HttpResponse; // // public class GetMemoryLabels { // public static void main(String[] args) throws Exception { // HttpClient client = HttpClient.newHttpClient(); // HttpRequest request = HttpRequest.newBuilder() // .uri(URI.create("http://127.0.0.1:14242/memories/{memory_id}/labels")) // .build(); // // HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); // System.out.println(response.body()); // } // } ``` -------------------------------- ### Get Graph Data Sample using C# Source: https://mem.nowledge.co/docs/api/graph/sample/get This C# code example utilizes `HttpClient` to make a GET request to the '/graph/sample' endpoint for retrieving graph data. It asynchronously sends the request and displays the response content. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class GraphClient { static readonly HttpClient client = new HttpClient(); public static async Task GetGraphSampleAsync() { try { HttpResponseMessage response = await client.GetAsync("http://127.0.0.1:14242/graph/sample"); response.EnsureSuccessStatusCode(); // Throw if status code is not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } public static void Main(string[] args) { GetGraphSampleAsync().Wait(); } } ``` -------------------------------- ### Search Threads Full Endpoint - JavaScript Example Source: https://mem.nowledge.co/docs/api/threads/search/get Illustrates how to interact with the 'Search Threads Full' endpoint using JavaScript. This example shows a basic GET request to retrieve thread search results. ```javascript async function searchThreads(query, mode = 'full', limit = 20) { const response = await fetch(`http://127.0.0.1:14242/threads/search?query=${query}&mode=${mode}&limit=${limit}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return await response.json(); } searchThreads('example query').then(data => console.log(data)).catch(error => console.error('Error:', error)); ``` -------------------------------- ### List Threads GET Request using Go Source: https://mem.nowledge.co/docs/api/threads/get Example Go code to fetch a list of threads from the API. This snippet demonstrates how to make an HTTP GET request and handle the JSON response. ```go package main import ( "fmt" "net/http" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/threads") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() // Process the response body here fmt.Println("Status Code:", resp.StatusCode) } ``` -------------------------------- ### Start Graph Augmentation Job - Go Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Initiates a background augmentation job via a POST request. Requires the job type and accepts optional parameters. Returns job status and ID upon success. This example demonstrates using Go's standard library for HTTP requests. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "http://127.0.0.1:14242/graph/augmentation/start" data := map[string]interface{}{ "job_type": "string", "parameters": nil // Add parameters if needed } jsonBody, err := json.Marshal(data) if err != nil { fmt.Printf("Error marshaling JSON: %s\n", err) return } resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonBody)) if err != nil { fmt.Printf("Error making POST request: %s\n", err) return } defer resp.Body.Close() // Process response body here fmt.Printf("Status Code: %d\n", resp.StatusCode) } ``` -------------------------------- ### Start Graph Augmentation Job - C# Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Initiates a background augmentation job via a POST request. Requires the job type and accepts optional parameters. Returns job status and ID upon success. This example uses HttpClient. ```csharp using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; public class AugmentationApiClient { public async Task StartAugmentationAsync(string jobType, object parameters = null) { using (HttpClient client = new HttpClient()) { var payload = new { job_type = jobType, parameters = parameters }; string jsonPayload = Newtonsoft.Json.JsonConvert.SerializeObject(payload); var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PostAsync("http://127.0.0.1:14242/graph/augmentation/start", content); string responseBody = await response.Content.ReadAsStringAsync(); // Process responseBody } } } ``` -------------------------------- ### Search Graph API - Go Example Source: https://mem.nowledge.co/docs/api/graph/search/get Example Go code for querying the Graph Search API. This snippet illustrates making an HTTP GET request, setting query parameters, and handling the JSON response. It includes basic error handling for the request and JSON unmarshalling. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" ) func searchGraphGo(query string, limit int, depth int, nodeTypes string, edgeTypes string, includeMetadata bool) (map[string]interface{}, error) { params := url.Values{} params.Add("query", query) params.Add("limit", fmt.Sprintf("%d", limit)) params.Add("depth", fmt.Sprintf("%d", depth)) if nodeTypes != "" { params.Add("node_types", nodeTypes) } if edgeTypes != "" { params.Add("edge_types", edgeTypes) } params.Add("include_metadata", fmt.Sprintf("%t", includeMetadata)) url := fmt.Sprintf("http://127.0.0.1:14242/graph/search?%s", params.Encode()) resp, err := http.Get(url) if err != nil { return nil, fmt.Errorf("failed to make request: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } var result map[string]interface{} if err := json.Unmarshal(body, &result); err != nil { return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) } return result, nil } ``` -------------------------------- ### Search Graph API - C# Example Source: https://mem.nowledge.co/docs/api/graph/search/get Example C# code for interacting with the Graph Search API. This snippet demonstrates making an HTTP GET request using HttpClient, setting query parameters, and deserializing the JSON response. It includes basic error handling. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; using System.Web; using Newtonsoft.Json; public class GraphSearchCSharp { public static async Task SearchGraphAsync(string query, int limit = 30, int depth = 2, string nodeTypes = null, string edgeTypes = null, bool includeMetadata = true) { using (var client = new HttpClient()) { var builder = new UriBuilder("http://127.0.0.1:14242/graph/search"); var queryParams = HttpUtility.ParseQueryString(builder.Query); queryParams["query"] = query; queryParams["limit"] = limit.ToString(); queryParams["depth"] = depth.ToString(); if (nodeTypes != null) queryParams["node_types"] = nodeTypes; if (edgeTypes != null) queryParams["edge_types"] = edgeTypes; queryParams["include_metadata"] = includeMetadata.ToString(); builder.Query = queryParams.ToString(); var request = new HttpRequestMessage(HttpMethod.Get, builder.Uri); try { HttpResponseMessage response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); // Throws an exception if the response indicates an error string responseBody = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); return default(T); } } } } ``` -------------------------------- ### Get Graph Analysis - Go Source: https://mem.nowledge.co/docs/api/graph/analysis/get Example using Go to send a GET request to the graph analysis endpoint. This demonstrates how to retrieve graph data using Go's standard http package, suitable for backend services. ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/graph/analysis") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Start Graph Augmentation Job - Java Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Initiates a background augmentation job via a POST request. Requires the job type and accepts optional parameters. Returns job status and ID upon success. This example uses Apache HttpClient. ```java import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.io.IOException; public class AugmentationClient { public static void main(String[] args) { try (CloseableHttpClient client = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("http://127.0.0.1:14242/graph/augmentation/start"); String jsonPayload = "{\"job_type\": \"string\"}"; // Add parameters if needed StringEntity entity = new StringEntity(jsonPayload); httpPost.setEntity(entity); httpPost.setHeader("Content-Type", "application/json"); // Execute request and process response // CloseableHttpResponse response = client.execute(httpPost); // ... process response ... } catch (IOException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Start Graph Augmentation Job - JavaScript Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Initiates a background augmentation job via a POST request. Requires the job type and accepts optional parameters. Returns job status and ID upon success. This example uses the fetch API. ```javascript async function startAugmentation(jobType, parameters) { const response = await fetch('http://127.0.0.1:14242/graph/augmentation/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ job_type: jobType, parameters: parameters }) }); return await response.json(); } ``` -------------------------------- ### List Threads GET Request using C# Source: https://mem.nowledge.co/docs/api/threads/get Example C# code to fetch a list of threads from the API using HttpClient. This demonstrates making an asynchronous GET request and processing the response. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ListThreads { public static async Task Main(string[] args) { using (HttpClient client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync("http://127.0.0.1:14242/threads"); response.EnsureSuccessStatusCode(); // Throw if not success string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` -------------------------------- ### List Entities using cURL Source: https://mem.nowledge.co/docs/api/entities/get Example of how to list entities using the cURL command-line tool. This demonstrates a basic GET request to the entities endpoint. ```shell curl -X GET "http://127.0.0.1:14242/entities" ``` -------------------------------- ### Start Graph Augmentation Job - Python Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Initiates a background augmentation job via a POST request. Requires the job type and accepts optional parameters. Returns job status and ID upon success. This example uses the 'requests' library. ```python import requests def start_augmentation(job_type, parameters=None): url = "http://127.0.0.1:14242/graph/augmentation/start" payload = { "job_type": job_type, "parameters": parameters } response = requests.post(url, json=payload) return response.json() ``` -------------------------------- ### Get Thread Coverage Report (C#) Source: https://mem.nowledge.co/docs/api/threads/thread_id/coverage/get C# code example for fetching thread coverage. This snippet demonstrates using HttpClient to make a GET request to the specified API endpoint and process the response. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ThreadCoverageFetcher { public static async Task GetCoverageAsync() { using (HttpClient client = new HttpClient()) { string url = "http://127.0.0.1:14242/threads/string/coverage"; HttpResponseMessage response = await client.GetAsync(url); if (response.IsSuccessStatusCode) { string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } else { Console.WriteLine($"Error: {response.StatusCode}"); } } } public static void Main(string[] args) { GetCoverageAsync().GetAwaiter().GetResult(); } } ``` -------------------------------- ### Search Graph API - Java Example Source: https://mem.nowledge.co/docs/api/graph/search/get Example Java code for calling the Graph Search API. This snippet shows how to make an HTTP GET request using Apache HttpClient, set query parameters, and parse the JSON response. It includes basic error handling. ```java import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.net.URI; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.Map; public class GraphSearchJava { public static Map searchGraph(String query, int limit, int depth, String nodeTypes, String edgeTypes, boolean includeMetadata) { CloseableHttpClient httpClient = HttpClients.createDefault(); ObjectMapper mapper = new ObjectMapper(); Map result = null; try { URIBuilder builder = new URIBuilder("http://127.0.0.1:14242/graph/search"); builder.addParameter("query", query); builder.addParameter("limit", String.valueOf(limit)); builder.addParameter("depth", String.valueOf(depth)); if (nodeTypes != null) { builder.addParameter("node_types", nodeTypes); } if (edgeTypes != null) { builder.addParameter("edge_types", edgeTypes); } builder.addParameter("include_metadata", String.valueOf(includeMetadata)); URI uri = builder.build(); HttpGet httpGet = new HttpGet(uri); CloseableHttpResponse response = httpClient.execute(httpGet); try { if (response.getStatusLine().getStatusCode() == 200) { String jsonResponse = EntityUtils.toString(response.getEntity()); result = mapper.readValue(jsonResponse, Map.class); } else { System.err.println("Error: " + response.getStatusLine().getStatusCode()); } } finally { response.close(); } } catch (Exception e) { e.printStackTrace(); } finally { try { httpClient.close(); } catch (Exception e) { e.printStackTrace(); } } return result; } } ``` -------------------------------- ### Get Graph Analysis - C# Source: https://mem.nowledge.co/docs/api/graph/analysis/get Example using C# to send a GET request to the graph analysis endpoint. This code shows how to retrieve graph data using .NET's HttpClient, useful for C# applications. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class GraphAnalysisClient { public static async Task Main(string[] args) { using (HttpClient client = new HttpClient()) { try { HttpResponseMessage response = await client.GetAsync("http://127.0.0.1:14242/graph/analysis"); response.EnsureSuccessStatusCode(); // Throw if not success string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } } } ``` -------------------------------- ### Search Graph API - JavaScript Example Source: https://mem.nowledge.co/docs/api/graph/search/get Example JavaScript code to interact with the Graph Search API. This snippet shows how to make a GET request to the endpoint, passing necessary query parameters and handling the JSON response. It assumes the use of a fetch API or similar. ```javascript async function searchGraph(query, limit = 30, depth = 2, nodeTypes = null, edgeTypes = null, includeMetadata = true) { const url = new URL('http://127.0.0.1:14242/graph/search'); url.searchParams.append('query', query); url.searchParams.append('limit', limit.toString()); url.searchParams.append('depth', depth.toString()); if (nodeTypes) url.searchParams.append('node_types', nodeTypes); if (edgeTypes) url.searchParams.append('edge_types', edgeTypes); url.searchParams.append('include_metadata', includeMetadata.toString()); try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error('Error searching graph:', error); return null; } } ``` -------------------------------- ### Get Graph Analysis - Java Source: https://mem.nowledge.co/docs/api/graph/analysis/get Example using Java to send a GET request to the graph analysis endpoint. This code demonstrates how to fetch graph data using standard Java HTTP client libraries, suitable for enterprise applications. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; public class GraphAnalysisClient { public static void main(String[] args) { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://127.0.0.1:14242/graph/analysis")) .build(); try { HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } catch (IOException | InterruptedException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Get Thread Coverage Report (Java) Source: https://mem.nowledge.co/docs/api/threads/thread_id/coverage/get Java example for accessing the thread coverage API. This snippet illustrates making an HTTP GET request and handling the response, likely using a library like Apache HttpClient or Java's built-in http client. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class ThreadCoverage { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://127.0.0.1:14242/threads/string/coverage")) .GET() .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println("Status Code: " + response.statusCode()); System.out.println("Response Body: " + response.body()); } } ``` -------------------------------- ### Get Graph Data Sample using Go Source: https://mem.nowledge.co/docs/api/graph/sample/get This Go code illustrates how to fetch graph data from the '/graph/sample' endpoint using the `net/http` package. It makes a GET request and handles the JSON response. ```go package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/graph/sample") if err != nil { log.Fatalf("Failed to make request: %v", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Failed to read response body: %v", err) } fmt.Println(string(body)) } ``` -------------------------------- ### Preview Memory KG Extraction using Go Source: https://mem.nowledge.co/docs/api/memories/memory_id/extract-kg/preview/post Provides a Go code example for sending a POST request to preview knowledge graph extraction. It utilizes the standard `net/http` package to construct and send the request with an empty JSON body. ```go package main import ( "bytes" "net/http" ) func main() { client := &http.Client{} request, _ := http.NewRequest("POST", "http://127.0.0.1:14242/memories/string/extract-kg/preview", bytes.NewBuffer([]byte("{}"))); request.Header.Set("Content-Type", "application/json"); client.Do(request); } ``` -------------------------------- ### List Threads GET Request using cURL Source: https://mem.nowledge.co/docs/api/threads/get Example cURL command to fetch a list of threads from the API. This demonstrates the basic request structure and endpoint. ```bash curl -X GET "http://127.0.0.1:14242/threads" ``` -------------------------------- ### Get Job Status - Python Source: https://mem.nowledge.co/docs/api/graph/augmentation/status/job_id/get Example Python code to get the status of an augmentation job. This snippet shows how to send a GET request and process the JSON response. ```python # Python example would go here, likely using the 'requests' library. ``` -------------------------------- ### Get Memory by ID Python Request Source: https://mem.nowledge.co/docs/api/memories/memory_id/get Example Python code using the requests library to get a specific memory by its ID. It sends a GET request and prints the JSON response. ```python import requests response = requests.get("http://127.0.0.1:14242/memories/string") print(response.json()) ``` -------------------------------- ### Get Favorite Threads - cURL Source: https://mem.nowledge.co/docs/api/favorites/threads/get Example of how to retrieve all favorite threads using cURL. This command sends a GET request to the specified endpoint. ```shell curl -X GET "http://127.0.0.1:14242/favorites/threads" ``` -------------------------------- ### Get Favorite Threads - C# Source: https://mem.nowledge.co/docs/api/favorites/threads/get Example of how to retrieve all favorite threads using C#. This code snippet demonstrates making a GET request to the API endpoint. ```csharp // C# example for fetching favorite threads would go here. ``` -------------------------------- ### Preview Memory KG Extraction using C# Source: https://mem.nowledge.co/docs/api/memories/memory_id/extract-kg/preview/post Provides a C# example for making a POST request to preview knowledge graph extraction. It uses `System.Net.Http.HttpClient` to send the request with an empty JSON payload. ```csharp using System.Net.Http; using System.Text; using System.Threading.Tasks; var client = new HttpClient(); var response = await client.PostAsync("http://127.0.0.1:14242/memories/string/extract-kg/preview", new StringContent("{}", Encoding.UTF8, "application/json")); ``` -------------------------------- ### Get Favorite Threads - Java Source: https://mem.nowledge.co/docs/api/favorites/threads/get Example of how to retrieve all favorite threads using Java. This code snippet demonstrates making a GET request to the API endpoint. ```java // Java example for fetching favorite threads would go here. ``` -------------------------------- ### Get Favorite Threads - Python Source: https://mem.nowledge.co/docs/api/favorites/threads/get Example of how to retrieve all favorite threads using Python. This code snippet demonstrates making a GET request to the API endpoint. ```python # Python example for fetching favorite threads would go here. ``` -------------------------------- ### Get Favorite Threads - Go Source: https://mem.nowledge.co/docs/api/favorites/threads/get Example of how to retrieve all favorite threads using Go. This code snippet demonstrates making a GET request to the API endpoint. ```go // Go example for fetching favorite threads would go here. ``` -------------------------------- ### Get Favorite Threads - JavaScript Source: https://mem.nowledge.co/docs/api/favorites/threads/get Example of how to retrieve all favorite threads using JavaScript. This code snippet demonstrates making a GET request to the API endpoint. ```javascript // JavaScript example for fetching favorite threads would go here. ``` -------------------------------- ### Get Label by ID using C# Source: https://mem.nowledge.co/docs/api/labels/label_id/get C# code snippet for fetching a label by its ID. This example uses `HttpClient` to make the GET request to the specified API endpoint. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class LabelApiClient { private static readonly HttpClient client = new HttpClient(); public static async Task GetLabelAsync(string labelId) { string url = $"http://127.0.0.1:14242/labels/{labelId}"; HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); // Throw exception if not successful return await response.Content.ReadAsStringAsync(); } // Example usage: // public static async Task Main(string[] args) // { // try // { // string labelData = await GetLabelAsync("your_label_id"); // Console.WriteLine($"Label Data: {labelData}"); // } // catch (HttpRequestException e) // { // Console.WriteLine($"Error fetching label: {e.Message}"); // } // } } ``` -------------------------------- ### List Augmentation Jobs - Go Source: https://mem.nowledge.co/docs/api/graph/augmentation/jobs/get Example using Go (net/http) to list augmentation jobs. This shows how to make a GET request and read the response body. ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/graph/augmentation/jobs") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Get Label by ID using Go Source: https://mem.nowledge.co/docs/api/labels/label_id/get Provides a Go code example for retrieving a specific label by its ID. This involves making an HTTP GET request to the API endpoint. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" ) func getLabel(labelID string) (map[string]interface{}, error) { url := fmt.Sprintf("http://127.0.0.1:14242/labels/%s", labelID) resp, err := http.Get(url) if err != nil { return nil, fmt.Errorf("failed to make request: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } var result map[string]interface{} if err := json.Unmarshal(body, &result); err != nil { return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) } return result, nil } // Example usage: // func main() { // labelData, err := getLabel("your_label_id") // if err != nil { // fmt.Println("Error:", err) // } else { // fmt.Println("Label Data:", labelData) // } // } ``` -------------------------------- ### Search Threads Full Endpoint - Go Example Source: https://mem.nowledge.co/docs/api/threads/search/get Presents a Go program for calling the 'Search Threads Full' endpoint. This snippet includes making an HTTP GET request and handling the JSON response. ```go package main import ( "fmt" "io/ioutil" "log" "net/http" "net/url" ) func main() { baseURL := "http://127.0.0.1:14242/threads/search" query := "example query" params := url.Values{} params.Add("query", query) params.Add("mode", "full") params.Add("limit", "20") fullURL := baseURL + "?" + params.Encode() resp, err := http.Get(fullURL) if err != nil { log.Fatalf("Failed to make request: %v", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { bodyBytes, _ := ioutil.ReadAll(resp.Body) log.Fatalf("Request failed with status %d: %s", resp.StatusCode, string(bodyBytes)) } bodyBytes, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Failed to read response body: %v", err) } fmt.Println(string(bodyBytes)) } ``` -------------------------------- ### Get Memory by ID C# Request Source: https://mem.nowledge.co/docs/api/memories/memory_id/get Example C# code using HttpClient to fetch a specific memory by its ID. This snippet shows how to construct the GET request and process the response. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class MemoryClient { public static async Task GetMemoryAsync(string memoryId) { using (HttpClient client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync($"http://127.0.0.1:14242/memories/{memoryId}"); response.EnsureSuccessStatusCode(); // Throw if HTTP status code is not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` -------------------------------- ### Preview Distillation Response (JSON) Source: https://mem.nowledge.co/docs/api/memories/distill/preview/post Example JSON response for a successful preview distillation (200 OK). It includes success status, a cache key for reuse, distillation details, processing time, extracted memories, entities, relationships, insights, a summary, and potential error messages. ```json { "success": true, "cache_key": "string", "distillation_type": "string", "processing_time": 0, "memories": [ {} ], "entities": [ {} ], "relationships": [ {} ], "insights": [ {} ], "summary": "string", "error": "string" } ``` -------------------------------- ### Get Job Status - C# Source: https://mem.nowledge.co/docs/api/graph/augmentation/status/job_id/get Example C# code to retrieve the status of an augmentation job. This snippet illustrates making the HTTP GET request and handling the response in C#. ```csharp // C# example would go here, using System.Net.Http.HttpClient. ``` -------------------------------- ### List Labels via HTTP Request (C#) Source: https://mem.nowledge.co/docs/api/labels/get Shows a C# example for listing labels using `HttpClient`. This code sends a GET request to the API and handles the response, including error checking. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class ListLabelsClient { private static readonly HttpClient client = new HttpClient(); public static async Task Main(string[] args) { string url = "http://127.0.0.1:14242/labels"; try { HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); // Throw if status code is not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } } ``` -------------------------------- ### Get Favorite Memories - JavaScript Request Source: https://mem.nowledge.co/docs/api/favorites/memories/get Example JavaScript code using the 'fetch' API to retrieve favorite memories. It shows how to construct the GET request and handle the response. ```javascript fetch('http://127.0.0.1:14242/favorites/memories') .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### POST /graph/augmentation/start Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Starts a background augmentation job. Supports various job types such as community detection, PageRank calculation, and their undo operations. ```APIDOC ## POST /graph/augmentation/start ### Description Start a background augmentation job. Supports job types: * 'community_detection': Apply Louvain community detection * 'pagerank_calculation': Apply PageRank importance calculation * 'undo_community_detection': Remove community detection augmentation * 'undo_pagerank_calculation': Remove PageRank augmentation ### Method POST ### Endpoint /graph/augmentation/start ### Parameters #### Request Body - **job_type** (string) - Required - The type of augmentation job to start. - **parameters** (Parameters) - Optional - Additional parameters for the job. ### Request Example ```json { "job_type": "string" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the job was started successfully. - **job_id** (string) - The unique identifier for the started job. - **job_type** (string) - The type of the started job. - **message** (string) - A status message related to the job. #### Error Response (422) - **detail** (array) - A list of validation errors. - **loc** (array) - The location of the error in the request. - **msg** (string) - The error message. - **type** (string) - The type of error. #### Response Example (200) ```json { "success": true, "job_id": "string", "job_type": "string", "message": "string" } ``` #### Response Example (422) ```json { "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string" } ] } ``` ``` -------------------------------- ### Get Favorite Memories - cURL Request Source: https://mem.nowledge.co/docs/api/favorites/memories/get Example cURL command to fetch favorite memories from the Nowledge Mem API. This demonstrates how to make a GET request to the specified endpoint. ```shell curl -X GET "http://127.0.0.1:14242/favorites/memories" ``` -------------------------------- ### Get Memory by ID Go Request Source: https://mem.nowledge.co/docs/api/memories/memory_id/get Example Go code to retrieve a specific memory by its ID. This code snippet demonstrates how to make an HTTP GET request and process the JSON response. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/memories/string") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println("Response body:", string(body)) } ``` -------------------------------- ### Get Memory by ID cURL Request Source: https://mem.nowledge.co/docs/api/memories/memory_id/get Example cURL command to retrieve a specific memory by its ID. This command sends a GET request to the memories endpoint with the memory ID as a path parameter. ```bash curl -X GET "http://127.0.0.1:14242/memories/string" ``` -------------------------------- ### Get Favorite Memories - Go Request Source: https://mem.nowledge.co/docs/api/favorites/memories/get Example Go code for fetching favorite memories. It utilizes the standard 'net/http' package to perform a GET request and print the response body. ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("http://127.0.0.1:14242/favorites/memories") if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Search Threads Full Endpoint - cURL Example Source: https://mem.nowledge.co/docs/api/threads/search/get Demonstrates how to call the 'Search Threads Full' endpoint using cURL. This command fetches search results for threads based on a provided query string. ```shell curl -X GET "http://127.0.0.1:14242/threads/search?query=string" ``` -------------------------------- ### Get Favorite Memories - C# Request Source: https://mem.nowledge.co/docs/api/favorites/memories/get Example C# code using HttpClient to make a GET request for favorite memories. This illustrates how to initiate the request and read the response body. ```csharp using System.Net.Http; using System.Threading.Tasks; public class GetMemories { public static async Task Main(string[] args) { using (HttpClient client = new HttpClient()) { HttpResponseMessage response = await client.GetAsync("http://127.0.0.1:14242/favorites/memories"); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); System.Console.WriteLine(responseBody); } } } ``` -------------------------------- ### Get Memory by ID Java Request Source: https://mem.nowledge.co/docs/api/memories/memory_id/get Example Java code using a hypothetical HTTP client to retrieve a specific memory by its ID. This demonstrates the process of sending a GET request and handling the response. ```java // Assuming a hypothetical HTTP client library // HttpClient client = new HttpClient(); // HttpResponse response = client.get("http://127.0.0.1:14242/memories/string"); // System.out.println(response.getBody()); ``` -------------------------------- ### Get Graph Data Sample using cURL Source: https://mem.nowledge.co/docs/api/graph/sample/get This cURL command demonstrates how to fetch sample graph data from the API without any specific query parameters. It sends a GET request to the '/graph/sample' endpoint. ```bash curl -X GET "http://127.0.0.1:14242/graph/sample" ``` -------------------------------- ### Get Memory by ID JavaScript Request Source: https://mem.nowledge.co/docs/api/memories/memory_id/get Example JavaScript code to fetch a specific memory by its ID using the fetch API. It makes a GET request to the memories endpoint and handles the JSON response. ```javascript fetch("http://127.0.0.1:14242/memories/string") .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Preview Memory KG Extraction using Java Source: https://mem.nowledge.co/docs/api/memories/memory_id/extract-kg/preview/post Demonstrates a Java implementation for sending a POST request to preview knowledge graph extraction. It uses `java.net.http.HttpClient` to send the request with an empty JSON body. ```java var client = java.net.http.HttpClient.newHttpClient(); var request = java.net.http.HttpRequest.newBuilder() .uri(java.net.URI.create("http://127.0.0.1:14242/memories/string/extract-kg/preview")) .header("Content-Type", "application/json") .POST(java.net.http.HttpRequest.BodyPublishers.ofString("{}")) .build(); client.sendAsync(request, java.net.http.HttpResponse.BodyHandlers.ofString()); ``` -------------------------------- ### Get Favorite Memories - Python Request Source: https://mem.nowledge.co/docs/api/favorites/memories/get Example Python code using the 'requests' library to fetch favorite memories. This snippet illustrates making a GET request and processing the JSON response. ```python import requests response = requests.get('http://127.0.0.1:14242/favorites/memories') print(response.json()) ``` -------------------------------- ### List Labels via HTTP Request (cURL) Source: https://mem.nowledge.co/docs/api/labels/get Example of how to list all labels using an HTTP GET request with cURL. This command fetches labels from the specified local development server endpoint. ```shell curl -X GET "http://127.0.0.1:14242/labels" ``` -------------------------------- ### Get Label by ID using Java Source: https://mem.nowledge.co/docs/api/labels/label_id/get Java code example for retrieving a label by its ID. This typically involves using a library like Apache HttpClient or the built-in `java.net.http` client to perform the GET request. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; public class LabelClient { public static String getLabel(String labelId) throws IOException, InterruptedException { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://127.0.0.1:14242/labels/" + labelId)) .GET() .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() != 200) { throw new IOException("Unexpected status code: " + response.statusCode()); } return response.body(); } // Example usage: // public static void main(String[] args) { // try { // String labelData = getLabel("your_label_id"); // System.out.println("Label Data: " + labelData); // } catch (IOException | InterruptedException e) { // e.printStackTrace(); // } // } } ``` -------------------------------- ### Start Graph Augmentation Job - cURL Source: https://mem.nowledge.co/docs/api/graph/augmentation/start/post Initiates a background augmentation job via a POST request. Requires the job type and accepts optional parameters. Returns job status and ID upon success. ```shell curl -X POST "http://127.0.0.1:14242/graph/augmentation/start" \ -H "Content-Type: application/json" \ -d '{ "job_type": "string" }' ``` -------------------------------- ### Get Job Status - JavaScript Source: https://mem.nowledge.co/docs/api/graph/augmentation/status/job_id/get Example JavaScript code to fetch the status of an augmentation job via its job ID. This typically involves making an HTTP GET request to the specified API endpoint. ```javascript // JavaScript example would go here, typically using fetch or a similar library. ``` -------------------------------- ### Get Job Status - cURL Source: https://mem.nowledge.co/docs/api/graph/augmentation/status/job_id/get Example cURL command to retrieve the status of a specific augmentation job using its unique job ID. ```shell curl -X GET "http://127.0.0.1:14242/graph/augmentation/status/string" ``` -------------------------------- ### Get Memory Labels - cURL Source: https://mem.nowledge.co/docs/api/memories/memory_id/labels/get Example of how to retrieve labels for a memory using cURL. It specifies the GET request and the endpoint URL with a placeholder for the memory ID. ```shell curl -X GET "http://127.0.0.1:14242/memories/string/labels" ``` -------------------------------- ### Get Label by ID using cURL Source: https://mem.nowledge.co/docs/api/labels/label_id/get Example of how to retrieve a specific label by its ID using a cURL command. This demonstrates the HTTP method and endpoint structure. ```shell curl -X GET "http://127.0.0.1:14242/labels/string" ``` -------------------------------- ### Get Favorite Memories - Java Request Source: https://mem.nowledge.co/docs/api/favorites/memories/get Example Java code demonstrating how to make a GET request to retrieve favorite memories using a common HTTP client library. It shows basic request construction and response handling. ```java import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; public class GetMemories { public static void main(String[] args) throws IOException, InterruptedException { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(java.net.URI.create("http://127.0.0.1:14242/favorites/memories")) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ```