Core API Reference#
Universal models and parsing engine in nse_xbrl_parser.core.
High-Level Parsing Functions#
- async nse_xbrl_parser.parse_xbrl(content, source_name=None)[source]#
Parse an XBRL XML instance document asynchronously into a universal XBRLInstance.
- Parameters:
- Return type:
- async nse_xbrl_parser.parse_file(file_path)[source]#
Parse a local XBRL file asynchronously into a universal XBRLInstance.
- Parameters:
- Return type:
Parsing Engine#
- class nse_xbrl_parser.core.parser.AsyncXBRLParser[source]#
Bases:
objectHigh-performance parser for XBRL instance documents.
- async parse(content, source_name=None)[source]#
Parse XML string or bytes asynchronously without blocking the event loop.
- Parameters:
- Return type:
- async parse_file(file_path)[source]#
Parse a local XML file asynchronously.
- Parameters:
- Return type:
Universal Models#
- class nse_xbrl_parser.core.models.XBRLInstance(*, source=None, target_namespaces=<factory>, schema_refs=<factory>, contexts=<factory>, units=<factory>, facts=<factory>)[source]#
Bases:
BaseModelUniversal model representing a parsed XBRL instance document.
- Parameters:
- contexts: Dict[str, XBRLContext]#
- model_post_init(_XBRLInstance__context)[source]#
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- Parameters:
_XBRLInstance__context (Any)
- Return type:
None
- get_facts_by_tag(tag_name)[source]#
Lookup facts by case-insensitive tag name (e.g. ‘RevenueFromOperations’ or ‘ScripCode’).
- get_fact_value(tag_name, context_ref=None, default=None)[source]#
Get parsed value for a tag. If context_ref is specified, returns match for that context.
- get_fact_float(tag_name, context_ref=None, default=None)[source]#
Get numeric float value for a tag.
- get_entity_id()[source]#
Extract first available entity identifier (e.g. Scrip code or CIN).
- Return type:
str | None
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nse_xbrl_parser.core.models.XBRLFact(*, tag, namespace='', prefix='', context_ref, unit_ref=None, decimals=None, scale=None, raw_value, value=None)[source]#
Bases:
BaseModelRepresents a single parsed XBRL Fact.
- Parameters:
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nse_xbrl_parser.core.context.XBRLContext(*, context_id, entity_id='', entity_scheme='', period_type=PeriodType.DURATION, instant=None, start_date=None, end_date=None, dimensions=<factory>, scenario_dimensions=<factory>)[source]#
Bases:
BaseModelRepresents an XBRL context element.
- Parameters:
- period_type: PeriodType#
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nse_xbrl_parser.core.unit.XBRLUnit(*, unit_id, measure, measure_namespace=None, divide_numerator=None, divide_denominator=None)[source]#
Bases:
BaseModelRepresents an XBRL unit element (e.g. INR, Shares, Pure).
- Parameters:
Return True if unit represents shares.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].