data
data
¶
NIP-11 relay information data models.
Defines the typed Pydantic models that represent the fields of a NIP-11 relay information document, including server limitations, retention policies, and fee schedules.
Note
All data classes extend BaseData and use
declarative FieldSpec parsing.
Complex nested structures (limitation, retention, fees) override
parse() with custom logic while still leveraging the base mechanism
for flat fields.
See Also
bigbrotr.nips.nip11.info.Nip11InfoMetadata:
Container that pairs these data models with fetch logs.
bigbrotr.nips.nip11.nip11.Nip11:
Top-level model that wraps the fetch result.
bigbrotr.nips.base.BaseData: Base class
providing the parse() / from_dict() / to_dict() interface.
Classes¶
Nip11InfoDataLimitation
¶
Bases: BaseData
Server-imposed limitations advertised in the NIP-11 document.
All fields are optional; relays may omit any or all of them.
See Also
Nip11InfoData: Parent
model that contains this as the limitation field.
Nip11InfoDataRetentionEntry
¶
Bases: BaseData
Single retention policy entry from a NIP-11 document.
The kinds field can contain plain integers or [start, end]
range pairs, requiring custom parsing logic in parse().
Note
The parse() override handles the mixed int | [int, int]
format specified by NIP-11. Lists are converted to tuples for
immutability, and to_dict() uses mode="json" to convert
tuples back to lists for JSON serialization.
See Also
Nip11InfoData: Parent
model that contains these as the retention list.
Functions¶
parse
classmethod
¶
Parse a retention entry, handling mixed int/range kinds lists.
Parameters:
-
data(Any) –Raw dictionary for a single retention entry.
Returns:
-
dict[str, Any]–Validated dictionary with
kinds,time, andcount.
Source code in src/bigbrotr/nips/nip11/data.py
to_dict
¶
Nip11InfoDataFeeEntry
¶
Bases: BaseData
Single fee entry (admission, subscription, or publication).
See Also
Nip11InfoDataFees: Parent model that groups fee entries by category.
Nip11InfoDataFees
¶
Bases: BaseData
Fee schedule categories from a NIP-11 document.
Contains nested lists of Nip11InfoDataFeeEntry objects for admission, subscription, and publication fees.
See Also
Nip11InfoData: Parent
model that contains this as the fees field.
Functions¶
parse
classmethod
¶
Parse fee schedule data with nested fee entry objects.
Parameters:
-
data(Any) –Raw dictionary containing fee category lists.
Returns:
-
dict[str, Any]–Validated dictionary with non-empty fee entry lists.
Source code in src/bigbrotr/nips/nip11/data.py
Nip11InfoData
¶
Bases: BaseData
Complete NIP-11 relay information document.
Overrides parse() to handle nested objects (limitation, retention,
fees) and to_dict() to use by_alias=True for the self
field, which maps to self_pubkey internally.
Note
The NIP-11 self field is a reserved Python keyword, so it is
mapped to self_pubkey with a Pydantic alias. The to_dict()
method uses by_alias=True to ensure the JSON output uses the
correct self key name as specified by the NIP.
See Also
Nip11InfoMetadata: Container that wraps this data model with fetch logs. Nip11InfoDataLimitation: Nested limitation sub-model. Nip11InfoDataFees: Nested fee schedule sub-model.
Attributes¶
Functions¶
parse
classmethod
¶
Parse a complete NIP-11 document with nested sub-objects.
Handles string fields, supported_nips list, and nested limitation, retention, and fees objects.
Parameters:
-
data(Any) –Raw dictionary from the relay HTTP response.
Returns:
-
dict[str, Any]–Validated dictionary suitable for model construction.
Source code in src/bigbrotr/nips/nip11/data.py
to_dict
¶
Serialize to a dictionary using field aliases (self instead of self_pubkey).