Documentazione API

Tutte le API rispondono in JSON UTF-8. Autenticazione via X-API-Key oppure Authorization: Bearer <api_key>.

Base URL: https://tapy.cc

POST /api/v1/qrcodes

Abilita la generazione dei QR code per uno specifico short_code o ne aggiorna le impostazioni.

Body JSON

{"short_code":"Ab3xK9q"}

Regola piano: su piano Free il campo custom_code viene ignorato e il sistema genera automaticamente uno short code casuale.

Risposta 201

{"short_code":"Ab3xK9q","has_qr":1,"message":"QR Code abilitato per il link selezionato."}

GET /api/v1/qrcodes

Recupera la lista di tutti gli short link per i quali è stato attivato un QR code.

Risposta 200

{"data":[{"short_code":"abc123","destination_url":"https://example.com","title":"Landing","has_qr":1}]}

Errori standard

  • 401 API key mancante o non valida
  • 403 Limite del piano mensile per la creazione dei QR Code superato.
  • 404 Link non trovato
  • 409 Short code già in uso / limite piano raggiunto
  • 422 URL non valido

Info

Il rendering visuale del QR (immagini, colori) deve attualmente essere generato tramite l'interfaccia web o librerie client. L'API tiene traccia dei link a cui è stato associato il QR tramite il flag `has_qr: 1` e il calcolo dei limiti attivi del tuo account.

PHP smoke example

Esempio completo in stile smoke-test per gli endpoint QR Codes (inserisci la tua API key nel placeholder).

<?php

declare(strict_types=1);

$baseUrl = 'https://tapy.cc';
$apiKey = 'YOUR_API_KEY'; // replace with your key

function request_json(string $method, string $url, string $apiKey, ?array $payload = null): array
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);

    $headers = [
        'Accept: application/json',
        'X-API-Key: ' . $apiKey,
    ];

    if ($payload !== null) {
        $headers[] = 'Content-Type: application/json';
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_SLASHES));
    }

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $raw = curl_exec($ch);
    $status = (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
    curl_close($ch);

    return [$status, json_decode((string) $raw, true) ?: ['raw' => $raw]];
}

// Step 1 – Create a short link first
[$createStatus, $createBody] = request_json('POST', $baseUrl . '/api/v1/shorten', $apiKey, [
    'url' => 'https://example.com',
    'title' => 'QR Demo',
]);
echo "POST /api/v1/shorten => HTTP {$createStatus}\n";
print_r($createBody);

$code = (string) $createBody['short_code'];

// Step 2 – Enable QR code for this link
[$qrStatus, $qrBody] = request_json('POST', $baseUrl . '/api/v1/qrcodes', $apiKey, [
    'short_code' => $code,
]);
echo "POST /api/v1/qrcodes => HTTP {$qrStatus}\n";
print_r($qrBody);

// Step 3 – List all QR-enabled links
[$listStatus, $listBody] = request_json('GET', $baseUrl . '/api/v1/qrcodes', $apiKey);
echo "GET /api/v1/qrcodes => HTTP {$listStatus}\n";
print_r($listBody);

Output atteso

Esempio indicativo di output CLI quando la sequenza API va a buon fine.

POST /api/v1/shorten => HTTP 201
Array
(
    [short_code] => Ab3xK9q
    [short_url] => https://tapy.cc/Ab3xK9q
    [destination_url] => https://example.com
)

POST /api/v1/qrcodes => HTTP 201
Array
(
    [short_code] => Ab3xK9q
    [has_qr] => 1
    [message] => QR Code abilitato per il link selezionato.
)

GET /api/v1/qrcodes => HTTP 200
Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [short_code] => Ab3xK9q
                    [destination_url] => https://example.com
                    [title] => QR Demo
                    [has_qr] => 1
                )
        )
)