---
title: "QR code per sviluppatori: REST API, SDK e CLI — qr3.app Blog"
description: "Come generare QR code in modo programmatico, integrarli nella tua app e reagire alle scansioni tramite webhook: un approfondimento tecnico."
canonical: "https://qr3.app/it/blog/qr-codes-for-developers/"
lang: "it"
robots: "index,follow,max-image-preview:large,max-snippet:-1"
---

# QR code per sviluppatori: REST API, SDK e CLI — qr3.app Blog

> Come generare QR code in modo programmatico, integrarli nella tua app e reagire alle scansioni tramite webhook: un approfondimento tecnico.

Canonical: <https://qr3.app/it/blog/qr-codes-for-developers/>

[← Blog](/it/blog/) [Tutorials](/it/blog/category/tutorials/)

8 marzo 2026 8 min di lettura [Tutorials](/it/blog/category/tutorials/) [API](/it/blog/tag/API/)[SDK](/it/blog/tag/SDK/)[Developer](/it/blog/tag/Developer/)[Webhooks](/it/blog/tag/Webhooks/)

# QR code per sviluppatori: REST API, SDK e CLI

Come generare QR code in modo programmatico, integrarli nella tua app e reagire alle scansioni tramite webhook: un approfondimento tecnico.

di **qr3.app Team**

![QR code per sviluppatori: REST API, SDK e CLI](https://qr3-blog-agent.meistern.workers.dev/cdn/blog/qr-codes-for-developers/hero.png)

Da sviluppatore non vuoi creare QR code manualmente da una dashboard: vuoi generarli automaticamente, integrarli nella tua pipeline di build e reagire alle scansioni tramite webhook. È esattamente per questo che è nato qr3.app.

## Lo stack

qr3.app è interamente nativo su Cloudflare:

- **API Worker**: Hono su Cloudflare Workers (runtime V8, zero dipendenze da Node.js)

- **Redirect Worker**: worker ultra-leggero, redirect in cache su KV in < 5 ms p50

- **Database**: Cloudflare D1 (SQLite) con multi-tenancy tramite `workspace_id`

- **Queue**: eventi di scansione disaccoppiati tramite Cloudflare Queues

## Autenticazione

Tutte le richieste API richiedono un Bearer token e un ID del workspace:

```
POST https://qr3.app/v1/codes
Authorization: Bearer qr3_sk_...
Content-Type: application/json
```

Crea le tue API key su [app.qr3.app/dashboard/api-keys](https://app.qr3.app/dashboard/api-keys).

## SDK TypeScript

```
npm install @qr3/sdk
# oppure
pnpm add @qr3/sdk
```

```
import { QR3 } from "@qr3/sdk";

const client = new QR3({
  apiKey: process.env.QR3_API_KEY!,
  workspaceId: process.env.QR3_WORKSPACE_ID!,
});

// Create a QR code
const { data: code } = await client.codes.create({
  type: "url",
  url: "https://my-shop.com/product/42",
  title: "Product 42",
  tags: ["shop", "product"],
});

console.log(code.short_code);       // "r7f3Kx"
console.log(code.image_svg_url);    // SVG image URL
console.log(code.redirect_url);     // https://qr3.app/r7f3Kx

// Change URL later (dynamic codes only)
await client.codes.update(code.id, {
  url: "https://my-shop.com/product/42-new",
});

// Query analytics
const stats = await client.codes.stats(code.id, {
  from: "2026-01-01",
  to: "2026-03-31",
});
console.log(stats.data.total_scans); // e.g. 1247
```

## REST API diretta

Nessuna dipendenza dall'SDK? La REST API è utilizzabile direttamente:

```
# Create a QR code
curl -X POST https://qr3.app/v1/codes \
  -H "Authorization: Bearer $QR3_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "url",
    "url": "https://my-site.com",
    "title": "My Site",
    "is_dynamic": true
  }'

# List all QR codes
curl https://qr3.app/v1/codes?limit=20 \
  -H "Authorization: Bearer $QR3_API_KEY"

# Upload a logo — embedded automatically in SVG and PNG from here on
curl -X POST https://qr3.app/v1/codes/qr_abc123/logo \
  -H "Authorization: Bearer $QR3_API_KEY" \
  -F "file=@logo.png"

# Download QR code as SVG (now includes the logo)
curl "https://qr3.app/v1/codes/r7f3Kx/qr.svg?size=8" \
  -o qrcode.svg
```

## CLI

Per lo scripting e per il CI/CD c'è la `@qr3/cli`:

```
npm install -g @qr3/cli
qr3 login

# Create QR code and save as SVG
qr3 codes create --url "https://my-site.com" --title "CI Deploy" --output qr.svg

# Batch creation from CSV
qr3 codes batch import urls.csv --format svg --output ./qr-codes/
```

## Webhook: reagisci alle scansioni

I webhook sono la funzionalità più potente: ti permettono di reagire in tempo reale a ogni singola scansione.

```
// Register a webhook
const { data: webhook } = await client.webhooks.create({
  url: "https://your-app.com/webhooks/qr3",
  events: ["qr.scanned", "qr.updated"],
});
```

### Payload del webhook

```
{
  "id": "evt_4f0c2a91d7e84b3c9a1f",
  "type": "qr.scanned",
  "created": "2026-03-15T14:30:00.000Z",
  "data": {
    "code_id": "qr_abc123",
    "short_code": "r7f3Kx",
    "scanned_at": "2026-03-15T14:30:00.000Z",
    "country": "DE",
    "device_type": "mobile",
    "os": "iOS",
    "browser": "Safari",
    "language": "de",
    "ab_variant": null,
    "redirected_to": "https://example.com/landing"
  }
}
```

### Verifica dei webhook (HMAC)

```
import { createHmac, timingSafeEqual } from "crypto";

export async function verifyWebhook(
  payload: string,
  signature: string,
  secret: string,
): Promise<boolean> {
  const expected = createHmac("sha256", secret)
    .update(payload)
    .digest("hex");
  const expectedBytes = Buffer.from(`sha256=${expected}`);
  const receivedBytes = Buffer.from(signature);
  return (
    expectedBytes.length === receivedBytes.length &&
    timingSafeEqual(expectedBytes, receivedBytes)
  );
}
```

## Rate limiting

Ogni chiave API può inviare 60 richieste al minuto, per qualsiasi piano. La creazione dei codici prevede inoltre un limite giornaliero per workspace, anch'esso uguale per tutti i piani: `POST /v1/codes` accetta nuovi codici fino a quando non ne sono stati creati 200 in quel giorno, `POST /v1/codes/batch` fino a 10.000.

Ogni risposta autenticata contiene `X-RateLimit-Limit`. Una risposta `429` indica inoltre quando riprovare:

```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1710510060
Retry-After: 60
```

## Formato degli errori (RFC 7807)

Tutti gli errori seguono lo standard [RFC 7807 Problem Details](https://www.rfc-editor.org/rfc/rfc7807):

```
{
  "type": "https://docs.qr3.app/errors/validation",
  "title": "Validation Error",
  "status": 422,
  "detail": "url is required for type 'url'",
  "errors": [
    { "field": "url", "message": "Required" }
  ]
}
```

## Conclusione

qr3.app è stato progettato fin dalle fondamenta come strumento per sviluppatori: REST API aperta, SDK TypeScript-first, CLI, webhook e documentazione OpenAPI completa. Dai un'occhiata alla [documentazione API](https://docs.qr3.app/en/api/) oppure inizia subito dalla [Dashboard](https://app.qr3.app/dashboard).

[← Tutti gli articoli](/it/blog/) [Inizia gratis](https://app.qr3.app/sign-up)
