How to Get a Company Logo in PHP

October 23, 2026
How to Get a Company Logo in PHP

You need to automatically pull a company’s logo during signup, CRM enrichment, or when rendering a list of partner domains. By the end of this guide, you will make a single API call to fetch a logo URL you can drop into your product, and you will know how to cache, batch, and integrate this result into a production pipeline.

Why Klazify fits logo retrieval for production pipelines

When you need a dependable company logo at scale, accuracy and coverage are only the start. You also want the response to plug into your stack, include useful extras (like company and category data), and behave reliably across new or obscure domains. Here’s how Klazify helps you ship this quickly and keep it maintainable:

Illustration: How to Get a Company Logo in PHP
  • Accurate categorization alongside logos: The same request that gives you a logo can also return IAB taxonomy categories, so you can gate signups, drive brand safety checks, or route leads by industry while rendering the logo.
  • Global coverage: Klazify analyzes websites in multiple languages, which matters when you onboard international domains and still want a consistent logo asset without regional gaps.
  • Real-time classification: Rather than depending on stale lookups, Klazify analyzes content and returns an up-to-date categorization and a current logo URL that you can cache and refresh.
  • IAB taxonomy alignment: If you’re enriching signups or auditing placements, the IAB mapping in the same payload lets you classify content in advertising-standard categories while you fetch the logo.
  • Simple REST integration: A single POST request returns a hosted logo URL in JSON, making it trivial to attach to a user, account, or domain record.
  • Compliance and filtering: The returned categories can help you filter, whitelist, or block sensitive sites while still populating logos for approved domains.

Teams building signup flows, ad placement audits, or partner directories can start by fetching only the logo, and expand to categorization and company enrichment without changing providers.

What you are building: a one-call logo fetch

Your immediate goal is to send a URL or domain to Klazify and get back a hosted logo URL in JSON. You can then render this in your app, or store it with your account record. We will:

  • Call the logo endpoint with a URL.
  • Parse the JSON to extract the logo URL.
  • Cache the result per domain to minimize repeat calls.
  • Optionally call the categorization endpoint to retrieve categories, company info, and similar domains alongside the logo for broader enrichment.

Endpoint to fetch a logo URL

Use this endpoint to retrieve a hosted logo URL for a given site:

  • Method: POST
  • URL: https://www.klazify.com/api/domain_logo
  • Headers: Authorization: Bearer YOUR_API_KEY, Content-Type: application/json
  • Body: {"url":"https://cbsnews.com"}

Failed or unreachable calls are not billed. If you are new to Klazify, the Starter plan is $39.99/mo and includes a 7-day trial so you can build and validate without risk. To get an API key, create a free account from the link below.

Copy-paste cURL request

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

This returns JSON that includes a hosted logo URL you can store or render immediately. Keep your API key secure and do not expose it in client-side code.

Node.js example: fetch the logo and guard for nulls

import fetch from "node-fetch";

async function getLogo(url) {
  const res = await fetch("https://www.klazify.com/api/domain_logo", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ url })
  });

  if (!res.ok) {
    // Not billed if unreachable/failed, but still handle gracefully
    const text = await res.text();
    throw new Error(`Klazify error ${res.status}: ${text}`);
  }

  const json = await res.json();

  // The response contains a hosted logo URL in JSON.
  // When also using the categorize endpoint, the official sample shows domain.logo_url.
  // Here we read domain.logo_url if present.
  const logoUrl = json?.domain?.logo_url || null;

  return {
    logoUrl,
    raw: json
  };
}

(async () => {
  try {
    const { logoUrl } = await getLogo("https://cbsnews.com");
    if (!logoUrl) {
      console.log("No logo available for this domain yet. Consider queuing a retry.");
    } else {
      console.log("Logo URL:", logoUrl);
      // Persist to your DB and cache. Example: accounts.logo_url = logoUrl
    }
  } catch (err) {
    console.error(err);
  }
})();

In production, cache the logo URL keyed by the registrable domain (for example, example.com). Time-based cache invalidation (for instance, a weekly refresh) is a safe default for most applications.

Official sample: categorization response with a logo URL

The main categorization endpoint returns much more than a logo. Below is the official sample response format. Use it when you need to enrich a domain with categories, IAB mapping, company info, domain registration data, and similar domains. It also includes a logo URL you can render immediately.


{
    "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 will use:

  • domain.logo_url: Hosted logo you can render in your UI or email templates.
  • domain.categories: One or more content categories with confidence scores. Use to filter or segment.
  • objects.company.*: Company profile attributes (name, location, size, revenue, tags, tech) that you can map into CRM or scoring logic.
  • domain_registration_data.*: Helpful for fraud checks and security scoring.
  • similar_domains: Useful for deduplication and prospecting (e.g., suggest likely related vendors).

Choosing the right endpoint for your job

Two endpoints matter for logos. Use domain_logo for a minimal logo-only integration, and use categorize when you also need categories or company data.

Endpoint Primary goal Logo in response When to use
POST /api/domain_logo Get a hosted logo URL Yes (logo URL in JSON) Signup flows, lists, quick UI rendering, or anytime you only need a logo
POST /api/categorize Full enrichment and IAB mapping Yes (domain.logo_url) Ad tech, brand safety, CRM/lead enrichment, analytics, and cybersecurity contexts

PHP drop-in snippet for server-side rendering

Although the required sample above uses JavaScript, most teams working in PHP will keep logo fetching server-side (to protect the API key). This minimal example demonstrates sending a POST to the logo endpoint and extracting a hosted logo URL:

<?php
function klz_get_logo_url($targetUrl) {
    $endpoint = "https://www.klazify.com/api/domain_logo";
    $payload = json_encode(["url" => $targetUrl]);

    $ch = curl_init($endpoint);
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer YOUR_API_KEY",
            "Content-Type: application/json",
            "Content-Length: " . strlen($payload),
        ],
        CURLOPT_POSTFIELDS => $payload,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 20,
    ]);

    $response = curl_exec($ch);
    if ($response === false) {
        curl_close($ch);
        return null; // Not billed if unreachable/failed, but return gracefully
    }

    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($status < 200 || $status >= 300) {
        return null;
    }

    $json = json_decode($response, true);
    // The response contains a hosted logo URL in JSON.
    // When using the categorize endpoint, the sample shows domain.logo_url.
    $logoUrl = $json["domain"]["logo_url"] ?? null;

    return $logoUrl;
}

// Example:
$logo = klz_get_logo_url("https://cbsnews.com");
if ($logo) {
    // Persist in DB and render in templates
    echo htmlspecialchars($logo);
} else {
    // Fallback to initials or a placeholder SVG in your app
    echo "No logo available";
}

Always store the final hosted logo URL in your database keyed by the domain, so your frontend never calls the API directly.

How to wire this into your pipeline

1) Where to call from

  • Signup enrichment: When a user enters a work email, extract the domain and call the logo endpoint. Save the hosted logo URL on the account/company record.
  • Bulk import: For lists of domains, process in batches, respecting your plan’s general rate guidance from the documentation, and cache per domain.
  • Ad placement audit: For each publisher/partner domain, retrieve a logo and categories to display and filter in your review dashboard.

2) Caching strategy

  • Key by registrable domain (e.g., example.com). Store the hosted logo URL and a last_fetched timestamp.
  • Set a refresh window (for example, 7–30 days) to pick up rebrands without over-calling the API.
  • On null or missing logo, enqueue a delayed retry and fall back to an initials-based avatar.

3) Handling unknown or new domains

  • If the response does not include a logo yet, return a neutral fallback in your UI and schedule a retry.
  • Log unreachable domains separately; failed or unreachable calls are not billed, but should not block your user flow.

4) Mapping categories to your internal taxonomy

  • Use the categories array from the categorization response and map the IAB taxonomy to your internal types.
  • Persist the original category path (for example, "/Internet & Telecom/Mobile & Wireless/Mobile Phones") and your mapped value side-by-side for auditability.
  • When a domain spans multiple categories, choose based on the highest confidence or your business rules.

Connecting logos with categorization and company data

Even if your immediate need is just the logo, you can often unlock extra product value by including categories and basic company metadata:

  • Brand safety and filtering: Use domain.categories with confidence to determine if a site is eligible for certain placements while showing its logo next to the decision.
  • CRM and lead enrichment: Use objects.company fields (name, city, countryCode, employeesRange, revenue, tags, tech) to qualify and route leads during onboarding, paired with the company logo to enhance account views.
  • Analytics and segmentation: Use IAB mappings for content strategies and audience analysis, while logos drive better UX in reports and dashboards.

Operational notes that save time

  • Batching: Queue domain lookups and process in fixed-size batches server-side. Deduplicate domains within a batch to avoid redundant calls.
  • Backoff and retries: Implement exponential backoff on transient errors. Persist partial results to continue from the last successful offset.
  • Rate limits: Follow the general guidance in the API docs and avoid client-side calls. Throttle based on your plan and centralize API usage in a single service.
  • Storage format: Store the hosted logo URL as a normalized HTTPS URL. If you transform it (proxy, CDN, or resizing), keep the original unmodified URL for refresh cycles.
  • Security: Use server-to-server calls with a Bearer token. Never embed your API key in client-side JavaScript.

Testing, monitoring, and fallbacks

  • Integration tests: Verify that the response includes a logo URL, categories, and company objects where applicable. Assert non-null for critical fields you depend on.
  • Observability: Track success rate, null-logo percentage, median latency, and refresh hit rate in logs/metrics.
  • Fallbacks: If no logo is returned, serve a deterministic placeholder (e.g., initials-based SVG) and batch-retry later. Log these cases for review.

When to use the categorization endpoint first

If your workflow already needs categories or company data, call the categorization endpoint and extract the logo from the domain.logo_url field in the same response. This avoids a second network hop and keeps enrichment atomic. The official sample above shows the fields exactly as they appear.

Get started

  • Create your free account and get an API key: Register
  • Review the endpoint details, authentication, and additional objects you can retrieve: Documentation
  • If you manage multiple services, check how to centralize and govern usage: MCP

FAQ

  • How do I handle rate limits when enriching a large list of domains?
    Use server-side batching with deduplication, centralize calls through one service, and apply backoff on non-2xx responses. Cache results per domain to avoid repeat lookups.
  • What if the API cannot reach a site or returns no logo yet?
    Return a UI fallback immediately and enqueue a retry. Failed or unreachable calls are not billed.
  • Can I also get categories and company data with the logo?
    Yes. Use the categorization endpoint and read domain.logo_url along with categories and objects.company fields shown in the official sample.
  • How should I map categories to my internal taxonomy?
    Persist the raw category path and IAB mapping, then translate to your internal codes during ingestion. Choose the final category by confidence or your business rules.
  • How do I keep logos fresh without over-calling the API?
    Cache per domain and refresh on a schedule (for example, weekly). Only refresh stale entries or on-demand when a user views a profile after a long gap.

Ready to implement? Create your account to get an API key and start fetching logos in minutes. The Starter plan is $39.99/mo with a 7-day trial, and failed or unreachable calls are not billed. Build your integration now: Register. For details on all response fields and endpoints, see the Documentation.

Ready to use Klazify?

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

Get Started Free