How to Get the IAB Category for a Website in PHP

November 05, 2026
How to Get the IAB Category for a Website in PHP

You need to determine the IAB category for a website so your PHP app can block certain topics, enrich signups, or audit where your ads appear. By the end of this walkthrough, you’ll be able to call the Klazify API to get IAB taxonomy data for any domain, parse the response to extract the IAB IDs and names, and plug the result into your PHP pipeline with caching and error handling.

Why Klazify is the right fit for IAB classification in a PHP workflow

When your PHP service needs to decide whether to block a category, enrich a record, or label a partner domain at scale, the data must be accurate, fresh, and simple to integrate. Klazify provides:

Illustration: How to Get the IAB Category for a Website in PHP
  • Accurate Website Categorization Using AI: It analyzes real page content, which helps identify niche topics relevant to ad safety and policy enforcement in your PHP services.
  • Global Coverage: It supports multiple languages, which is essential if your app evaluates international domains.
  • Real-Time Classification: It performs live analysis rather than relying solely on static lists, which reduces stale-category decisions.
  • Industry-Level Categories: It maps to the IAB taxonomy, which lets you enforce advertising and brand-safety rules with standardized, granular categories.
  • Simple API Integration: A developer-friendly REST interface that’s straightforward to call from PHP and aligns with common backend patterns.
  • Superior Compliance and Filtering: Easy to implement allow/deny logic at the IAB category level, which is ideal for ad placements, parental controls, and enterprise filtering.

What the IAB fields look like in the response

Klazify returns a categories array where each category includes:

  • A human-readable category path in the name field.
  • One or more IAB fields as sibling keys on the same category object, e.g., keys like IAB12 or IAB-324-JLBCU7. There’s no separate IAB_categories object.
  • A confidence score you can use to prioritize or threshold decisions.

In practice, you’ll read categories[i].name, categories[i].confidence, and any keys in categories[i] that start with IAB to retrieve the standardized IAB taxonomy tag(s).

Quickstart: Request the IAB category with a single API call

To request IAB categories for a domain, use the domain_iab_categories endpoint. This example posts a JSON body with a URL and uses Bearer authentication. Failed or unreachable calls are not billed.

curl -X POST "https://www.klazify.com/api/domain_iab_categories" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://cbsnews.com"}'

Notes:

  • Replace YOUR_API_KEY with the key from your account.
  • Send a fully qualified URL or domain in the url field.
  • If the domain is new or the site is temporarily unreachable, handle the response gracefully and cache a fallback decision if applicable. Failed/unreachable calls are not billed.

If you don’t have an account yet, you can sign up for the Starter plan ($39.99/mo with a 7-day trial) and get your key here: Register. You can also explore the API surface here: Documentation.

PHP implementation: extract the IAB IDs and names

The snippet below demonstrates how to submit the domain, parse the categories array, and collect all IAB keys co-located on each category object. It also shows how to implement a basic in-memory cache per domain to reduce latency and calls.

<?php
function getIabCategories($domainUrl, $apiKey) {
    static $cache = [];

    if (isset($cache[$domainUrl])) {
        return $cache[$domainUrl];
    }

    $ch = curl_init("https://www.klazify.com/api/domain_iab_categories");
    $payload = json_encode(["url" => $domainUrl]);

    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . $apiKey,
            "Content-Type: application/json"
        ],
        CURLOPT_POSTFIELDS => $payload,
        CURLOPT_TIMEOUT => 10
    ]);

    $resp = curl_exec($ch);
    $err  = curl_error($ch);
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($err) {
        // Network error. Not billed; decide on fallback.
        return ["error" => "network_error", "detail" => $err];
    }

    if ($code < 200 || $code >= 300) {
        // API rejected request; log and fallback.
        return ["error" => "http_" . $code, "detail" => $resp];
    }

    $data = json_decode($resp, true);
    if (!is_array($data)) {
        return ["error" => "invalid_json", "detail" => $resp];
    }

    // Collect categories and any sibling IAB keys
    $result = [];
    if (isset($data["domain"]["categories"]) && is_array($data["domain"]["categories"])) {
        foreach ($data["domain"]["categories"] as $cat) {
            $entry = [
                "name" => $cat["name"] ?? null,
                "confidence" => $cat["confidence"] ?? null,
                "iab" => []
            ];
            foreach ($cat as $k => $v) {
                if (strpos($k, "IAB") === 0) {
                    $entry["iab"][$k] = $v;
                }
            }
            $result[] = $entry;
        }
    }

    // Cache per domain to save calls in the same process
    $cache[$domainUrl] = $result;
    return $result;
}

// Example usage
$apiKey = "YOUR_API_KEY";
$domain = "https://cbsnews.com";
$iabs   = getIabCategories($domain, $apiKey);

foreach ($iabs as $row) {
    echo "Category: " . ($row["name"] ?? "n/a") . PHP_EOL;
    echo "Confidence: " . ($row["confidence"] ?? "n/a") . PHP_EOL;
    foreach ($row["iab"] as $code => $value) {
        echo " - $code: $value" . PHP_EOL;
    }
    echo PHP_EOL;
}

What this gives you:

  • A list of categories for the domain, including the human-readable path (name).
  • All IAB keys and values found on each category object, ready to store to your DB or use in allow/deny rules.
  • A simple in-process cache to avoid repeated lookups during a single request lifecycle or worker execution.

Official example JSON format and how to interpret it

Below is the official example of a categorization payload. The categories array is the part you’ll parse for IAB IDs; they appear as additional keys on the same object as name and confidence. Use this pattern for IAB extraction in your PHP code.


{
    "domain": {
        "categories": [
            {
                "confidence": 0.92,
                "name": "/Computers & Electronics/Consumer Electronics",
                "IAB-632-596": "Consumer Electronics/Technology & Computing/Consumer Electronics"
            },
            {
                "confidence": 0.89,
                "name": "/Internet & Telecom/Mobile & Wireless/Mobile Phones"
            }
        ],
        "social_media": null,
        "logo_url": "https://klazify.s3.amazonaws.com/2110787991611585019600ed5fb1d1300.04730104.png"
    },
    "success": true,
    "objects": {
        "company": {
            "url": "https://www.apple.com/",
            "name": "Apple",
            "city": "Cupertino",
            "stateCode": "CA",
            "countryCode": "US",
            "employeesRange": "100K+",
            "revenue": 274515000000,
            "raised": null,
            "tags": [
                "E-commerce",
                "Consumer Electronics",
                "Mobile",
                "B2C"
            ],
            "tech": [
                "omniture_adobe_analytics",
                "atlassian_confluence",
                "successfactors",
                "apache_apex",
                "talend",
                "oracle_peoplesoft",
                "salesforce",
                "stripe",
                "dell_boomi_atomsphere",
                "gigya",
                "sage_50cloud",
                "quickbooks",
                "webmethods",
                "apache_tomcat",
                "alteryx",
                "tibco_rendezvous",
                "atlassian_jira",
                "..."
            ]
        }
    },
    "domain_registration_data": {
        "domain_age_date": "1987-02-19",
        "domain_age_days_ago": "13026",
        "domain_expiration_date": "2030-02-20",
        "domain_expiration_days_left": "123"
    },
    "similar_domains": [
        "bestbuy.com",
        "icloud.com",
        "microsoft.com",
        "macrumors.com",
        "google.com",
        "samsung.com",
        "twitter.com",
        "hp.com",
        "bhphotovideo.com",
        "dell.com"
    ]
}

Key fields you’ll use:

  • domain.categories[].name: Human-readable category path.
  • domain.categories[].confidence: Use this to threshold inclusion/exclusion.
  • domain.categories[] IAB fields: Any key that starts with IAB identifies the IAB mapping for that category. The value is a standardized taxonomy path.
  • domain.logo_url: Useful if you also want to show the site’s logo in your UI during manual reviews.

JavaScript example: fetch and extract IAB fields

If you maintain supporting tooling in Node.js for QA or batch scripts, here’s how to call the same endpoint and extract IAB fields:

import fetch from "node-fetch";

async function fetchIab(domainUrl, apiKey) {
  const res = await fetch("https://www.klazify.com/api/domain_iab_categories", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ url: domainUrl }),
    // Consider a short timeout/retry in production
  });

  if (!res.ok) {
    // Not billed on failed/unreachable; log and fallback
    const text = await res.text();
    throw new Error(`HTTP ${res.status}: ${text}`);
  }

  const data = await res.json();
  const out = [];

  if (data?.domain?.categories?.length) {
    for (const cat of data.domain.categories) {
      const entry = {
        name: cat.name ?? null,
        confidence: cat.confidence ?? null,
        iab: {}
      };
      for (const k of Object.keys(cat)) {
        if (k.startsWith("IAB")) {
          entry.iab[k] = cat[k];
        }
      }
      out.push(entry);
    }
  }

  return out;
}

// Example run
fetchIab("https://cbsnews.com", "YOUR_API_KEY")
  .then(rows => {
    for (const r of rows) {
      console.log("Category:", r.name);
      console.log("Confidence:", r.confidence);
      for (const [code, value] of Object.entries(r.iab)) {
        console.log(` - ${code}: ${value}`);
      }
      console.log();
    }
  })
  .catch(err => console.error(err));

How to act on the result: block, enrich, or audit

Once you have the list of categories plus IAB fields, you can:

  • Block or Allow: Compare each IAB code/path against your policy list and short-circuit your PHP handler with an allow/deny decision.
  • Enrich: Attach the IAB value(s) to a lead, publisher, or partner in your database for downstream segmentation.
  • Audit: Log the domain, selected IAB code, and confidence. Trigger human review if the confidence dips below your threshold.

Mapping to your own taxonomy typically involves a lookup table from IAB code/path to your internal enum. Since IAB fields are sibling keys in the same category object, your mapper can iterate all IAB keys present and pick the one you prefer (e.g., prioritize a specific code pattern your governance team selected).

Operational guidance: throughput, batching, caching, and unknowns

  • Batching: If you classify many domains per job, run calls in parallel with conservative concurrency. Space requests over time to avoid bursts.
  • Caching: Cache results at the domain level in your datastore. A TTL between hours and a few days balances freshness and cost. Recheck only when needed.
  • Handling Unknown or New Domains: If the site is new or unreachable, store a “pending” status and retry later. Failed or unreachable calls are not billed, but your pipeline should still progress with a default decision.
  • Idempotency: Deduplicate requests in your queue so a single domain isn’t requested multiple times simultaneously.
  • Confidence Thresholds: For safety-critical decisions, require a minimum confidence before applying a strict block. Otherwise, route to a manual review queue.
  • Observability: Log request timing and category outcomes. Track latency and error rate to scale workers as needed.

Integrating with your taxonomy and policy engine

You typically need to translate IAB fields into your internal categories and policies. Because Klazify exposes IAB data as sibling keys on each category object, you can:

  • Scan each category for any keys that start with IAB and read the standardized path.
  • Resolve multiple IAB values by rank-order rules (e.g., pick the most granular or the first matching policy).
  • Store both the human-readable name and the IAB path to make your admin UI more interpretable.

Choosing an implementation path

Below is a quick comparison of common approaches to plug IAB classification into your PHP service:

Approach When to Use Pros Trade-offs
On-demand lookup per request Low volume, strict freshness Always up-to-date, simple logic Higher latency and API usage without caching
Background batch enrichment High-volume imports or scheduled audits Cost-effective, controllable throughput Not real-time; requires a job system
Hybrid with cache-first Most production pipelines Fast responses, balanced cost/freshness Cache invalidation and TTL management

Additional data you can use alongside IAB

If you call the general categorization features, you can also retrieve:

  • Logo URLs to display context in admin tools.
  • Company data fields including name, location, and tags for enrichment and review.
  • Domain registration data and similar domains for QA or clustering.

Refer to the Documentation for details about fields and supported capabilities, and explore related content and models in the MCP.

Production tips that save time

  • Normalize Domains: Lowercase, strip protocol and trailing slashes before caching keys.
  • Retry Policy: Use short retry windows for transient connectivity issues. Since failed/unreachable calls are not billed, a safe backoff is fine.
  • Versioning: Keep a snapshot of your IAB-to-internal mapping. Changes to your policy don’t require reclassification—just remap stored IAB paths.
  • Data Retention: Keep the IAB path, the human-friendly category name, and the confidence. This makes auditing and future remaps straightforward.
  • Security: Store the API key securely (env vars, secret manager). Don’t hardcode in source.

FAQ

  • Which endpoint should I use to get IAB categories?

    Use POST https://www.klazify.com/api/domain_iab_categories with a JSON body that includes the url field.

  • Where do I find the IAB category in the response?

    Loop over domain.categories[]. Each category object contains the name and confidence fields, plus one or more IAB fields as sibling keys (e.g., IAB-xxx). There is no separate IAB_categories object.

  • How should I handle unknown or unreachable domains?

    Return a default policy (e.g., temporary allow or queue for review), log the event, and retry later. Failed or unreachable calls are not billed.

  • Can I cache results per domain?

    Yes. Cache at the domain level with a TTL that fits your freshness needs. This reduces latency and call volume without sacrificing accuracy for stable sites.

  • How do I start and what does it cost?

    Create a free account with a 7-day trial on the Starter plan ($39.99/mo) and obtain your API key to begin integration.

Ready to classify domains and apply IAB policies from your PHP app? Create your account and get an API key here: Register. For full endpoint details and field descriptions, visit the Documentation, and explore more capabilities at MCP.

Ready to use Klazify?

Start classifying websites, enriching company data, and exploring web intelligence.

Get Started Free