Integrate the IAB Category API in PHP

November 22, 2026
Integrate the IAB Category API in PHP

You need to classify domains into IAB categories from a PHP service so you can block certain categories, enrich user signups, or audit where your ads run. By the end of this guide you’ll have a working path to call the IAB Category API, parse the returned category signals, cache and map them in your own taxonomy, and wire the results into a PHP pipeline.

Why Klazify is the right IAB classifier for PHP stacks

If your product relies on precise IAB categories to gate content, score leads, or enforce brand safety, Klazify gives you the building blocks to ship quickly from a PHP codebase:

Illustration: Integrate the IAB Category API in PHP
  • Accurate website categorization using AI: Klazify analyzes full site content to identify nuanced topics and assigns IAB taxonomy fields on each detected category, enabling precise inclusion or blocking in your rules engine.
  • Global coverage: Classifies sites in multiple languages, so the same IAB logic applies across regions in your PHP service without custom per-locale logic.
  • Real-time classification: Fresh content is evaluated on-demand rather than relying solely on a static database. This helps when your moderation or ad placement rules need up-to-date IAB results.
  • Industry-level categories: Uses IAB taxonomy with granular categorizations commonly expected by ad tech, brand safety, and content filtering workflows.
  • Simple API integration: A clean REST interface fits well with PHP HTTP clients (e.g., Guzzle) and is easy to wire into middleware, job queues, or enrichment workers.
  • Compliance and filtering: Consistent IAB signals support well-defined whitelisting/blacklisting logic across your sites, campaigns, or network policies.

Learn more on the homepage: https://www.klazify.com. You can start for free and upgrade when you need scale.

What you will build: PHP workflow for IAB categories

The scenario: a PHP backend receives a domain during signup or ad placement review. You need to classify it into IAB categories to decide whether to allow, block, or flag for review, and to attach enrichment metadata. The flow below keeps latency low and costs predictable.

  1. Receive a domain or URL (e.g., from a signup, ad request, or crawl).
  2. Check your cache/store for a recent classification result for this domain.
  3. If missing or expired, call Klazify’s IAB endpoint and persist the result with a TTL (e.g., hours to days, tuned per your risk tolerance).
  4. Parse top category objects, extract the category paths and the IAB keys (sibling keys such as IAB12 or IAB-324-… on each category item).
  5. Map the returned IAB signals to your allow/block logic and your internal taxonomy if needed.
  6. Return a decision quickly and log enrichment to your data warehouse.

Make your first IAB request with curl

The IAB-specific endpoint accepts a POST with a JSON body and Bearer auth. Use this when your primary goal is category classification aligned to IAB. Failed or unreachable calls are not billed, and there’s a 7-day trial on paid plans. Starter is $39.99/mo.

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:

  • Send a full URL or domain in the url property.
  • Use a short timeout in your PHP service and a retry with backoff in a background job to avoid request fanout.
  • Cache per registrable domain (e.g., example.com) unless you explicitly need page-level variance.

Parse IAB categories from the response

Klazify returns category objects with a name and confidence. IAB taxonomy identifiers come as sibling keys within each category entry (for example, IAB12 or IAB-324-JLBCU7). There is no aggregated IAB_categories object; you read IAB codes directly from the category item’s keys.

In practice you will:

  • Iterate domain or endpoint-specific categories array.
  • Collect the category name and confidence.
  • Grab any keys that start with IAB (IAB or IAB- prefixed) and record those codes for decisions or mapping.

Official JSON response example you can model against

The sample below illustrates the structure you’ll use when reading categories, enrichment objects, logos, and related fields. Use it as your reference for parsing categories and extracting IAB sibling keys from each category item.


{
    "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"
    ]
}

How teams typically use these fields:

  • domain.categories: your primary source for the category name and confidence. On each item, scan for IAB-prefixed keys; those are the IAB taxonomy signals.
  • domain.logo_url: use for UI previews, internal consoles, or CRM enrichment.
  • objects.company: when available, enrich CRM or analytics with size, location, and tech stack.
  • domain_registration_data: inform risk models or prioritization when evaluating new signups.
  • similar_domains: build lookalike discovery, clustering, or QA sampling.

Working code: request IAB categories and extract IAB keys

The snippet below calls the IAB endpoint and converts each category item into a normalized structure where IAB-sibling keys are collected into an array. This is a minimal starting point for a worker or a PHP-adjacent microservice; adapt the same logic in your PHP client.

import requests

API_KEY = "YOUR_API_KEY"
ENDPOINT = "https://www.klazify.com/api/domain_iab_categories"

def fetch_iab(url):
    r = requests.post(
        ENDPOINT,
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json"
        },
        json={"url": url},
        timeout=12
    )
    r.raise_for_status()
    return r.json()

def normalize_categories(payload):
    # Expect a categories list in the response. Each item may include sibling IAB keys.
    categories = []
    # Defensive: walk all objects looking for "categories" if structure varies by endpoint
    # Here we assume the endpoint returns a top-level or nested categories container.
    stacks = []
    if isinstance(payload, dict):
        stacks.append(payload)
    while stacks:
        node = stacks.pop()
        if isinstance(node, dict):
            if "categories" in node and isinstance(node["categories"], list):
                for cat in node["categories"]:
                    if not isinstance(cat, dict):
                        continue
                    name = cat.get("name")
                    confidence = cat.get("confidence")
                    iab_codes = []
                    for k, v in cat.items():
                        if isinstance(k, str) and k.upper().startswith("IAB"):
                            # Some keys hold paths; store key and value for mapping.
                            iab_codes.append({"key": k, "value": v})
                    categories.append({
                        "name": name,
                        "confidence": confidence,
                        "iab": iab_codes
                    })
            for v in node.values():
                stacks.append(v)
        elif isinstance(node, list):
            stacks.extend(node)
    return categories

if __name__ == "__main__":
    data = fetch_iab("https://example.com")
    cats = normalize_categories(data)
    for c in cats:
        print(c)

Implementation tips:

  • Persist each domain’s normalized result alongside a fetched_at timestamp and TTL.
  • At decision time (block/allow), use the normalized IAB keys to map to your internal policy table.
  • Log the confidence so you can A/B tune thresholds later.

End-to-end in a PHP service: where the IAB API fits

In PHP frameworks (Laravel, Symfony, Slim), the IAB call belongs in a boundary that hides network concerns and provides a simple method to your domain logic:

  • A service class (e.g., CategoryService) making HTTP requests (via Guzzle) to Klazify and transforming the results.
  • A repository (e.g., CategoryCacheRepository) to store per-domain results in Redis with expiry.
  • A policy layer that maps IAB signals to allow/block outcomes (for example, deny if any mapped IAB code equals a blocked policy code).
  • Middleware that checks cache, enqueues async refresh if stale, and proceeds with the cached decision to keep latency low.

Use a short timeout (10–12s) for synchronous code paths and re-query asynchronously when you can. Reach out to the Documentation for full parameter references and structured field descriptions.

Using the categorization endpoint when you also need enrichment

When you need broader enrichment (logos, company info, similar domains) together with categories, the main endpoint provides a rich payload you can feed into CRM, analytics, and QA. The same parsing approach applies for extracting category names, confidences, and IAB-prefixed keys from each category item.


{
    "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"
    ]
}

Practical uses:

  • CRM enrichment: write objects.company.name, employeesRange, and tags to lead records.
  • Console UX: display domain.logo_url to help reviewers and CS agents verify entities quickly.
  • Analytics: compute domain_age_days_ago bucketing for risk modeling and triage tiers.

Batching, rate limits, caching, and unknown domains

For throughput and reliability, wire up the following operational practices:

  • Batching: If your PHP process handles large imports, push domains into a queue and process them in small concurrent worker batches to respect service-level limits. Persist results as they arrive.
  • Caching: Cache by registrable domain (example.com) unless you truly need per-URL variance. A TTL of 24–72 hours balances freshness and cost for most brand safety or signup enrichment flows.
  • Rate limits: Implement client-side throttling and exponential backoff. For details, refer to the Documentation.
  • Unknown or new domains: If a domain comes back with minimal data, record the attempt and schedule a recheck later. You can gate decisions on confidence thresholds and re-run asynchronously.
  • Error handling: Use short timeouts and treat unreachable calls as non-fatal. Failed or unreachable calls are not billed.

Mapping IAB to your internal taxonomy

You may need to reconcile IAB signals with your own policy or CRM taxonomy. Three common approaches:

Approach How it works Pros Cons When to use
Map by IAB code key Look for keys that start with IAB or IAB- on each category item and map exact codes to your internal policy rows. Stable, explicit mapping; easy to test. Requires maintaining a lookup table of IAB codes. Strict brand safety, ad placement controls.
Map by category path Use the category name path (e.g., /Parent/Sub/Leaf) to map to your own categories. Human-readable; helpful for analysts. String normalization and path drift require care. Analytics and reporting dashboards.
Hybrid (code + path) Prefer IAB codes when present; fall back to name path otherwise. Best coverage; resilient to missing fields. Slightly more complex logic. Production pipelines with heterogeneous sources.

Category-driven decisions in PHP

Once you have normalized categories, the decision layer in PHP becomes a simple table lookup:

  • Block list: If any returned IAB code is present in a blocked_codes set, short-circuit and deny.
  • Allow list: If an allowlist is used, allow when at least one category or IAB code matches; otherwise review.
  • Confidence: Require confidence ≥ threshold (e.g., 0.80) to auto-approve; route lower-confidence cases to review.

Store the computed decision, the matched code(s), and the raw JSON for auditability.

Sample JSON payload for local testing (copy exactly)

Use this payload to validate your parsing and mapping locally. It mirrors the same field structure you will see when inspecting results from the categorization endpoint.


{
    "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"
    ]
}

Operational checklist for production

  • Retries: Implement limited retries with backoff; push retriable failures to a queue.
  • Observability: Log latency, hit/miss on cache, and the number of categories returned. Keep samples of raw JSON for QA.
  • Backfills: For bulk reclassification or taxonomy updates, run backfills off-peak and throttle requests.
  • Change management: When updating your internal taxonomy mapping, deploy behind a feature flag and measure decision diffs.
  • Security: Keep API keys in your secret manager; rotate periodically.

Where to go next

Set up your account and grab an API key to start testing in minutes. Create a free account here: Register. Then review the full API reference and schema details in the Documentation. For managed change processes and platform updates, see MCP. Also bookmark the homepage: https://www.klazify.com.

FAQ

How do I map IAB categories to my own taxonomy?
Scan each category object for keys starting with IAB or IAB-, store those alongside the category path in your DB, and create a lookup table mapping those IAB codes (or paths) to your internal category IDs.

What if the API can’t reach a site or times out?
Treat it as a soft failure. Retry later from a queue. Unreachable calls are not billed, so you can safely implement retries without incurring charges for failed attempts.

How should I cache results?
Cache per registrable domain for 24–72 hours in Redis or your database, and invalidate on manual review or when business rules require stricter freshness.

Can I enrich records beyond IAB categories?
Yes. Use the main categorization endpoint to collect company details, logo URLs, domain registration data, and similar domains to power CRM enrichment and analytics.

What plan should I start with?
Most teams begin on Starter ($39.99/mo) with a 7-day trial, then scale as volume grows. Monitor cache hit rates and concurrency to forecast cost.

Ready to use Klazify?

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

Get Started Free