How to Get the Employee Count in Python

November 11, 2026
How to Get the Employee Count in Python

Your team needs to enrich incoming domains with company size so you can qualify leads, route accounts, or segment users at signup. By the end of this guide you’ll fetch a company’s employee count range from a domain using Python, cache it safely, and wire it into your pipeline with the Klazify Domain Company endpoint.

Why Klazify is a strong fit for employee-count enrichment

Employee-size lookups seem simple until you hit coverage gaps, outdated sources, or latency spikes when you need results in real time. Klazify combines company enrichment with full-content website analysis, letting you extract employeesRange directly from a domain while also getting categorization and business context when you need it.

Illustration: How to Get the Employee Count in Python
  • Accurate company signals tied to live sites: Klazify analyzes actual site content, which keeps company metadata like employeesRange and tags grounded in what the organization presents online.
  • Global coverage: Works across multiple languages and regions so you can standardize “employee count” enrichment worldwide.
  • Real-time classification when needed: For new or edited sites, analysis avoids stale lookups from static databases.
  • IAB taxonomy is available: If your workflow combines firmographics with content classification, Klazify maps to IAB categories for downstream ad tech and brand safety policies.
  • Simple REST API: One request returns company fields such as name, location, employeesRange, revenue (as a range), raised, and tags, which are easy to integrate with CRM and scoring systems.
  • Compliance and filtering: When you must gate access or route users based on company size and industry, Klazify helps you detect, filter, or whitelist in one pass.

Explore the platform at klazify.com and keep reading to implement the Domain Company lookup in Python.

What you’ll build: use case and working path

Scenario: You operate a self-serve signup where users provide a website field. You want to enrich each domain with employeesRange (“1–10”, “51–200”, “100K+”, etc.), then route to SMB or Enterprise flows and sync firmographics to your CRM.

Working path:

  • Call POST https://www.klazify.com/api/domain_company with the user’s URL.
  • Extract objects.company.employeesRange (and name, tags, location if needed).
  • Cache the structured response under the domain to avoid re-calling.
  • Fallback behavior: handle unknown or unreachable sites cleanly.
  • Map employeesRange into your internal size buckets or directly store the string.

We’ll provide a copy-pasteable curl, a Python example, and guidance to operate this at scale.

Endpoint overview: Domain Company

Use the Domain Company endpoint to retrieve company data from a URL:

  • Method: POST
  • URL: https://www.klazify.com/api/domain_company
  • Auth: Bearer token
  • Body: JSON with a single field: url

Key fields in the response (inside objects.company):

  • name
  • city, stateCode, countryCode
  • employeesRange
  • revenue (a range, not an exact figure)
  • raised
  • tags

Pricing note: Starter is $39.99/mo with a 7-day trial. Failed or unreachable calls are not billed.

See the full API reference in the Documentation and check out platform status and controls via MCP. Visit the homepage at klazify.com to learn more.

Quickstart: curl request to get employeesRange

The following example shows how to post a domain and receive company data. Replace YOUR_API_KEY with your token.

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

On success, parse objects.company.employeesRange. You can also read name, location fields, revenue (range), raised, and tags to enrich CRM or apply routing rules.

Python example: enrich domains with employee count

This script accepts a list of domains, calls the Domain Company endpoint, extracts employeesRange, and applies simple caching to reduce repeat lookups.

import os
import time
import json
import hashlib
import requests

API_URL = "https://www.klazify.com/api/domain_company"
API_KEY = os.getenv("KLAZIFY_API_KEY") or "YOUR_API_KEY"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
}

CACHE_TTL_SECONDS = 60 * 60 * 24 * 7  # 7 days
CACHE_FILE = "klazify_cache.json"

def _load_cache():
    if not os.path.exists(CACHE_FILE):
        return {}
    with open(CACHE_FILE, "r", encoding="utf-8") as f:
        try:
            return json.load(f)
        except json.JSONDecodeError:
            return {}

def _save_cache(cache):
    with open(CACHE_FILE, "w", encoding="utf-8") as f:
        json.dump(cache, f)

def _cache_key(url):
    return hashlib.sha256(url.encode("utf-8")).hexdigest()

def get_company_info(url):
    cache = _load_cache()
    key = _cache_key(url)
    now = int(time.time())

    if key in cache:
        entry = cache[key]
        if now - entry.get("ts", 0) < CACHE_TTL_SECONDS:
            return entry.get("data")

    payload = {"url": url}
    resp = requests.post(API_URL, headers=HEADERS, json=payload, timeout=15)
    # Non-2xx responses should be handled; failed/unreachable calls aren't billed.
    if not resp.ok:
        return {"error": f"request_failed_{resp.status_code}", "url": url}

    data = resp.json()
    cache[key] = {"ts": now, "data": data}
    _save_cache(cache)
    return data

def extract_employees_range(api_response):
    # Defensive parsing in case fields are missing:
    try:
        company = api_response["objects"]["company"]
        return company.get("employeesRange")
    except (TypeError, KeyError):
        return None

if __name__ == "__main__":
    domains = [
        "https://cbsnews.com",
        "https://example.com"
    ]
    results = []
    for d in domains:
        r = get_company_info(d)
        size = extract_employees_range(r)
        # Additional optional fields:
        name = (r.get("objects", {}).get("company", {}) or {}).get("name")
        country = (r.get("objects", {}).get("company", {}) or {}).get("countryCode")
        results.append({"url": d, "name": name, "employeesRange": size, "countryCode": country})

    print(json.dumps(results, indent=2))

How to use the output:

  • employeesRange: Use directly to gate signup flows (e.g., “51–200” routes to sales) or convert it into internal tiers.
  • name, countryCode, stateCode, city: Auto-fill CRM company records and normalize addresses.
  • revenue (range) and raised: Build firmographic scoring without handling exact financial figures.
  • tags: Map capabilities/vertical hints into your own taxonomy for routing or targeting.

Official sample response and what to read

Below is an official sample response format from the Klazify docs. Note the presence of objects.company with employeesRange and other company fields you can reuse across pipelines.

{
    "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"
    ]
}

Fields you’ll use for size enrichment and context:

  • objects.company.employeesRange: The company’s employee count range to drive routing and segmentation.
  • objects.company.name: Normalized company name for CRM.
  • objects.company.city, stateCode, countryCode: Location data for region-level rules.
  • objects.company.revenue: Revenue represented as a range, useful for scoring.
  • objects.company.raised: Aggregate fundraising where available; use as a qualification signal.
  • objects.company.tags: Business tags to accelerate categorization and targeting.
  • domain.categories and IAB mapping: If you also need content-level classification for brand safety or ad placement, use these fields alongside firmographics.

How to act on employeesRange in your pipeline

  • Signup flows: Route “10–50” to SMB onboarding and “1000+” to assisted sales.
  • CRM enrichment: Upsert employeesRange, name, and location into account objects; keep your scoring model simple with ranges rather than exact numbers.
  • Ad targeting and brand safety: Combine employeesRange with IAB categories to gate where ads run or who qualifies for campaigns.
  • Customer data platforms: Use employeesRange as a trait for downstream segments.

Field reference at a glance

Field Type Description Common Uses
name string Canonical company name CRM account naming, deduplication
city, stateCode, countryCode string Primary location Regional routing, compliance, territory assignment
employeesRange string Employee count range Qualification, routing, segmentation
revenue number (range) Revenue range, not an exact figure Lead scoring, cohort analysis without handling exact values
raised number or null Total capital raised Signal for growth-stage prioritization
tags array of strings Business-relevant tags Feature targeting, vertical mapping

Operational guidance: scale, caching, and resiliency

Batching and throughput

If you need to enrich large lists, parallelize requests with modest concurrency and backoff. Group domains by TLD or customer priority. Persist results to avoid repeated lookups.

Caching policy

  • Cache by normalized domain (e.g., lowercase, strip query/fragment, and prefer https scheme).
  • TTL suggestions: 7–30 days for most use cases. Refresh sooner for high-velocity leads.
  • Keep a last-seen timestamp and invalidate on customer-triggered re-verification.

Error handling

  • Failed or unreachable calls are not billed, but you should still implement retries with exponential backoff and circuit breaking to protect your pipeline.
  • Gracefully return employeesRange = null when unknown, and fall back to user-provided input or deferred enrichment.

Unknown or new domains

  • Return a “pending enrichment” state in your UI while retrying in the background.
  • Offer a manual override if a customer provides verified data.
  • Schedule a delayed recheck; some new sites get indexed with more context after initial discovery.

Mapping to your internal taxonomy

  • employeesRange: Map each string range to internal tiers (e.g., tier1 = “1–10”, tier2 = “11–50”, etc.). Store both raw and mapped values for transparency.
  • tags and IAB categories: Maintain a lookup table so your product lines or sales teams see familiar labels.

Data pipeline fit

  • Ingest layer: Call Klazify synchronously for signup flows with a short timeout; defer deeper enrichment to a background job.
  • Warehouse: Store the full company object as JSON along with parsed columns (employeesRange, countryCode) for analytics and debugging.
  • CDP/CRM sync: Upsert the latest employeesRange and a last_update timestamp to avoid flapping.

Security, latency, and reliability notes

  • Authenticate with Bearer tokens and secure them in your secrets manager.
  • Use read timeouts in your HTTP client; 10–20 seconds is a practical ceiling for synchronous forms.
  • Implement idempotency at your job layer: if an event retriggers enrichment, use a cache hit instead of refetching immediately.

End-to-end example: qualifying a signup by employee size

  1. User submits a form with website = example.org.
  2. Your backend posts {"url":"https://example.org"} to /api/domain_company.
  3. Parse objects.company.employeesRange = "201–500".
  4. Route the account to your mid-market playbook, tag the CRM record with employeesRange, and assign to the correct territory based on countryCode.
  5. Persist the response JSON in your data store with a 14-day TTL. Show the enriched size in the admin console.

Testing and monitoring

  • Unit tests: Validate parsing when objects.company is missing or fields are null.
  • Smoke tests: Run scheduled checks on a stable set of domains to detect unexpected schema or latency changes.
  • Observability: Track enrichment success rate, median/95th latency, and cache hit ratio.

Next steps

  • Combine employeesRange with IAB categories for content-aware targeting and brand-safety use cases alongside firmographic routing.
  • Enrich technology and similar domains for competitor insights, if relevant to your qualification flow.
  • Document your internal size-tier mappings and expose them in your admin tooling.

Create your free account to start integrating: Register.

FAQ

How do I authenticate to the API?
Use the Authorization: Bearer YOUR_API_KEY header. Keep the token in your secrets manager and rotate it periodically.

Which field contains the employee count?
Read objects.company.employeesRange. It’s a range string suitable for routing, scoring, and segmentation.

What if a domain has no company data?
Return a null employeesRange in your system, retry later with backoff, and optionally prompt the user to confirm their company size.

Can I also classify the domain’s content?
Yes. The categorization payload includes IAB-mapped categories under domain.categories, which you can use for filtering, brand safety, or targeting.

Are failed requests billed?
No. Failed or unreachable calls are not billed.

Ready to use Klazify?

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

Get Started Free