> ## Documentation Index
> Fetch the complete documentation index at: https://shinydapps-bd9fa40b.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Esempi VERITY

> Esempi di codice per tutti i 10 servizi VERITY usando L402Client.

# Esempi VERITY

VERITY è un agente autonomo attivo su `https://l402kit.com/api/verity`. Questi esempi mostrano come chiamare tutti i 10 servizi in modo programmatico usando l'SDK agente di l402-kit.

***

## Configurazione

```typescript theme={null}
import { L402Client } from "l402-kit/agent";
import { BlinkWallet } from "l402-kit/wallets";

const client = new L402Client({
  wallet: new BlinkWallet(process.env.BLINK_API_KEY!),
  budget: { maxSats: 5000 }, // hard cap per session
});
```

***

## Scopri tutti i servizi e i prezzi attuali

```typescript theme={null}
const res = await fetch("https://l402kit.com/api/verity/services");
const { services } = await res.json();

for (const svc of services) {
  console.log(`${svc.id}: ${svc.price_sats} sats (floor: ${svc.floor_sats})`);
}
```

***

## Controlla il report fiscale giornaliero

```typescript theme={null}
// Public — no payment required
const res = await fetch("https://l402kit.com/api/verity/fiscal");
const report = await res.json();

console.log(`Revenue: ${report.revenue_sats} sats (~${report.usd_equivalent})`);
console.log(`Net: ${report.net_sats} sats (${report.margin_pct}% margin)`);

for (const [service, data] of Object.entries(report.breakdown)) {
  console.log(`  ${service}: ${data.calls} calls × ${data.price} sats = ${data.revenue} sats`);
}
```

***

## Stato del Mondo — 80 sats

Ottieni l'ora UTC, la tua posizione e il meteo locale in un'unica chiamata.

```typescript theme={null}
const res = await client.fetch("https://l402kit.com/api/verity/worldstate");
const { time, location, weather } = await res.json();

console.log(`Time: ${time.utc}`);
console.log(`Location: ${location.city}, ${location.country}`);
console.log(`Weather: ${weather.temperature_c}°C, ${weather.condition}`);
```

***

## Prezzo BTC — 10 sats

```typescript theme={null}
const res = await client.fetch("https://l402kit.com/api/verity/btc-price");
const { bitcoin } = await res.json();

console.log(`BTC: $${bitcoin.usd} USD | R$${bitcoin.brl} BRL`);
```

***

## Ricerca Web — 100 sats

```typescript theme={null}
const res = await client.fetch(
  "https://l402kit.com/api/verity/search?q=bitcoin+lightning+l402",
);
const { results } = await res.json();

for (const r of results) {
  console.log(`${r.title}\n${r.link}\n${r.snippet}\n`);
}
```

***

## Riassumi — 50 sats

```typescript theme={null}
const longText = "..."; // fino a 50.000 caratteri

const res = await client.fetch("https://l402kit.com/api/verity/summarize", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: longText, language: "english" }),
});
const { summary } = await res.json();
console.log(summary);
```

***

## Sentiment — 30 sats

```typescript theme={null}
const res = await client.fetch("https://l402kit.com/api/verity/sentiment", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: "Lightning payments are instant and cheap!" }),
});
const { analysis } = await res.json();
// { sentiment: "positive", score: 0.94, confidence: 0.91, keywords: [...] }
```

***

## Domain Intel — 500 sats

```typescript theme={null}
const res = await client.fetch(
  "https://l402kit.com/api/verity/domain-intel?domain=bitcoin.org",
);
const { whois, dns, certificates } = await res.json();

console.log(`Registered: ${whois.registered}`);
console.log(`Expires: ${whois.expires}`);
console.log(`A records: ${dns.a_records.join(", ")}`);
```

***

## Web Scraping — 200 sats

```typescript theme={null}
const res = await client.fetch("https://l402kit.com/api/verity/scrape", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://bitcoin.org/en/bitcoin-paper" }),
});
const { content, title } = await res.json();
console.log(`${title}\n\n${content.slice(0, 500)}...`);
```

***

## Traduci — 50 sats

Traduci qualsiasi testo in 11 lingue. La modalità MDX-aware preserva i blocchi di codice, i tag dei componenti, gli URL e la terminologia L402.

```typescript theme={null}
// Testo semplice
const res = await client.fetch("https://l402kit.com/api/verity/translate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    text: "Pay per call with Bitcoin Lightning. No API keys needed.",
    locale: "pt",
  }),
});
const { translated } = await res.json();
console.log(translated);
// "Pague por chamada com Bitcoin Lightning. Nenhuma chave de API necessária."
```

```typescript theme={null}
// MDX-aware (preserva blocchi di codice, <Components />, URL)
const mdxPage = `## Install\n\`\`\`bash\nnpm install l402-kit\n\`\`\`\nSee [docs](https://docs.l402kit.com).`;

const res = await client.fetch("https://l402kit.com/api/verity/translate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: mdxPage, locale: "es", format: "mdx" }),
});
const { translated } = await res.json();
// Il blocco di codice e l'URL vengono preservati intatti; viene tradotto solo il testo
```

Lingue supportate: `pt` `es` `zh` `ar` `fr` `de` `ja` `ko` `hi` `ru` `it`

***

## Integrazione l402-kit — 10.000 sats

Invia a VERITY un repository GitHub pubblico. Lei legge il codice e restituisce un'integrazione l402-kit completa.

```typescript theme={null}
const res = await client.fetch("https://l402kit.com/api/verity/integration", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ repoUrl: "https://github.com/owner/my-api" }),
});
const { integration, next_steps } = await res.json();

// integration = markdown con il codice esatto da aggiungere al tuo repository
console.log(integration);
```

<Note>
  Il servizio di integrazione costa 10.000 sats (\~\$10). Dopo il pagamento, ricevi il codice middleware completo specifico per il tuo framework (Express, FastAPI, Gin, Axum, ecc.) — e VERITY ottiene il primo referral alla tua nuova API potenziata da l402-kit.
</Note>

***

## Concatenare i servizi

Un pattern comune per agenti: ricerca → scraping → riassunto.

```typescript theme={null}
// 1. Cerca un argomento (100 sats)
const searchRes = await client.fetch(
  "https://l402kit.com/api/verity/search?q=bitcoin+lightning+adoption+2026",
);
const { results } = await searchRes.json();
const topUrl = results[0].link;

// 2. Esegui lo scraping del primo risultato (200 sats)
const scrapeRes = await client.fetch("https://l402kit.com/api/verity/scrape", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: topUrl }),
});
const { content } = await scrapeRes.json();

// 3. Riassumi l'articolo (50 sats)
const sumRes = await client.fetch("https://l402kit.com/api/verity/summarize", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: content }),
});
const { summary } = await sumRes.json();

// Costo totale: 350 sats (~$0.35)
console.log(summary);
```

***

## Python

```python theme={null}
from l402kit import L402Client, BlinkWallet
import os

client = L402Client(
    wallet=BlinkWallet(os.environ["BLINK_API_KEY"]),
    budget={"max_sats": 5000},
)

# Stato del mondo
resp = client.get("https://l402kit.com/api/verity/worldstate")
data = resp.json()
print(f"{data['time']['utc']} | {data['location']['city']} | {data['weather']['temperature_c']}°C")
```
