Integrate the Similar Companies API in PHP
A sales-enrichment pipeline can start with a company website and still lack the related domains an analyst needs for research. By the end of this guide, you can send a URL to Klazify, read its similar-domain results in PHP, and route them into a review or enrichment workflow.
Why use domain intelligence for related-company research?
Klazify Documentation describes an API for finding related domains as well as categorizing and enriching websites. For a CRM signup, the related-domain list can give a researcher candidate sites to investigate without maintaining a separate directory of company relationships.
Klazify also analyzes website content for classification and maps categories to the IAB taxonomy. That is useful when a team wants to assess the subject of a candidate site as well as find it. Content analysis can provide context that a domain name or metadata alone may miss, including for sites in different languages.
Keep the two tasks separate: the similar-domain endpoint identifies related sites, while classification is a separate capability. A related site is a candidate for investigation, not proof that the businesses are competitors, share an owner, or meet a particular brand-safety policy.
Make the similar-domain request
Send a JSON object containing the URL to POST https://www.klazify.com/api/similar_domain. Replace YOUR_API_KEY with your API key. The following request includes the authentication and content-type headers:
curl -X POST "https://www.klazify.com/api/similar_domain" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://cbsnews.com"}'
For this endpoint, read similar_domains under domain. The list contains up to 10 related sites. Do not look for a top-level similar field or interpret the order as a ranking.
Before connecting the result to a CRM or audit system, test the request with a domain you are authorized to process. Treat an empty list differently from a failed request or a response that does not contain the expected field.
Read the results in PHP
The example below uses PHP’s cURL extension. Set the KLazify_API_KEY and DOMAIN_URL environment variables before running it; the latter is the website you want to investigate. The script checks transport errors, HTTP status, JSON validity, and the location of the list before printing the domains.
<?php
$apiKey = getenv('KLazify_API_KEY');
$url = getenv('DOMAIN_URL');
if (!$apiKey || !$url) {
fwrite(STDERR, "Set KLazify_API_KEY and DOMAIN_URL.\n");
exit(1);
}
$payload = json_encode(['url' => $url]);
if ($payload === false) {
fwrite(STDERR, "Could not encode the request.\n");
exit(1);
}
$handle = curl_init('https://www.klazify.com/api/similar_domain');
curl_setopt_array($handle, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $payload,
]);
$body = curl_exec($handle);
if ($body === false) {
$error = curl_error($handle);
curl_close($handle);
fwrite(STDERR, "Request failed: " . $error . "\n");
exit(1);
}
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
if ($status < 200 || $status >= 300) {
fwrite(STDERR, "API returned HTTP " . $status . "\n");
exit(1);
}
$data = json_decode($body, true);
if (!is_array($data)) {
fwrite(STDERR, "Response was not a JSON object.\n");
exit(1);
}
if (($data['success'] ?? null) === false) {
fwrite(STDERR, "API reported an unsuccessful result.\n");
exit(1);
}
$domains = $data['domain']['similar_domains'] ?? null;
if (!is_array($domains)) {
fwrite(STDERR, "Similar domains were not available.\n");
exit(1);
}
if (count($domains) === 0) {
echo "No similar domains returned.\n";
} else {
foreach ($domains as $domain) {
if (is_string($domain)) {
echo $domain . PHP_EOL;
}
}
}
Replace the printing step with your own persistence or review-queue code. Store the input domain alongside each returned candidate so an analyst can trace why a site appeared. Keep the raw response available according to your organization’s retention policy if you need to investigate later changes.
The script does not turn an absent list into an empty one. That distinction prevents an unexpected response shape from being recorded as a definitive “no related sites” result.
Python alternative for a data pipeline
If a worker in your pipeline is written in Python, it can call the same endpoint and read the same nested field. This version uses the standard library and the same environment variables as the PHP example.
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
api_key = os.environ.get("KLazify_API_KEY")
url = os.environ.get("DOMAIN_URL")
if not api_key or not url:
sys.exit("Set KLazify_API_KEY and DOMAIN_URL.")
payload = json.dumps({"url": url}).encode("utf-8")
request = Request(
"https://www.klazify.com/api/similar_domain",
data=payload,
headers={
"Authorization": "Bearer " + api_key,
"Content-Type": "application/json",
},
method="POST",
)
try:
with urlopen(request) as response:
data = json.load(response)
except (HTTPError, URLError, TimeoutError, ValueError) as error:
sys.exit(f"Request or response failed: {error}")
if not isinstance(data, dict) or data.get("success") is False:
sys.exit("API did not return a successful object.")
domain_data = data.get("domain")
if not isinstance(domain_data, dict):
sys.exit("Domain data was not available.")
domains = domain_data.get("similar_domains")
if not isinstance(domains, list):
sys.exit("Similar domains were not available.")
if not domains:
print("No similar domains returned.")
else:
for domain in domains:
if isinstance(domain, str):
print(domain)
In production, pass each candidate to your own review or enrichment step instead of assuming it has already been classified. For an automated workflow, record whether the lookup succeeded, returned no candidates, or needs a retry.
Understand the broader domain response
The following example shows the supplied domain-intelligence response, including classification and company fields. It is useful for understanding enrichment data, but it is not the response shape to use when parsing the similar-domain endpoint above: this example places similar_domains at the top level, whereas that endpoint places it under domain.
{
"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"
]
}
In this example, domain.categories contains category names and confidence values; one entry also includes an IAB mapping. A pipeline can preserve those source values and map them to internal labels. The confidence values are signals to evaluate against your own review process, not guarantees that a classification or business relationship is correct.
objects.company contains company details that can help an analyst assess a candidate, while domain_registration_data provides registration-related dates. Some fields, including social_media and raised here, are null. Handle missing or null data explicitly rather than treating it as a negative finding.
The example’s categories and company data illustrate enrichment; the similar-domain request in this guide should not be assumed to return all of those fields. Klazify’s categorization endpoint is https://www.klazify.com/api/categorize; consult the documentation for its request and response details before adding classification to the pipeline.
Move from a single lookup to a reliable pipeline
Normalize incoming website addresses before lookup and cache results per domain where domain-level reuse makes sense. Preserve the original input as well: if your application later classifies individual URLs, a domain-level cache is not necessarily equivalent to a page-level result.
For a large signup backlog, group work in your application and send requests at a controlled rate. The request shown here accepts one URL; do not assume that it accepts an array or that related sites are paginated. Check the current account limits and documentation, then configure concurrency and backoff around those limits.
Cache successful results with a refresh policy suited to your workflow. Related sites and website content can change, so retain the lookup time with cached data and refresh stale entries rather than treating an old result as permanent. Separate a successful empty list from an unavailable or failed lookup, and avoid caching a transient failure as a long-lived negative result.
New, unreachable, or unfamiliar domains may need another attempt or human review. Queue retryable failures with backoff; surface persistent failures instead of repeatedly submitting the same input without investigation. Failed or unreachable calls are not billed, but you should still monitor failures for pipeline health.
If you subsequently classify candidate sites, maintain a versioned mapping from Klazify’s category names or IAB values to your internal taxonomy. Define what happens when a category has no mapping, when multiple categories apply, or when confidence is insufficient for an automated decision. For ad-placement audits or filtering, send uncertain cases to review rather than inferring safety from a related-domain list.
Measure your own operational outcomes: request latency, cache hit rate, failed lookups, missing fields, and the proportion of candidates reviewers find useful. These measurements help determine whether to refresh more often, adjust concurrency, or add review before enriching CRM records.
FAQ
Where does the PHP integration find related sites?
For similar_domain, read domain.similar_domains. The endpoint lists up to 10 related sites; a missing field should be handled separately from an empty list.
Does a related domain prove a company is a competitor?
No. Use the returned domains as research candidates. Verify the relationship and, if needed, classify or enrich each site separately before acting on it.
Can I submit a batch in the request shown?
The documented request shown here submits one URL. For multiple inputs, manage a queue and concurrency in your application, and check your account’s current rate limits.
What does it cost to start?
Starter is $39.99 per month with a 7-day trial. Failed or unreachable calls are not billed; check the current account terms before deploying a large workload.
Register for a free account to try the request, and explore MCP if it fits your integration workflow.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free