Examples

Common patterns you'll likely need beyond a single request — see each endpoint's own page for its full example set in 7 languages.

Handling every error uniformly

async function callPaqet(url) {
    const response = await fetch(url, {
        headers: { Authorization: `Bearer ${process.env.PAQET_API_KEY}` }
    });

    const body = await response.json();

    if (!body.success) {
        switch (body.code) {
            case "RATE_LIMIT_EXCEEDED":
                // back off and retry using X-RateLimit-Reset
                break;
            case "SCOPE_REQUIRED":
            case "API_KEY_INVALID":
            case "API_KEY_REVOKED":
            case "API_KEY_EXPIRED":
                // configuration problem — fix the key, don't retry
                throw new Error(`Paqet auth error: ${body.code}`);
            default:
                throw new Error(body.message);
        }
    }

    return body.data;
}

Running every DNS record type at once

curl "https://api.paqet.net/v1/dns/lookup?domain=example.com&type=All" \
  -H "Authorization: Bearer pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Chaining a domain health check

A typical "is this domain healthy" flow combines a few endpoints:

const [dns, ssl, blacklist] = await Promise.all([
    callPaqet(`https://api.paqet.net/v1/dns/lookup?domain=${domain}&type=ARecord`),
    callPaqet(`https://api.paqet.net/v1/ssl?domain=${domain}`),
    callPaqet(`https://api.paqet.net/v1/blacklist?domain=${domain}`)
]);

Reading remaining quota without spending a request

Rate limit headers are attached to every real API response — there's no separate "check my quota" endpoint on the Public API itself. To see current standing without making a diagnostic call, use Rate Limits in the Developer Portal, which reads the same counters without incrementing them.

Want to run these live?

The Playground executes real requests using your own API key.

Open Playground