Industry Code Validation in Python — NAICS & NACE Classification
Every business operating in a regulated environment needs a valid industry classification code. NAICS covers North America, NACE covers the European Union — both are standardised systems for categorising business activities. Here's how to validate them properly in Python.
In this guide
1. What are industry codes?
Industry classification codes are standardised systems for categorising the economic activities of businesses and organisations. They assign a numeric (or alphanumeric) code to every type of business activity — from agriculture and mining to software development and financial services.
The two most widely used systems are NAICS (North American Industry Classification System), used by the United States, Canada, and Mexico, and NACE (Nomenclature statistique des Activités économiques dans la Communauté Européenne), the standard across the European Union.
These codes appear everywhere: business registrations, tax filings, regulatory reports, loan applications, insurance underwriting, and KYC (Know Your Customer) processes. They provide a common language for government agencies, financial institutions, and businesses to describe what a company does.
Both systems are periodically revised — NAICS was last updated in 2022 and NACE uses Rev. 2 as its current edition. Using outdated codes can lead to misclassification, compliance issues, and rejected filings.
2. NAICS vs NACE comparison
While both systems serve the same purpose — classifying business activities — they differ in structure, geography, and granularity.
| Feature | NAICS | NACE |
|---|---|---|
| Region | North America (US, CA, MX) | European Union |
| Current edition | 2022 | Rev. 2 |
| Code format | 2–6 digit numeric | Letter + 2–4 digit numeric |
| Top level | 20 sectors (2-digit) | 21 sections (A–U) |
| Deepest level | 6-digit (national detail) | 4-digit class |
| Maintained by | US Census Bureau / StatCan / INEGI | Eurostat |
| Replaces | SIC (Standard Industrial Classification) | Earlier NACE Rev. 1 |
system parameter to specify which classification you want.3. Code structure and hierarchy
Both NAICS and NACE organise industries into a tree-like hierarchy, from broad sectors down to specific activity types.
NAICS structure (2–6 digits)
| Level | Digits | Example | Description |
|---|---|---|---|
| Sector | 2 | 54 | Professional, Scientific, and Technical Services |
| Subsector | 3 | 541 | Professional, Scientific, and Technical Services |
| Industry Group | 4 | 5415 | Computer Systems Design and Related Services |
| NAICS Industry | 5 | 54151 | Computer Systems Design and Related Services |
| National Industry | 6 | 541511 | Custom Computer Programming Services |
NACE structure (Sections A–U)
| Level | Format | Example | Description |
|---|---|---|---|
| Section | Letter (A–U) | J | Information and communication |
| Division | 2-digit | 62 | Computer programming, consultancy and related activities |
| Group | 3-digit (XX.X) | 62.0 | Computer programming, consultancy and related activities |
| Class | 4-digit (XX.XX) | 62.01 | Computer programming activities |
4. Why industry code validation matters
KYC and onboarding
Financial institutions and payment processors require a valid industry code during customer onboarding. An invalid or unrecognised code can block account opening, delay merchant approvals, or trigger enhanced due diligence. Validating industry codes at the point of entry streamlines KYC workflows.
Risk assessment
Insurance underwriters, lenders, and compliance teams use industry codes to assess risk profiles. A misclassified business may receive incorrect pricing, inappropriate coverage, or be flagged (or missed) during sanctions screening. Accurate industry codes are foundational to risk models.
Regulatory reporting
Government agencies require industry codes in tax filings, statistical surveys, and regulatory submissions. The US Census Bureau, BLS, IRS, and EU statistical offices all rely on accurate NAICS or NACE codes. Filing with an invalid code can result in rejected submissions or audit flags.
SIC replacement
The Standard Industrial Classification (SIC) system, introduced in 1937, has been largely superseded by NAICS (in North America) and NACE (in the EU). However, many legacy systems still store SIC codes. Migrating to current NAICS or NACE codes requires validation to ensure the new codes are recognised and correctly mapped.
5. The right solution
The IsValid Industry Code API provides two endpoints: a validate endpoint that checks whether an industry code is valid and returns its description, hierarchy, and system information, and a list endpoint that returns all codes for a given system, level, or parent code.
Get your free API key at isvalid.dev. The free tier includes 100 calls per day — enough for most development and low-volume production use.
Full parameter reference and response schema: Industry Code Validation API docs →
6. Python code example
Using the isvalid-sdk Python SDK or the requests library. Install with pip install isvalid-sdk or pip install requests.
# industry_validator.py import os from isvalid_sdk import IsValidConfig, create_client iv = create_client(IsValidConfig(api_key=os.environ["ISVALID_API_KEY"])) # ── Validate a NAICS code ─────────────────────────────────────────────────── result = iv.industry("541511") print(result["valid"]) # True print(result["system"]) # 'NAICS' print(result["description"]) # 'Custom Computer Programming Services' print(result["level"]) # '6-digit' print(result["hierarchy"]) # [{'code': '54', 'description': '...'}, ...] # ── Validate a NACE code ──────────────────────────────────────────────────── nace = iv.industry("62.01", system="nace") print(nace["valid"]) # True print(nace["system"]) # 'NACE' print(nace["description"]) # 'Computer programming activities' print(nace["edition"]) # 'Rev. 2' print(nace["level"]) # 'class' print(nace["parent"]) # '62.0' # ── Check a sector-level NAICS code ───────────────────────────────────────── sector = iv.industry("54") print(sector["description"]) # 'Professional, Scientific, and Technical Services' print(sector["level"]) # '2-digit' print(sector["edition"]) # '2022'
You can also list industry codes by system, level, or parent:
# List all 4-digit NAICS industry groups under sector 54 groups = iv.industry.list(system="naics", level="4-digit", parent="54") for g in groups: print(f"{g['code']} — {g['description']}") # → 5411 — Legal Services # → 5412 — Accounting, Tax Preparation, Bookkeeping... # → ... # → 5415 — Computer Systems Design and Related Services # → ...
In a Flask application, you might validate industry codes during business onboarding:
# app.py (Flask) import os import requests as http from flask import Flask, request, jsonify app = Flask(__name__) API_KEY = os.environ["ISVALID_API_KEY"] BASE_URL = "https://api.isvalid.dev" def validate_industry(code: str, system: str | None = None) -> dict: params = {"value": code} if system: params["system"] = system resp = http.get( f"{BASE_URL}/v0/industry", params=params, headers={"Authorization": f"Bearer {API_KEY}"}, ) resp.raise_for_status() return resp.json() @app.post("/businesses") def create_business(): data = request.get_json() # Determine the system based on region country = data.get("country", "") system = "naics" if country in ("US", "CA", "MX") else "nace" # Validate the industry code try: check = validate_industry(data["industry_code"], system=system) except http.RequestException: return jsonify(error="Industry code validation service unavailable"), 502 if not check["valid"]: return jsonify( error="Invalid industry code", hint=f"Provide a valid {system.upper()} code", ), 400 # Use the validated data business = save_business( name=data["name"], industry_code=check["code"], industry_description=check["description"], industry_system=check["system"], industry_level=check["level"], hierarchy=check["hierarchy"], country=country, ) return jsonify(success=True, business=business)
list endpoint to build industry code pickers in your UI. Start with sectors (NAICS) or sections (NACE), then drill down through the hierarchy — giving users a guided classification experience.7. cURL example
Validate a NAICS code:
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.isvalid.dev/v0/industry?value=541511"
Validate a NACE code:
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.isvalid.dev/v0/industry?value=62.01&system=nace"
Validate a NAICS sector:
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.isvalid.dev/v0/industry?value=54&system=naics"
List NAICS codes under a parent:
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.isvalid.dev/v0/industry/list?system=naics&level=4-digit&parent=54"
8. Understanding the response
Response for a NAICS code:
{ "valid": true, "system": "NAICS", "edition": "2022", "code": "541511", "description": "Custom Computer Programming Services", "level": "6-digit", "parent": "54151", "hierarchy": [ { "code": "54", "description": "Professional, Scientific, and Technical Services" }, { "code": "541", "description": "Professional, Scientific, and Technical Services" }, { "code": "5415", "description": "Computer Systems Design and Related Services" }, { "code": "54151", "description": "Computer Systems Design and Related Services" } ] }
Response for a NACE code:
{ "valid": true, "system": "NACE", "edition": "Rev. 2", "code": "62.01", "description": "Computer programming activities", "level": "class", "parent": "62.0", "hierarchy": [ { "code": "J", "description": "Information and communication" }, { "code": "62", "description": "Computer programming, consultancy and related activities" }, { "code": "62.0", "description": "Computer programming, consultancy and related activities" } ] }
Invalid industry code:
{ "valid": false }
| Field | Type | Description |
|---|---|---|
| valid | boolean | Whether the industry code exists in the specified system |
| system | string | Classification system: "NAICS" or "NACE" |
| edition | string | Edition of the classification: "2022" for NAICS, "Rev. 2" for NACE |
| code | string | The normalised industry code |
| description | string | Official description of the industry activity |
| level | string | Hierarchy level (e.g. "2-digit", "6-digit" for NAICS; "section", "class" for NACE) |
| parent | string | null | Parent code in the hierarchy, or null for top-level codes |
| hierarchy | array | Full ancestor chain from the top level down to the parent |
hierarchy array contains ancestors only — it does not include the code itself. For top-level codes (NAICS sectors or NACE sections), the parent field is null and hierarchy is an empty array.9. Edge cases to handle
NAICS 2022 vs older editions
NAICS is revised every five years (2002, 2007, 2012, 2017, 2022). Codes that existed in the 2017 edition may have been split, merged, or renumbered in 2022. The API validates against the current 2022 edition. If your system stores historical NAICS codes, verify them against the current edition before using them in new filings.
# Code 519130 was valid in NAICS 2017 but restructured in 2022 old = iv.industry("519130") print(old["valid"]) # may be False in 2022 edition # Always validate against the current edition current = iv.industry("541511") print(current["valid"]) # True print(current["edition"]) # '2022'
NACE Rev. 2 specifics
NACE codes use a dot separator between the division and group/class digits (e.g. 62.01). The API expects this format for NACE codes. NACE sections are single letters (A through U) and represent the broadest classification level.
# NACE codes use dot notation nace = iv.industry("62.01", system="nace") print(nace["valid"]) # True # NACE section (single letter) section = iv.industry("J", system="nace") print(section["description"]) # 'Information and communication'
Cross-system mapping
NAICS and NACE are independent systems — there is no one-to-one mapping between them. A NAICS code like 541511 (Custom Computer Programming Services) roughly corresponds to NACE 62.01 (Computer programming activities), but the boundaries differ. If your application needs to support both systems, validate each code against its own system using the system parameter rather than attempting to convert between them.
Auto-detection vs explicit system
When the system parameter is omitted, the API attempts to auto-detect the classification system based on the code format. For unambiguous codes this works well, but some numeric codes could theoretically exist in both systems. For production use, always specify the system parameter explicitly to avoid ambiguity.
10. Summary
See also
Validate industry codes instantly
Free tier includes 100 API calls per day. No credit card required. Validate any NAICS or NACE code and get descriptions, hierarchy, and edition info.