Integrate the Website Directory API in PHP
A website directory can help a PHP application enrich a signup, review an advertising placement, or apply a browsing policy—but only if the application can turn domain data into a decision. This guide shows how to call Klazify’s discovery endpoint, read the supplied categorization response in PHP, and handle domains that need another look.
Why use domain intelligence in a directory workflow?
Documentation describes Klazify as a source of website categorization and related domain data. A directory can use that data to organize sites, while an enrichment pipeline can attach the same context to a company record.
Klazify analyzes website content rather than relying solely on domain names or metadata. It supports hierarchical categories, IAB taxonomy mapping, and analysis of websites in multiple languages. That is useful when a site’s name alone does not tell you whether it belongs in a particular directory section or policy review queue.
The response can also contain company details, technology tags, social links, registration information, and related domains. Availability varies by result: a missing social link or company field should not be treated as evidence that the information does not exist.
For filtering and brand safety, use categories as inputs to your own policy. A category match can trigger a block or review, but categorization alone is not a malware verdict or a compliance determination. Likewise, a directory entry should retain the source data and the time it was retrieved so that an operator can revisit a decision.
Make a discovery request
The directory integration uses POST https://www.klazify.com/api/discovery. Klazify also documents https://www.klazify.com/api/categorize for website classification; treat these as distinct endpoints and consult the documentation for the request and response details applicable to your workflow.
For the discovery request below, put the documented authentication and request data in a local curl configuration file, and set KLAZIFY_CURL_CONFIG to its path. Use YOUR_API_KEY when preparing the credential, replacing it with your actual key before calling the API. Keep that file out of source control and restrict access to it.
curl --config "$KLAZIFY_CURL_CONFIG" \
--request POST \
https://www.klazify.com/api/discovery
The configuration file is important: the command supplies the endpoint and method, while the documented request configuration supplies the credentials and input. Check the HTTP result before passing the response to a directory or policy rule. The example response below illustrates the categorization fields to read; verify the fields returned by the endpoint and request you use.
Call the same endpoint from Python
This example invokes curl with the same configuration and checks for a successful process before parsing JSON. It reads categories only when the returned object contains them, so a different response shape does not silently become a category match.
import json
import os
import subprocess
config_path = os.environ["KLAZIFY_CURL_CONFIG"]
result = subprocess.run(
[
"curl",
"--fail",
"--silent",
"--show-error",
"--config",
config_path,
"--request",
"POST",
"https://www.klazify.com/api/discovery",
],
capture_output=True,
text=True,
check=True,
)
data = json.loads(result.stdout)
if data.get("success") is True:
domain = data.get("domain") or {}
for category in domain.get("categories") or []:
print(category.get("name"), category.get("confidence"))
else:
print("No successful categorization result to process")
In production, handle process failures and invalid JSON in the job runner. Do not log the configuration file or credentials. If the discovery response does not include the categorization fields shown here, use the documented response for that request rather than interpreting absent fields as empty classifications.
Read and apply the categorization response in PHP
The following is the supplied example of a domain intelligence response. It includes two categories and an IAB mapping, as well as company and domain signals that a directory or enrichment job may use.
{
"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"
]
}
Check success before using domain.categories. Each category has a name and a confidence; the first also has an IAB mapping under IAB-632-596. A confidence value is not a substitute for measuring how well a policy performs on your own traffic.
For enrichment, objects.company supplies fields such as name, location, employee range, tags, and technology labels in this example. social_media and raised are null, so consumers must allow for missing values. Registration dates and day counts are separate fields; preserve the source values and retrieval time rather than treating the day counts as permanently current.
Map a category to a local action
Save a JSON response as response.json, then run the following PHP script with that file as standard input. It maps the example’s consumer-electronics category to a review action. Replace that local rule with your directory or policy mapping; the script deliberately treats missing or unsuccessful results as unknown.
<?php
$input = stream_get_contents(STDIN);
try {
$data = json_decode($input, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
fwrite(STDERR, "Invalid JSON response\n");
exit(1);
}
if (!is_array($data) || ($data['success'] ?? null) !== true) {
echo "Unknown: no successful result\n";
exit(0);
}
$categories = $data['domain']['categories'] ?? null;
if (!is_array($categories) || $categories === []) {
echo "Unknown: no categories returned\n";
exit(0);
}
$action = 'unmapped';
foreach ($categories as $category) {
if (!is_array($category)) {
continue;
}
$name = $category['name'] ?? null;
$confidence = $category['confidence'] ?? null;
if ($name === '/Computers & Electronics/Consumer Electronics') {
$action = 'review';
echo "Matched: " . $name . "\n";
echo "Confidence: " . ($confidence ?? 'not provided') . "\n";
}
}
echo "Action: " . $action . "\n";
php classify.php < response.json
A real mapping can send an entry to a directory section, enrich a CRM record, or place an ad impression in an audit queue. Store the original category alongside the local action and mapping version. That makes it possible to explain a decision later and reprocess records when your taxonomy changes.
Operate the integration at scale
Normalize input consistently before caching: decide whether your use case is domain-level or page-level, and avoid treating distinct page URLs as interchangeable when page content matters. Cache successful domain results per normalized domain for domain-level workflows, with a refresh policy suited to how quickly your decisions need to reflect site changes.
Do not cache an unreachable or unsuccessful lookup as a permanent classification. Mark it as unknown, retain enough context to retry, and route consequential decisions to review according to your policy. New domains may have limited information; an empty result is not the same as a safe or disallowed category.
For bulk enrichment, queue work and control concurrency according to your account’s applicable rate limits. Deduplicate domains before issuing calls, retry transient failures with backoff, and monitor the rate of unknown and failed results. Check the account and documentation for the limits that apply rather than assuming a fixed batch size or throughput.
Keep provider categories and your internal taxonomy separate. A mapping table should record the source category, local action, and version; test changes against reviewed examples before applying them to historical data. If multiple categories are returned, define whether any match triggers review or whether a more specific rule takes precedence.
For operating costs, the Starter plan is $39.99 per month with a seven-day trial. Failed or unreachable calls are not billed. Even so, monitor failures: an unbilled failure can still delay an enrichment job or leave a policy decision unresolved.
FAQ
Can I use the same result for a domain and every page on it?
Not necessarily. Klazify supports URL-level classification as well as domain analysis. Choose the appropriate scope for the decision and make that scope part of your cache key.
What should I do when a category is missing?
Treat the result as unknown or unmapped, not automatically allowed or blocked. Retry when appropriate and use a review path for decisions with significant consequences.
How should I use confidence?
Store it with the source category and evaluate thresholds against your own reviewed data. Define separately what happens when confidence is absent or below your chosen threshold.
Can I use these fields in an AI-assisted workflow?
Explore MCP for the available integration information. Keep the same validation and policy checks around any action based on returned domain data.
To start building the directory workflow, Register for a free account, configure your request using the documentation, and test your PHP mapping against responses from your own domains.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free