Taxonomy API Reference#

Taxonomy registry and metadata loader in nse_xbrl_parser.taxonomy.

Taxonomy Registry#

class nse_xbrl_parser.taxonomy.registry.TaxonomyRegistry(catalog_path=None)[source]#

Bases: object

Registry managing all 58 official taxonomy definitions.

Parameters:

catalog_path (Optional[Path])

__init__(catalog_path=None)[source]#
Parameters:

catalog_path (Path | None)

Return type:

None

count()[source]#

Total number of registered taxonomies (58).

Return type:

int

get_all()[source]#

Get all registered taxonomies ordered by ID.

Return type:

List[TaxonomyInfo]

get_by_id(taxonomy_id)[source]#

Lookup taxonomy by its ID (1 to 58).

Parameters:

taxonomy_id (int)

Return type:

TaxonomyInfo | None

find_by_name(search_term)[source]#

Search taxonomies by keyword in name or regulation (e.g. ‘Shareholding’, ‘Financial’, ‘Governance’).

Parameters:

search_term (str)

Return type:

List[TaxonomyInfo]

get_financial_taxonomies()[source]#

Get all Regulation 33 Financial Results taxonomies.

Return type:

List[TaxonomyInfo]

get_corporate_governance_taxonomy()[source]#

Get Regulation 27(2) Corporate Governance taxonomy.

Return type:

TaxonomyInfo | None

get_shareholding_pattern_taxonomy()[source]#

Get Regulation 31 Shareholding Pattern taxonomy.

Return type:

TaxonomyInfo | None

class nse_xbrl_parser.taxonomy.registry.TaxonomyInfo(*, id, name, regulation, all_links=<factory>, taxonomy_links=<factory>, utility_links=<factory>)[source]#

Bases: BaseModel

Metadata describing a specific NSE/BSE filing taxonomy.

Parameters:
id: int#
name: str#
regulation: str#
property primary_taxonomy_url: str | None#

Return the direct download URL for the taxonomy package if available.

property primary_utility_url: str | None#

Return the direct download URL for the Excel utility if available.

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Downloader & Linkbase#

class nse_xbrl_parser.taxonomy.downloader.AsyncTaxonomyDownloader(cache_dir=None)[source]#

Bases: object

Async downloader and local cache for taxonomy schema and linkbase packages.

Parameters:

cache_dir (Optional[Path])

__init__(cache_dir=None)[source]#
Parameters:

cache_dir (Path | None)

Return type:

None

async download_taxonomy_archive(taxonomy, force_reload=False)[source]#

Download and cache the ZIP archive for a taxonomy category.

Parameters:
Return type:

Path

async load_taxonomy_metadata(taxonomy)[source]#

Download (if needed) and parse schemas and label linkbases from the taxonomy package.

Parameters:

taxonomy (TaxonomyInfo)

Return type:

Tuple[TaxonomySchema | None, TaxonomyLinkbase | None]

class nse_xbrl_parser.taxonomy.linkbase.TaxonomyLinkbase(*, labels=<factory>, calculations=<factory>)[source]#

Bases: BaseModel

Container for parsed linkbase data.

Parameters:
labels: Dict[str, str]#
calculations: List[CalculationArc]#
classmethod from_label_xml(content)[source]#

Parse a label linkbase file (*-lab.xml, *-label.xml).

Parameters:

content (bytes | str)

Return type:

TaxonomyLinkbase

get_label(concept_name, default=None)[source]#

Get the human-readable label for a concept name.

Parameters:
  • concept_name (str)

  • default (str | None)

Return type:

str

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class nse_xbrl_parser.taxonomy.schema.TaxonomySchema(*, target_namespace='', elements=<factory>)[source]#

Bases: BaseModel

Container for parsed taxonomy schemas.

Parameters:
target_namespace: str#
elements: Dict[str, SchemaElement]#
classmethod from_xsd_content(content)[source]#

Parse an XSD file into a TaxonomySchema model.

Parameters:

content (bytes | str)

Return type:

TaxonomySchema

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class nse_xbrl_parser.taxonomy.schema.SchemaElement(*, name, id=None, type=None, substitution_group=None, period_type=None, balance=None, is_abstract=False, is_nillable=True, target_namespace=None)[source]#

Bases: BaseModel

Represents a concept element declared in an XBRL taxonomy schema (.xsd).

Parameters:
  • name (str)

  • id (str | None)

  • type (str | None)

  • substitution_group (str | None)

  • period_type (str | None)

  • balance (str | None)

  • is_abstract (bool)

  • is_nillable (bool)

  • target_namespace (str | None)

name: str#
id: str | None#
type: str | None#
substitution_group: str | None#
period_type: str | None#
balance: str | None#
is_abstract: bool#
is_nillable: bool#
target_namespace: str | None#
property is_monetary: bool#
property is_shares: bool#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].