TagoIO SDK for JavaScript and TypeScript
    Preparing search index...

    Class Analyses

    Index

    Constructors

    Methods

    • Calls the Endpoint of a Luau analysis ({API_URL}/endpoint/{id}/{path}) with the module token. Unlike the other methods, a non-2xx answer is returned, not thrown: the Endpoint's code decides its status. The request is sent once (no retries) and redirects are never followed: the 3xx answer is returned as is (browsers hide it behind status: 0). The body is parsed when the response is JSON, otherwise it is text.

      Type Parameters

      • T = any

      Parameters

      Returns Promise<AnalysisEndpointResponse<T>>

      A Run user or analysis token needs Analysis / Call Endpoint in Access Management.

      const response = await Resources.analysis.callEndpoint("analysis-id-123", {
      method: "POST",
      path: "/orders",
      query: { dry_run: true },
      body: { item: "sensor" },
      });
      console.log(response.status, response.body); // 200 { ok: true }
    • Creates a new analysis in your application.

      Parameters

      Returns Promise<{ id: string; token: string }>

      If receive an error "Authorization Denied", check policy Analysis / Create in Access Management.

      const newAnalysis = await Resources.analysis.create({
      name: "My Analysis",
      runtime: "node-rt2025",
      tags: [{ key: "type", value: "data-processing" }]
      });
      console.log(newAnalysis.id, newAnalysis.token); // analysis-id-123, analysis-token-123
    • Deletes an analysis from your application.

      Parameters

      • analysisID: string

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Analysis / Delete in Access Management.

      const result = await Resources.analysis.delete("analysis-id-123");
      console.log(result); // Successfully Removed
    • Gets a download URL for the analysis script.

      Parameters

      • analysisID: string
      • Optionaloptions: { version?: number }

      Returns Promise<{ expire_at: Date; size: number; size_unit: string; url: string }>

      If receive an error "Authorization Denied", check policy Analysis / Download Analysis Script in Access Management.

      const download = await Resources.analysis.downloadScript("analysis-id-123", { version: 1 });
      console.log(download.url);
    • Modifies an existing analysis.

      Parameters

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Analysis / Create in Access Management.

      const result = await Resources.analysis.edit("analysis-id-123", {
      name: "Updated Analysis",
      active: false
      });
      console.log(result); // Successfully Updated

      // Turn on the HTTP Endpoint of a Luau analysis (a partial `endpoint` is merged into the stored one)
      await Resources.analysis.edit("analysis-id-123", { endpoint: { active: true, access: "public" } });
    • Get the raw source code content of a specific snippet file. Fetches the actual code content from the TagoIO snippets repository.

      Parameters

      • runtime: SnippetRuntime

        The runtime environment the snippet belongs to

      • filename: string

        The filename of the snippet to retrieve

      Returns Promise<string>

      Promise resolving to the raw file content as string

      // Get TypeScript code for console example
      const code = await Resources.analysis.getSnippetFile("deno-rt2025", "console.ts");
      console.log(code);

      // Get Python code for data processing
      const pythonCode = await Resources.analysis.getSnippetFile("python-rt2025", "avg-min-max.py");
      console.log(pythonCode);
    • Lists all analyses from the application with pagination support. Use this to retrieve and manage analyses in your application.

      Type Parameters

      Parameters

      • OptionalqueryObj: T

      Returns Promise<
          AnalysisListItem<
              T["fields"] extends (keyof AnalysisInfo)[]
                  ? any[any] extends readonly (string | number | symbol)[]
                      ? any[any][number]
                      : "id" | "name"
                  : "id" | "name",
          >[],
      >

      If receive an error "Authorization Denied", check policy Analysis / Access in Access Management.

      const list = await Resources.analysis.list({
      page: 1,
      fields: ["id", "name"],
      amount: 10,
      orderBy: ["name", "asc"]
      });
      console.log(list); // [ { id: 'analysis-id-123', name: 'Analysis Test', ...} ]
    • Lists the analyses with an active Endpoint that the token may call: all of them for a profile token, and the ones granted by Access Management (call_endpoint) for a Run user or analysis token.

      Returns Promise<AnalysisEndpointListItem[]>

      If receive an error "Authorization Denied", the token is missing or invalid.

      const endpoints = await Resources.analysis.listEndpoints();
      console.log(endpoints); // [ { id: 'analysis-id-123', name: 'My Page', url: 'https://api.tago.io/endpoint/analysis-id-123/' } ]
    • Get all available snippets for a specific runtime environment. Fetches analysis code snippets from the public TagoIO snippets repository.

      Parameters

      Returns Promise<SnippetsListResponse>

      Promise resolving to the snippets metadata

      const denoSnippets = await Resources.analysis.listSnippets("deno-rt2025");

      // Print all snippet titles
      denoSnippets.snippets.forEach(snippet => {
      console.log(`${snippet.title}: ${snippet.description}`);
      });
    • Executes an analysis with optional scope parameters.

      Parameters

      • analysisID: string
      • OptionalscopeObj: Record<string, any>

      Returns Promise<{ analysis_token: string }>

      If receive an error "Authorization Denied", check policy Analysis / Run Analysis in Access Management.

      const result = await Resources.analysis.run("analysis-id-123", { environment: "production" });
      console.log(result.analysis_token);
    • Generates a new token for the analysis.

      Parameters

      • analysisID: string

      Returns Promise<{ analysis_token: string }>

      This is only allowed when the analysis is running in external mode.

      const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
      const token = await resources.analysis.tokenGenerate("analysis-id-123");
      console.log(token.analysis_token); // analysis-token-123
    • Uploads a script file to an analysis.

      Parameters

      Returns Promise<string>

      If receive an error "Authorization Denied", check policy Analysis / Upload Analysis Script in Access Management.

      const result = await Resources.analysis.uploadScript("analysis-id-123", {
      name: "script.js",
      content: "base64-encoded-content",
      language: "node-rt2025"
      });
      console.log(result);