How to Get a Company's City and Country
You need to enrich a domain with accurate company location so downstream systems can route leads, score accounts, or comply with regional policies. By the end of this guide, you’ll be able to call a single Klazify endpoint to reliably get a company’s city, stateCode, and countryCode from a URL or domain, handle edge cases at scale, and plug the results into your data pipeline.
Why Klazify is the right API for extracting company city and country
When your goal is to determine a company’s physical location from its website, false positives and stale data break routing logic and reporting. Klazify analyzes full-site content and signals rather than relying solely on metadata, which helps it resolve the correct company entity and its location fields even when a site has multiple sections or languages.
- Accurate from real content: Klazify’s models evaluate the actual website content and associated signals. That improves resolution of the correct company entity and its city/state/country, which is critical for routing, territory assignment, and compliance workflows.
- Global coverage: The API works with domains in multiple languages, so you can enrich signups or accounts from anywhere without building separate parsers or local rules.
- Real-time analysis: Instead of a static database, Klazify fetches and analyzes fresh content. If a company updates its HQ details, your enrichment can reflect that.
- Industry-aware structure: Alongside location, you can access standardized categories mapped to IAB taxonomy to combine geo rules with industry-based logic (e.g., route only specific categories in certain regions).
- Simple integration: A single POST request gives you name, city, stateCode, countryCode, employeesRange, revenue, raised, and tags, so you can keep your enrichment code straightforward.
- Compliance and filtering: With clean location fields and IAB categories in the same response, you can implement allow/deny rules that blend geography and content classification.
Get started with a free trial and straightforward pricing on the Starter plan ($39.99/mo with a 7-day trial). Failed or unreachable calls are not billed. Create your account at Register.
The single request you need to retrieve city and country
Use the company-from-domain endpoint. Send the URL or domain, and parse the company payload for city, stateCode, and countryCode. The basic request looks like this:
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"}'
Key points:
- Method: POST
- Endpoint: https://www.klazify.com/api/domain_company
- Auth: Bearer token in the Authorization header
- Body: JSON with a single url field containing the domain or full URL
On success, you’ll receive the company block with:
- name: canonical company name
- city: city for company location
- stateCode: region/state code where applicable
- countryCode: two-letter country code
- employeesRange, revenue, raised, tags: extra enrichment fields you can store or use for scoring
What the JSON response looks like
Below is an official example showing how location and enrichment data are structured within the response. You’ll use the objects.company.* fields for city/state/country extraction, while the domain.* block provides categories and logo URL that you can also store.
{
"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 typically use for location enrichment:
- objects.company.city: company city
- objects.company.stateCode: abbreviated region/state code, if present
- objects.company.countryCode: two-letter country code
Additional enrichment options from the same response:
- objects.company.employeesRange, revenue, raised: scale indicators you can store for scoring or routing. Revenue is provided as an indicator per Klazify’s documentation.
- objects.company.tags: useful for segmentation or suppression.
- domain.categories and their confidence: map to your content filters or ad safety logic.
- domain.logo_url: display the company logo in your CRM or back office.
Copy-paste code: extract city and country in Python
The snippet below calls the company-from-domain endpoint, reads the location fields, and shows a simple in-memory cache to avoid re-calling the API for the same domain repeatedly.
import os
import time
import json
import requests
API_KEY = os.getenv("KLAZIFY_API_KEY", "YOUR_API_KEY")
API_URL = "https://www.klazify.com/api/domain_company"
# naive in-memory cache keyed by domain; replace with Redis or your DB
DOMAIN_CACHE = {}
CACHE_TTL_SECONDS = 60 * 60 * 24 # adjust to your refresh policy
def get_cached(domain):
item = DOMAIN_CACHE.get(domain)
if not item:
return None
value, expires_at = item
if expires_at < time.time():
DOMAIN_CACHE.pop(domain, None)
return None
return value
def set_cached(domain, value):
DOMAIN_CACHE[domain] = (value, time.time() + CACHE_TTL_SECONDS)
def fetch_company_location(domain_or_url):
cached = get_cached(domain_or_url)
if cached:
return cached
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {"url": domain_or_url}
resp = requests.post(API_URL, headers=headers, data=json.dumps(payload), timeout=30)
# Non-2xx responses are not billed if the call fails or is unreachable per Klazify
resp.raise_for_status()
data = resp.json()
# Defensive parsing in case objects/company is missing
company = (data.get("objects") or {}).get("company") or {}
location = {
"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") or []
}
set_cached(domain_or_url, location)
return location
if __name__ == "__main__":
# Example usage
domain = "https://cbsnews.com"
loc = fetch_company_location(domain)
print("Company:", loc["name"])
print("City:", loc["city"])
print("State/Region:", loc["stateCode"])
print("Country:", loc["countryCode"])
# Persist to your DB or use in routing logic
Plug this function into your signup enrichment, lead scoring, or account assignment flow. We recommend persisting the fields in your CRM or data warehouse, and refreshing on a schedule or when a domain’s status changes.
From API response to production: how to use the fields
- Normalize and store location:
- city: store as free text.
- stateCode: keep the short code where available. If your system needs full names, map these codes in your ETL layer.
- countryCode: store the two-letter code; if you need full country names, map via your standard ISO-3166-1 lookup.
- Use tags and size indicators:
- employeesRange/revenue/raised can guide routing (e.g., enterprise queues) or scoring (e.g., MQL thresholds).
- tags provide quick hints for segmentation or for suppressing irrelevant industries.
- Join with categorization:
- domain.categories lets you combine geo rules and content rules (e.g., allow only specific IAB branches in certain countries).
- Store category name alongside confidence so downstream systems can apply thresholds.
- Display logo:
- domain.logo_url can power your UI (CRM/company profile cards) without additional scraping.
Batching, rate limits, and throughput
At scale, keep calls efficient and within rate guidance. If you need high throughput:
- Use connection reuse (HTTP keep-alive) and parallel workers with sensible concurrency.
- Implement retry with backoff for transient errors; log failed domains for later replay. Per Klazify, failed or unreachable calls are not billed.
- Apply a domain cache to avoid unnecessary repeat lookups within your chosen TTL.
- Batch your input list through your job queue and persist intermediate progress to safely resume after interruptions.
For endpoint details and implementation notes, see the Documentation. If you need to control or monitor usage across multiple projects, check MCP.
Caching strategy and data freshness
Company HQ locations do not change frequently, but they do change. Cache results by domain and define a refresh policy aligned to your operational needs. A common pattern is:
- Short-term cache (hours to days) for high-traffic enrichment services to control latency and cost.
- Periodic re-validation via scheduled jobs for recently active domains.
- Invalidate cache when you detect a material site change (e.g., domain redirects to a new brand or returns different company name).
Store the raw response alongside parsed fields so you can reprocess if your mapping logic evolves (e.g., new region mapping tables or tag usage).
Handling unknown, new, or ambiguous domains
- Unknown domains: If the response lacks objects.company or key fields are null, queue the domain for a retry later. Persist an “unresolved” status so your CRM or product can show a pending state rather than blocking the user.
- Multiple locations: Use the returned city/state/country as the canonical HQ. If your business logic requires local presence, supplement with your own regional databases.
- Redirects and short links: Always send the final destination domain when possible. If your ingestion receives short links, resolve them before calling the API.
- Custom overrides: Maintain an allowlist of high-value accounts with curated locations to override automated enrichment when needed.
Mapping to your internal taxonomy
Most teams standardize on ISO country codes and internal region groupings (e.g., EMEA, APAC). Keep your own mapping tables for:
- countryCode → country name → internal region
- stateCode → full state/province name where required
- domain.categories → your content or industry taxonomy (if you use category-based routing)
This lets you pivot by region in BI, apply territory-based assignment in CRM, or gate product features by location.
End-to-end workflow example
- Input capture: When a user signs up with a company domain, enqueue the domain for enrichment.
- API call: POST to https://www.klazify.com/api/domain_company with the domain in the JSON body.
- Parse: Read objects.company.city, stateCode, countryCode. Also capture name, employeesRange, revenue, raised, tags for scoring.
- Normalize: Map countryCode and stateCode to your internal region tables.
- Persist: Upsert into your CRM/accounts table and a domain_enrichment table with a last_refreshed timestamp.
- Cache: Save the normalized payload and set a TTL to avoid redundant calls.
- Apply logic: Route leads/opportunities to the right team based on country or region; apply compliance rules if necessary.
- Monitor: Track enrichment hit rate, unresolved domains, and retry performance.
Operational details that save time
- Latency: Use regional workers and keep-alive HTTP sessions to minimize round trips.
- Idempotency: Deduplicate by normalized domain (lowercased, stripped of protocol and path) before calling the API.
- Error handling: Distinguish between transport errors (safe to retry) and valid responses missing data (mark as unresolved, retry on a schedule).
- Security: Keep the Bearer token server-side; never expose it in client apps.
- Observability: Log the request domain, HTTP status, and a short response summary (company.name, countryCode) for audits.
Pricing, trial, and where to go next
The Starter plan is $39.99/month and comes with a 7-day trial. Calls that fail or are unreachable are not billed. Create your free account and start enriching domains today: Register. Explore the full parameter and response details in the Documentation, and manage usage centrally via MCP. Learn more about the platform anytime at klazify.com.
FAQ
- What input should I send: full URL or just the domain?
Send either; the endpoint accepts a URL or domain. Normalizing to a domain (e.g., example.com) before calling helps with caching and deduplication. - Which location do city/state/country represent?
They represent the company location associated with that domain (e.g., HQ). Use these fields for territory routing and reporting; maintain overrides if you require office-level granularity. - How should I handle missing city or stateCode?
Persist nulls and retry later. If countryCode is present, you can proceed with region-level logic while city/state are pending. - Can I combine location with content categories for filtering?
Yes. Use domain.categories alongside countryCode to implement geo-specific allow/deny rules for content, ads, or access control. - What about rate limits and batching?
Implement concurrency with backoff, cache results per domain, and process your domain list via a job queue. See the docs for endpoint specifics.
Ready to enrich your pipeline with reliable company locations? Create a free account and start calling the API in minutes: Register. For implementation specifics, see the Documentation and learn more about Klazify at klazify.com.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free