0

Execute Strale Capability

by
Published Apr 14, 2026

Execute a specific Strale data capability by its slug. Returns structured output with provenance, audit trail, and quality metadata. Common capabilities: - swedish-company-data: Look up Swedish company information - vat-validate: Validate EU VAT numbers via VIES - pep-check: Screen individuals against PEP/sanctions databases - invoice-extract: Extract structured data from invoice PDFs - email-validate: Validate email addresses (free, no auth required) Use dry_run=true to check pricing and availability without executing. Full capability catalog: https://api.strale.io/v1/capabilities Docs: https://strale.dev

Script strale Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
// Execute a specific Strale capability by slug.
4
// Calls a single quality-tested data capability and returns structured results
5
// with provenance, audit trail, and quality metadata.
6
//
7
// Strale is the data layer for AI agents — every data source independently
8
// quality-tested, scored, and audit-logged. https://strale.dev
9

10
type Strale = {
11
  api_key: string;
12
  base_url?: string;
13
};
14

15
export async function main(
16
  strale: Strale,
17
  capability_slug: string,
18
  inputs: Record<string, unknown>,
19
  dry_run: boolean = false,
20
) {
21
  const baseUrl = strale.base_url ?? "https://api.strale.io";
22

23
  const body: Record<string, unknown> = {
24
    capability_slug,
25
    inputs,
26
  };
27
  if (dry_run) {
28
    body.dry_run = true;
29
  }
30

31
  const response = await fetch(`${baseUrl}/v1/do`, {
32
    method: "POST",
33
    headers: {
34
      "Authorization": `Bearer ${strale.api_key}`,
35
      "Content-Type": "application/json",
36
    },
37
    body: JSON.stringify(body),
38
  });
39

40
  if (!response.ok) {
41
    const error = await response.json().catch(() => ({ message: response.statusText }));
42
    throw new Error(
43
      `Strale API error (${response.status}): ${(error as any).error?.message ?? (error as any).message ?? "Unknown error"}`
44
    );
45
  }
46

47
  const data = await response.json() as {
48
    transaction_id?: string;
49
    capability_slug: string;
50
    status: string;
51
    output?: Record<string, unknown>;
52
    provenance?: Record<string, unknown>;
53
    quality?: Record<string, unknown>;
54
    cost_cents?: number;
55
    wallet_balance_cents?: number;
56
    dry_run?: boolean;
57
  };
58

59
  return {
60
    transaction_id: data.transaction_id,
61
    capability: data.capability_slug,
62
    status: data.status,
63
    output: data.output,
64
    provenance: data.provenance,
65
    quality: data.quality,
66
    cost: data.cost_cents != null ? `€${(data.cost_cents / 100).toFixed(2)}` : undefined,
67
    wallet_balance_cents: data.wallet_balance_cents,
68
    dry_run: data.dry_run,
69
  };
70
}
Other submissions
  • Submitted by petter133 Deno
    Created 56 days ago
    1
    // Execute a specific Strale capability by slug.
    2
    // Calls a single quality-tested data capability and returns structured results
    3
    // with provenance, audit trail, and quality metadata.
    4
    //
    5
    // Strale is the data layer for AI agents — every data source independently
    6
    // quality-tested, scored, and audit-logged. https://strale.dev
    7
    
    
    8
    type Strale = {
    9
      api_key: string;
    10
      base_url?: string;
    11
    };
    12
    
    
    13
    export async function main(
    14
      strale: Strale,
    15
      capability_slug: string,
    16
      inputs: Record<string, unknown>,
    17
      dry_run: boolean = false,
    18
    ) {
    19
      const baseUrl = strale.base_url ?? "https://api.strale.io";
    20
    
    
    21
      const body: Record<string, unknown> = {
    22
        capability_slug,
    23
        inputs,
    24
      };
    25
      if (dry_run) {
    26
        body.dry_run = true;
    27
      }
    28
    
    
    29
      const response = await fetch(`${baseUrl}/v1/do`, {
    30
        method: "POST",
    31
        headers: {
    32
          "Authorization": `Bearer ${strale.api_key}`,
    33
          "Content-Type": "application/json",
    34
        },
    35
        body: JSON.stringify(body),
    36
      });
    37
    
    
    38
      if (!response.ok) {
    39
        const error = await response.json().catch(() => ({ message: response.statusText }));
    40
        throw new Error(
    41
          `Strale API error (${response.status}): ${(error as any).error?.message ?? (error as any).message ?? "Unknown error"}`
    42
        );
    43
      }
    44
    
    
    45
      const data = await response.json() as {
    46
        transaction_id?: string;
    47
        capability_slug: string;
    48
        status: string;
    49
        output?: Record<string, unknown>;
    50
        provenance?: Record<string, unknown>;
    51
        quality?: Record<string, unknown>;
    52
        cost_cents?: number;
    53
        wallet_balance_cents?: number;
    54
        dry_run?: boolean;
    55
      };
    56
    
    
    57
      return {
    58
        transaction_id: data.transaction_id,
    59
        capability: data.capability_slug,
    60
        status: data.status,
    61
        output: data.output,
    62
        provenance: data.provenance,
    63
        quality: data.quality,
    64
        cost: data.cost_cents != null ? `€${(data.cost_cents / 100).toFixed(2)}` : undefined,
    65
        wallet_balance_cents: data.wallet_balance_cents,
    66
        dry_run: data.dry_run,
    67
      };
    68
    }