Ca dezvoltator, nu vrei să creezi coduri QR manual printr-un dashboard — vrei să le generezi automat, să le integrezi în pipeline-ul de build și să reacționezi la scanări prin webhook-uri. Exact pentru asta a fost creat qr3.app.
Stack-ul
qr3.app este complet nativ pe Cloudflare:
- API Worker: Hono pe Cloudflare Workers (runtime V8, zero dependențe de Node.js)
- Redirect Worker: worker ultra-eficient, redirecționări cache-uite în KV în < 5 ms p50
- Bază de date: Cloudflare D1 (SQLite) cu multi-tenancy prin
workspace_id - Coadă: evenimentele de scanare sunt decuplate prin Cloudflare Queues
Autentificare
Toate cererile către API necesită un token Bearer și un workspace ID:
POST https://qr3.app/v1/codes
Authorization: Bearer qr3_sk_...
Content-Type: application/json
Creează chei API la app.qr3.app/dashboard/api-keys.
SDK TypeScript
npm install @qr3/sdk
# sau
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
API REST direct
Nu vrei o dependență de SDK? API-ul REST poate fi folosit direct:
# 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"
# Download QR code as SVG (with logo overlay)
curl "https://qr3.app/v1/codes/r7f3Kx/qr.svg?size=8&logo_url=https://mylogo.com/logo.png" \
-o qrcode.svg
CLI
Pentru scripting și CI/CD există @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-uri: reacționează la scanări
Webhook-urile sunt funcționalitatea cea mai puternică: poți reacționa în timp real la fiecare scanare.
// Register a webhook
const { data: webhook } = await client.webhooks.create({
url: "https://your-app.com/webhooks/qr3",
events: ["scan.created", "code.updated"],
});
Payload-ul webhook-ului
{
"event": "scan.created",
"timestamp": "2026-03-15T14:30:00Z",
"data": {
"code_id": "code_abc123",
"short_code": "r7f3Kx",
"country": "DE",
"city": "Berlin",
"device": "mobile",
"os": "iOS",
"browser": "Safari"
}
}
Verifică webhook-urile (HMAC)
import { createHmac } from "crypto";
export async function verifyWebhook(
payload: string,
signature: string,
secret: string,
): Promise<boolean> {
const expected = createHmac("sha256", secret)
.update(payload)
.digest("hex");
return `sha256=${expected}` === signature;
}
Limitarea ratei (rate limiting)
| Plan | Coduri/zi | Cereri API/min |
|---|---|---|
| Free | 10 | 60 |
| Pro | 100 | 300 |
| Business | 1.000 | 1.200 |
| Enterprise | Nelimitat | Personalizat |
Anteturi de rate limit în fiecare răspuns:
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 247
X-RateLimit-Reset: 1710510060
Formatul erorilor (RFC 7807)
Toate erorile respectă RFC 7807 Problem Details:
{
"type": "https://docs.qr3.app/errors/validation",
"title": "Validation Error",
"status": 422,
"detail": "url is required for type 'url'",
"errors": [
{ "field": "url", "message": "Required" }
]
}
Concluzie
qr3.app este construit din temelii ca instrument pentru dezvoltatori: API REST deschis, SDK orientat spre TypeScript, CLI, webhook-uri și documentație OpenAPI completă. Consultă documentația API sau pornește din Dashboard.