Integrate the Website Category API in PHP

November 23, 2026
Integrate the Website Category API in PHP

You need to classify and enrich domains in a PHP app so you can do concrete things: block a category like “News” on a corporate network, enrich a signup with company size and logo, or audit where ads are actually running. By the end of this guide you’ll POST a URL to the Klazify Website Category API from PHP, parse the response (categories, logo, social, company, tech, domain registration, and similar domains), and wire the results into your filters and data pipelines.

Why Klazify is the right fit for a PHP integration

PHP powers everything from custom admin tools to high-traffic CMS platforms. When your stack needs reliable, low-latency URL intelligence, Klazify’s single POST endpoint gives you production-ready website categorization plus enrichment fields your app can immediately use.

Illustration: Integrate the Website Category API in PHP
  • Accurate website categorization using AI: The API analyzes page content, enabling precise identification across niche topics. That’s essential when a single allow/block rule (e.g., “News”) controls user access or ad placement.
  • Global coverage: Classify sites in multiple languages, useful for multinational portals and global user bases served by your PHP app.
  • Real-time classification: You get up-to-date signals to reflect content changes rather than relying on stale, static lists.
  • Industry-level categories: IAB taxonomy mapping is returned for advertising and brand-safety alignment, simplifying targeting and exclusion rules.
  • Simple API integration: A single, well-defined categorize endpoint returns categories, logos, social links, company data, and technologies—ideal for one-call enrichments in signup flows or background jobs.
  • Compliance and filtering: Detect and whitelist or block relevant content categories at the URL level, improving both user safety and ad quality controls.

What you’ll build

You’ll implement an end-to-end workflow in PHP that:

  • Classifies a URL with a POST call and uses the top category to allow or block access.
  • Enriches a user or lead with company name, logo URL, location, size, revenue, tags, and technology stack for CRM or analytics.
  • Surfaces similar domains to expand targeting or competitive analysis lists.

We’ll show a copy-pasteable cURL request, a PHP example, and a JavaScript snippet. You can reuse the same patterns for batch jobs, cron tasks, or webhook handlers.

Endpoint and authentication

The API is a single POST:

  • URL: https://www.klazify.com/api/categorize
  • Auth: Bearer token in the Authorization header
  • Body: JSON with a single field, url

Create a free account to get your API key. Starter is $39.99/mo with a 7-day trial. Failed or unreachable calls are not billed.

Register

Make your first request

Here’s a complete, ready-to-run cURL call. The example sends a news publisher domain. Replace YOUR_API_KEY with your token.

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

For this URL, the API categorizes it under /News at confidence 0.97. You can use this to drive an allow/block decision or to label content in your data pipeline.

Understand the response

Below is the official example response format you’ll receive from the categorize endpoint. It includes categories, company data, logo, tech, domain registration dates, and similar domains.


{
    "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 to use in your PHP workflow:

  • domain.categories: The list of category candidates with confidence scores. Use the top entry for blocking/allowing or labeling.
  • domain.categories[].name: The category string you’ll apply in filters (e.g., “/News” for the earlier example URL).
  • domain.categories[].IAB-...: IAB taxonomy mapping when present. Use this to align with ad tech or content controls.
  • domain.logo_url: Stable logo URL you can store for UI or CRM enrichment.
  • objects.company: High-signal company metadata (name, location, employeesRange, revenue, tags, tech).
  • domain_registration_data: Useful for fraud checks or prioritizing older, established domains.
  • similar_domains: Expand your targeting sets, recommendation lists, or competitive audits.

PHP: classify and act on categories

This PHP snippet posts a URL, checks the top category, and decides whether to block access. It also extracts the logo and a few company fields for enrichment.

<?php
$apiKey = 'YOUR_API_KEY';
$endpoint = 'https://www.klazify.com/api/categorize';

$payload = json_encode([
    'url' => 'https://cbsnews.com'
]);

$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $apiKey,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);

if ($err) {
    // Network error or TLS issue. Not billed.
    error_log('Klazify request failed: ' . $err);
    http_response_code(503);
    exit('Service unavailable');
}

$data = json_decode($response, true);

// Basic safety checks
if (!is_array($data) || empty($data['success'])) {
    http_response_code(502);
    exit('Unexpected response');
}

// Extract top category if present
$topCategory = null;
$topConfidence = null;
if (!empty($data['domain']['categories'][0]['name'])) {
    $topCategory = $data['domain']['categories'][0]['name'];
    $topConfidence = $data['domain']['categories'][0]['confidence'] ?? null;
}

// Simple rule: block News with high confidence
$shouldBlock = ($topCategory === '/News' && $topConfidence !== null && $topConfidence >= 0.9);

if ($shouldBlock) {
    // Log and show a policy message
    error_log('Blocked URL due to category: ' . $topCategory . ' (' . $topConfidence . ')');
    http_response_code(451);
    exit('Blocked by policy');
}

// Otherwise, enrich your record
$logo = $data['domain']['logo_url'] ?? null;
$company = $data['objects']['company'] ?? [];
$companyName = $company['name'] ?? null;
$companySize = $company['employeesRange'] ?? null;
$companyRevenue = $company['revenue'] ?? null;
$companyTags = $company['tags'] ?? [];
$tech = $company['tech'] ?? [];

// Example: save to DB or render into a view
// saveEnrichment($url, $topCategory, $topConfidence, $logo, $companyName, $companySize, $companyRevenue, $companyTags, $tech);

echo json_encode([
    'category' => $topCategory,
    'confidence' => $topConfidence,
    'logo' => $logo,
    'company' => [
        'name' => $companyName,
        'employeesRange' => $companySize,
        'revenue' => $companyRevenue,
        'tags' => $companyTags,
    ],
    'techCount' => is_array($tech) ? count($tech) : 0
], JSON_PRETTY_PRINT);

JavaScript example for background workers or frontends

If you also maintain a Node.js worker or need a quick prototype, this fetch example shows how to parse the same fields:

import fetch from 'node-fetch';

const API_KEY = 'YOUR_API_KEY';

async function categorize(url) {
  const res = await fetch('https://www.klazify.com/api/categorize', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ url })
  });

  if (!res.ok) {
    // Network or non-2xx; unreachable calls are not billed
    const text = await res.text();
    throw new Error(`HTTP ${res.status}: ${text}`);
  }

  const data = await res.json();
  const categories = data?.domain?.categories || [];
  const top = categories[0] || {};

  return {
    category: top.name || null,
    confidence: top.confidence || null,
    iab: Object.keys(top).find(k => k.startsWith('IAB-')) ? top[Object.keys(top).find(k => k.startsWith('IAB-'))] : null,
    logo: data?.domain?.logo_url || null,
    company: {
      name: data?.objects?.company?.name || null,
      employeesRange: data?.objects?.company?.employeesRange || null,
      revenue: data?.objects?.company?.revenue || null
    },
    similarDomains: data?.similar_domains || []
  };
}

categorize('https://cbsnews.com')
  .then(console.log)
  .catch(console.error);

How to use the returned fields in real workflows

  • Blocklist or allowlist: Use domain.categories[0].name and confidence to apply policy rules. For example, block when category equals “/News” and confidence ≥ 0.9.
  • IAB mapping: When the response includes an IAB- code key, map it to your ad tech settings. Store both the friendly name and the IAB mapping to support reporting and audits.
  • Logos and UI: domain.logo_url plugs into your profile or dashboard views and can also power email templates and CRM cards.
  • Company enrichment: objects.company fields (name, employeesRange, revenue, tags, tech) enable lead scoring, sales routing, and product-led growth experiments.
  • Security and fraud: Check domain_registration_data for domain_age_date and domain_expiration_date to flag newly registered or expiring domains during risk scoring.
  • Analytics and recommendations: similar_domains extends your sets for analysis, competitor tracking, or content recommendations.

Mapping categories to your own taxonomy

Most teams standardize on a small set of content categories. Use a mapping table that reads the returned category name and optional IAB mapping, then converts it to your internal label.

  • Preferred key: Use the category name (e.g., “/News”) as the primary match.
  • Fallback: If you find an IAB- code property in the category object, use it to backfill missing or ambiguous mappings.
  • Versioning: Keep your mapping table versioned and log unmapped categories for review.

Operational details: batching, caching, rate limits, and unknown domains

  • Batching: Run classification in background jobs for inbound lists. Use a queue to smooth out bursts and keep latency predictable for your PHP web tier.
  • Caching: Cache results by normalized domain or canonical URL. A 7–30 day TTL works for most categories; shorter for newsy or fast-changing sites. Revalidate on misses or after TTL expiry.
  • Rate limits: Design for backoff and retry with jitter. Spread large imports over time to reduce spikes and smooth consumption.
  • Idempotency: Deduplicate URLs before sending. Normalizing schemes (http/https), removing default ports, and lowercasing hostnames avoids duplicate lookups.
  • Unknown or new domains: If you receive a minimal or empty category set, queue a delayed retry. Persist “unknown” as a temporary label so downstream systems remain deterministic.
  • Failures: Network errors or unreachable calls are not billed. Log them and retry with backoff.

Compare response sections and how to wire them in PHP

Response section Key fields Primary use in PHP apps Storage suggestion
domain.categories name, confidence, IAB-... Blocking, whitelisting, labeling content Store top category + confidence; keep raw array JSON
domain.logo_url logo_url UI avatars, CRM enrichment, emails Cache the URL; optionally proxy via your CDN
objects.company name, employeesRange, revenue, tags, tech Lead enrichment, routing, segmentation Flatten selected fields; persist tags/tech as arrays
domain_registration_data domain_age_date, domain_expiration_date Fraud/risk models, prioritization Store dates and derived age in days
similar_domains array of domains Target expansion, competitor analysis Separate join table keyed by seed domain

Production checklist

  • Normalize input URLs: lowercase host, trim, remove fragments, default ports.
  • Cache by domain and optionally by full URL for page-level differences.
  • Define category policy rules with confidence thresholds (e.g., ≥ 0.9 for blocking).
  • Implement retries with jitter; log network exceptions for audit.
  • Persist both human-readable categories and any IAB mapping returned.
  • Build a review process for unmapped or low-confidence results.
  • Store enrichment fields selectively to keep rows slim; archive raw JSON for reprocessing.

Pricing, setup, and where to go next

Starter is $39.99/mo with a 7-day trial. Because failed or unreachable calls are not billed, you can safely experiment during integration. For full request/response details, visit the API docs and management pages:

FAQ

  • Does the API classify specific URLs or just domains? It classifies URLs, enabling page-level decisions for sites with diverse content, and also returns domain-level enrichment.
  • How should I cache results? Cache by normalized domain for most policies. If your use case is page-level, cache by full URL. Use a TTL window (for example, 7–30 days) and revalidate on expiry or if you detect content changes.
  • What happens if the request fails? Network failures or unreachable calls are not billed. Implement retries with backoff and log the error for observability.
  • How do I align categories with my internal taxonomy? Map the returned category name to your internal label. When available, use the IAB mapping in the category object to anchor to industry-standard semantics and simplify ad tech alignment.
  • Can I use the enrichment fields in CRMs? Yes. Save company name, employeesRange, revenue, logo_url, tags, and tech to enhance segmentation, routing, and dashboards.

Ready to classify and enrich domains from your PHP stack? Create a free account, get your API key, and ship your first integration in minutes: Register. For implementation details and field-by-field definitions, see the Documentation.

Ready to use Klazify?

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

Get Started Free