Integrate the Website Rank API in PHP
Your team needs to score domains by popularity and engagement so you can prioritize ad placements, enrich signups, or flag suspicious referrers. By the end of this guide you’ll be able to call Klazify’s Website Rank API from a backend workflow, read rank and traffic fields, cache results per domain, and wire them into your PHP pipeline without guesswork.
Why Klazify is the best fit for ranking domains in your pipeline
When you integrate a website rank signal, you need consistent coverage, low latency, and context you can trust. Klazify combines traffic intelligence with website categorization and company enrichment, so a single request can inform both scoring and filtering decisions.
- Accurate website categorization using AI: Rankings are most useful when joined with categories. Klazify’s content analysis goes beyond metadata and maps to IAB taxonomy, so your ranking logic can weight news, shopping, finance, or adult categories differently during ad ops and brand safety checks.
- Global coverage: Websites in multiple languages receive categories and traffic insights, helping you interpret rank across regions and reduce blind spots when a referrer isn’t in English.
- Real-time classification: Fresh crawls and analysis feed both categorization and rank, keeping your prioritization logic aligned with current content and traffic shifts.
- Industry-level categories: With IAB mapping, you can align rank with recognized industry segments for bidding, allow/block rules, or compliance workflows.
- Simple API integration: A REST interface and JSON responses mean you can plug in from cron jobs, ETL tasks, or request-time enrichment with minimal glue code.
- Compliance and filtering: Pair rank with category signals to detect sensitive or restricted content before activating spend or unlocking access on a corporate network.
If you’re new to Klazify, you can explore it on klazify.com and create a free account to get API access.
What you’ll build: domain rank scoring with PHP-friendly integration
We’ll send a domain to the Website Rank API endpoint, read back fields like global_rank, country_rank, category_rank, monthly_visits, engagement, traffic_sources, and top_countries, and then apply them to a few common tasks:
- Ad tech: prioritize or exclude placements based on global_rank and category_rank, and verify traffic sources before activating.
- Lead enrichment: store monthly_visits and top_countries for sales routing and territory planning.
- Security analytics: downrank or flag domains with thin engagement, an unusual country mix, or high bounce behavior.
We’ll also show how to combine these ranking signals with categorization and company data, so you can route traffic by industry and size.
Endpoint and authentication
To access Website Rank data, call the traffic intelligence endpoint using a Bearer token and JSON body containing the URL or domain you want to analyze:
- Method: POST
- Endpoint: https://www.klazify.com/api/domain_traffic_intelligence
- Headers: Authorization: Bearer YOUR_API_KEY, Content-Type: application/json
- Body: {"url": "https://example.com"}
If you don’t have an API key yet, create one with the free trial on the Register page. The Starter plan is $39.99/mo with a 7-day trial, and failed or unreachable calls are not billed.
Copy-pasteable curl request (Website Rank API)
curl -X POST "https://www.klazify.com/api/domain_traffic_intelligence" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://cbsnews.com"}'
This request returns the website’s rank and traffic intelligence. In your production code, you’ll replace the URL with the domain you’re scoring and YOUR_API_KEY with your token.
JavaScript example: calling the Website Rank API and reading key fields
The snippet below demonstrates how to call the same endpoint from a Node.js service, extract key fields, and normalize them for storage. You can adapt it to PHP by mirroring the same headers and JSON parsing in cURL or Guzzle.
import fetch from "node-fetch";
async function getDomainRank(urlToCheck) {
const resp = await fetch("https://www.klazify.com/api/domain_traffic_intelligence", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({ url: urlToCheck })
});
if (!resp.ok) {
// Not billed if unreachable; still good to log and handle
const text = await resp.text();
throw new Error(`Klazify error ${resp.status}: ${text}`);
}
const data = await resp.json();
// Expected fields (example usage):
// data.global_rank, data.country_rank, data.category_rank
// data.monthly_visits, data.engagement, data.traffic_sources, data.top_countries
// Normalize for storage
const normalized = {
domain: urlToCheck,
global_rank: data.global_rank ?? null,
country_rank: data.country_rank ?? null,
category_rank: data.category_rank ?? null,
monthly_visits: data.monthly_visits ?? null,
engagement: data.engagement ?? null,
traffic_sources: data.traffic_sources ?? null,
top_countries: data.top_countries ?? null,
fetched_at: new Date().toISOString()
};
return normalized;
}
// Example usage
getDomainRank("https://example.com")
.then((info) => {
console.log("Rank summary:", info);
// Persist to your DB and feed any scoring pipeline
})
.catch((err) => {
console.error("Rank fetch failed:", err);
});
Store the entire payload in your data warehouse so you can iterate on scoring later. At request time, read only the fields you need for policy checks or feature flags.
Official sample JSON: categorization and company data you can join with rank
Klazify also exposes rich categorization and company intelligence via the categorize endpoint. Use this to join IAB categories and company info with your rank metrics for better scoring and filtering. Example response below (use it as-is in tests while wiring schema):
{
"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 to use these fields with rank:
- domain.categories: Map to IAB for ad placement and brand safety controls. Join with category_rank from the Website Rank API to prioritize or block at a category level.
- domain.logo_url: Display a recognizable logo in admin tools or sales dashboards alongside rank and monthly_visits.
- objects.company: Enrich leads or signups with company name, size, and tags; correlate with monthly_visits for lead scoring.
- domain_registration_data: Add heuristics for risk (e.g., very young domains with high rank may warrant review).
- similar_domains: Expand monitoring or prospecting by pulling rank metrics for nearby domains.
How to act on rank and traffic intelligence
After parsing the Website Rank API response, most teams wire these fields into downstream logic:
- global_rank: Use as a baseline popularity score. Smaller numbers indicate stronger global presence. Useful for whitelisting or minimum-quality thresholds.
- country_rank: If you sell or advertise by region, country_rank helps ensure you’re prioritizing domains that are relevant to your target geography.
- category_rank: Combine with the IAB category from the categorize endpoint to decide whether a site is a leader in its vertical (e.g., business news vs. general news).
- monthly_visits: Helpful for lead qualification, spend caps, and publisher tiering.
- engagement: Evaluate bounce, visit duration, or page depth indicators to detect thin or low-quality traffic in fraud checks or referral audits.
- traffic_sources: Understand acquisition mix before running campaigns or affiliate deals; sudden shifts may be risk signals.
- top_countries: Align with your market coverage and compliance needs (e.g., content rights, localization, or legal review).
Schema design: storing rank and joining with categorization
Persist rank and traffic intelligence as a dedicated table keyed by domain (or registrable domain). Recommended columns:
- domain (text, primary key or unique)
- global_rank (int), country_rank (json/object with country code and rank), category_rank (json/object)
- monthly_visits (numeric), engagement (json/object), traffic_sources (json/object), top_countries (json/array)
- fetched_at (timestamp UTC)
Keep categorization and company data in separate tables keyed by domain to avoid large row payloads. Pre-join them in your analytics layer or denormalize for fast read paths (e.g., a materialized view that includes global_rank, primary IAB category, and company name).
Operational details that save time
Batching and concurrency
- Batch requests by domain list and parallelize within your safe concurrency limits. If you orchestrate with queues or workers, prefer a modest fixed concurrency and exponential backoff on HTTP 429 or 5xx responses.
- For overnight enrichment, throttle based on your job window and API quotas. For real-time checks, cache results aggressively (see below).
Caching and TTLs
- Cache per registrable domain (e.g., example.com) rather than per subdomain unless subdomain granularity is critical to your use case.
- Rank and monthly_visits typically do not need minute-level freshness. A TTL of 7–30 days is common; shorten for high-traffic publishers you monitor closely.
- Write-through caching: on cache miss, fetch from Klazify, store the full payload, and return normalized fields to callers.
Handling unknown or new domains
- If the response lacks certain fields for very new or low-traffic domains, treat them as null and route to a “needs review” queue instead of failing requests.
- Retry on temporary network errors; failed or unreachable calls are not billed, but you should still avoid noisy retries.
Mapping to your own taxonomy
- Use the categorize endpoint’s IAB mapping to anchor your taxonomy. Maintain a translation table from IAB categories to your internal verticals or brand safety tiers.
- Join category_rank from the rank API with your internal category to compute per-vertical authority scores.
Latency and timeouts
- Set client timeouts conservatively for server-to-server calls. If a real-time request exceeds your SLO, fall back to cached data.
- For ETL, prefer bulk workers instead of synchronous API calls from user-facing paths.
Putting it into your PHP stack
Most PHP apps use cURL or Guzzle for HTTP. Mirror the curl request shown above within a job or controller and parse the JSON to extract rank, visits, and engagement. Example structure in PHP with cURL:
<?php
$ch = curl_init("https://www.klazify.com/api/domain_traffic_intelligence");
$payload = json_encode(["url" => "https://example.com"]);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_TIMEOUT => 15
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode < 200 || $httpCode >= 300) {
// Not billed if unreachable; still, log and handle
throw new Exception("Klazify error: HTTP $httpCode");
}
$data = json_decode($response, true);
// Example usage; be defensive on missing fields
$rankSummary = [
"global_rank" => $data["global_rank"] ?? null,
"country_rank" => $data["country_rank"] ?? null,
"category_rank" => $data["category_rank"] ?? null,
"monthly_visits" => $data["monthly_visits"] ?? null,
"engagement" => $data["engagement"] ?? null
];
// Persist $rankSummary to your DB
?>
Wrap this in a service class and add a caching layer (Redis or your DB) keyed by domain. Prefer background jobs for bulk backfills and keep real-time calls small and cached.
Joining rank with categorization for real actions
- Brand safety and blocking: If the categorize endpoint returns an IAB segment you block, short-circuit before any rank logic. Otherwise, evaluate global_rank and engagement against your thresholds.
- CPA/ROAS checks: Raise bids or allocate budget when category_rank is strong within your target vertical and top_countries aligns with your markets.
- Lead routing: When a signup includes a domain, fetch monthly_visits and attach it to the lead record. Combine with company size and tags to route to enterprise or SMB teams.
- Security: For unusual referral spikes, inspect traffic_sources and compare top_countries with your normal mix to detect anomalies.
Testing and monitoring
- Golden domains: Maintain a small set of domains you query daily to validate data ingestion and schema compatibility.
- Schema drift alerts: If a field is missing or its type changes, alert and fallback to cached data while you investigate.
- Usage metrics: Track call volume, success rates, and average latency. Combine with cache hit rate goals to manage cost and performance.
Where to go next
- Review parameters and response shapes in the Documentation.
- If you manage multiple environments or teams, see MCP for control and management options.
- Create an account to obtain your API key and start testing within minutes: Register.
You can always return to klazify.com to explore more features like logo extraction, technology detection, and company enrichment that complement rank-based decisions.
FAQ
-
Which endpoint do I use for rank and traffic?
Use POST https://www.klazify.com/api/domain_traffic_intelligence with a Bearer token and JSON body containing {"url": "https://example.com"}. -
Can I combine rank with IAB categories?
Yes. Call the categorize endpoint to get IAB mapping and join it with category_rank to weight or filter by vertical. -
How should I cache results?
Cache per registrable domain for 7–30 days depending on your freshness needs. Always persist the full JSON to allow new scoring without re-calling the API. -
What happens if a call fails?
Klazify does not bill for failed or unreachable calls. Implement retries with backoff and fall back to cached data to protect user-facing paths. -
How do I start?
Create your API key with the 7-day trial and call the endpoint with curl. See the Documentation for field details.
Ready to score domains by popularity and engagement, with categories and company data in the same stack? Start your free trial and get your API key now: Register.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free