Integrate the Employee Count API in Python
A signup form may collect a company website but not the size of the organization behind it. With Klazify’s company endpoint, you can submit that website from Python, read the returned employee range, and pass it to a CRM or routing pipeline without treating it as an exact headcount.
Why use domain intelligence for employee enrichment?
A company domain gives an enrichment workflow a useful starting point: it connects the signup to public website and company information without requiring the user to enter every attribute. Klazify combines company data with domain intelligence, so a team can use employee ranges for account sizing and use website categorization or business tags for additional context.
That distinction matters. An employee range describes company size, while a category or tag describes a website or business; neither should be substituted for the other. For example, the Consumer Electronics tag in the response below provides context about the business, but it does not tell you how many people work there.
Klazify also supports content analysis and IAB taxonomy mapping for classification workflows. That can help a team audit content or apply filtering rules alongside enrichment, but the Python integration here focuses on the company fields needed to route and enrich accounts. Use the Documentation to check the current endpoint behavior and integration details before deploying.
Send a company lookup
Klazify’s company endpoint accepts a URL in a JSON request. Create an API key, then replace YOUR_API_KEY in this request with that key:
curl -X POST "https://www.klazify.com/api/domain_company" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://cbsnews.com"}'
The request submits one URL. In a signup pipeline, use the company website supplied by the user rather than the illustrative domain above. Keep the key in a secret store or environment variable in production rather than embedding it in application source.
Call the endpoint from Python
The following example uses Python’s standard library. It accepts a website URL as a command-line argument, reads the API key from KLГAZIFY_API_KEY, and extracts company data when it is present in the response structure shown later in this article.
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
API_URL = "https://www.klazify.com/api/domain_company"
def fetch_company(website_url, api_key):
payload = json.dumps({"url": website_url}).encode("utf-8")
request = Request(
API_URL,
data=payload,
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
},
method="POST",
)
with urlopen(request, timeout=30) as response:
return json.load(response)
def company_fields(data):
if not isinstance(data, dict) or data.get("success") is False:
return None
objects = data.get("objects")
if not isinstance(objects, dict):
return None
company = objects.get("company")
if not isinstance(company, dict):
return None
return {
"name": company.get("name"),
"city": company.get("city"),
"stateCode": company.get("stateCode"),
"countryCode": company.get("countryCode"),
"employeesRange": company.get("employeesRange"),
"revenue": company.get("revenue"),
"raised": company.get("raised"),
"tags": company.get("tags"),
}
def main():
if len(sys.argv) != 2:
print("Usage: python enrich.py WEBSITE_URL", file=sys.stderr)
return 1
api_key = os.environ.get("KLГAZIFY_API_KEY")
if not api_key:
print("Set KLГAZIFY_API_KEY before running.", file=sys.stderr)
return 1
try:
data = fetch_company(sys.argv[1], api_key)
except HTTPError as exc:
print(f"API returned HTTP {exc.code}", file=sys.stderr)
return 1
except (URLError, TimeoutError) as exc:
print(f"Request failed: {exc}", file=sys.stderr)
return 1
except (json.JSONDecodeError, UnicodeDecodeError) as exc:
print(f"Could not read the JSON response: {exc}", file=sys.stderr)
return 1
company = company_fields(data)
if company is None:
print("Company data unavailable or response needs review.", file=sys.stderr)
return 1
print(json.dumps(company, indent=2))
return 0
if __name__ == "__main__":
sys.exit(main())
Save the script as enrich.py, set the environment variable, and pass the website URL as its argument. The script prints the fields it finds; a missing field remains null rather than becoming an invented value.
The extraction logic checks for the objects.company structure in the example below. If your company endpoint response has a different shape, inspect the response and adapt that extraction step before connecting it to your CRM. A missing company object should be reviewed as unavailable data, not interpreted as a company with zero employees.
Interpret the returned company data
This example shows a broader Klazify response, including company information and domain signals. It illustrates the fields a pipeline can read; the curl request above submits a different website, so its returned values should not be expected to match this example.
{
"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"
]
}
The primary field for this integration is objects.company.employeesRange. Here it is 100K+: retain that string as a range indicator, not as an exact employee count. The company’s name, location codes and tags can provide supporting context when a sales or operations team reviews the enriched record.
The example’s revenue value is numeric, while revenue enrichment may be used as a range rather than an exact figure. Preserve the returned value and its meaning as documented; do not assume a currency, reporting period or precision from this example. raised is null, which means the sample does not supply a value—not that the company raised nothing.
| Field | Use in the pipeline | Handling |
|---|---|---|
employeesRange | Account sizing or routing | Store the returned range; do not turn it into an exact count. |
name | Display company context | Keep the submitted domain alongside it for traceability. |
city, stateCode, countryCode | Location enrichment | Allow missing values and map codes to internal fields. |
revenue, raised | Financial context | Preserve supplied values and nulls without inferring units. |
tags | Business context | Map known tags to internal labels; retain the originals. |
The separate domain.categories array contains classification names and confidence values; one entry also includes an IAB mapping. Those fields are useful for a classification or advertising workflow, but they are not employee counts. Likewise, the logo, technology and registration data in this broader example should not be assumed to be present in every company lookup.
Make the enrichment reliable at scale
For a signup flow, decide whether the employee range must be available before the user can proceed. If it is only needed for later routing, enqueue the lookup and update the CRM asynchronously. That keeps a slow or unreachable external request from blocking account creation.
Batch work without overwhelming the endpoint
The request shown above submits one URL at a time. For a backlog, place domains in a queue, deduplicate them, and use controlled worker concurrency rather than sending every request at once. Check your account’s applicable rate limits and adjust throughput to them; do not hard-code an assumed quota.
Retry temporary failures with backoff and a bounded retry policy. Separate those failures from successful responses that lack company data: repeatedly retrying an unknown domain immediately may not produce a different result. Klazify states that failed or unreachable calls are not billed, but your application should still track outcomes and avoid unnecessary requests.
Cache by domain and preserve provenance
Cache successful enrichment results against a normalized domain key so repeated signups from the same organization do not trigger duplicate lookups. Keep the submitted URL and the lookup time with the result, and choose a refresh interval appropriate to how quickly your routing decisions need to reflect company changes.
Normalize carefully: remove obvious formatting differences, but do not assume that every subdomain or URL path represents the same business. If your application consolidates domains, make that an explicit rule and retain the original input for review. Use a shorter review or refresh policy for missing data than for a stable result if that fits your workload.
Map ranges, tags and unknowns explicitly
Create a versioned mapping between returned employee-range strings and your own account-size labels. Keep both the original employeesRange and the internal label so you can reprocess records if your routing rules change. Route an unrecognized range to an unknown or review state rather than guessing its boundaries.
Apply the same discipline to tags and website categories. Maintain a mapping from values you actually receive to your internal taxonomy, and retain unmapped values for review. A business tag, an IAB category and an employee range answer different questions, so keep them in separate fields.
For new, unreachable or otherwise unknown domains, preserve the signup and mark enrichment as unavailable or pending review. Log the outcome without exposing the API key, and monitor missing company objects, unexpected response shapes and request failures separately. This makes it easier to distinguish a data-coverage issue from an integration problem.
FAQ
Is employeesRange an exact headcount?
No. Store it as the returned range indicator and use your own mapping if a CRM requires an account-size label.
What happens if a company field is missing?
Treat it as unknown. The Python example returns null for absent fields and reports an unavailable company object rather than assigning a zero or an empty company size.
Can I use categories to determine employee count?
No. Categories and tags describe website or business context; use employeesRange for employee-size enrichment. You can retain both kinds of data for separate routing and analysis decisions.
What does it cost to start?
The Starter plan is $39.99 per month with a 7-day trial. Failed or unreachable calls are not billed; check the current account details before choosing a production plan.
Can I use Klazify with an MCP workflow?
Klazify also provides an MCP integration. For the Python pipeline above, the REST company endpoint is the direct path to the returned fields.
Ready to enrich company signups? Register for a free account, obtain your API key, and test the company lookup with a domain from your own workflow.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free