API Reference
This page catalogs the public API surface of the folio package: the FOLIO class, the OWLClass and OWLObjectProperty Pydantic models, FOLIOConfiguration, plus module constants and the FOLIOTypes enum. For tutorial-style usage, see the topical sub-pages linked at the bottom.
Module exports
The top-level folio package re-exports a small, stable surface from its submodules. These are the only names guaranteed by __all__.
| Name | Source | Description |
|---|---|---|
FOLIO | folio.graph | Main client class for loading and querying the ontology. |
FOLIOTypes | folio.graph | Enum of the 24 top-level taxonomy branches. |
FOLIO_TYPE_IRIS | folio.graph | Dict[FOLIOTypes, str] mapping each branch to its short IRI. |
OWLClass | folio.models | Pydantic model representing an OWL class. |
OWLObjectProperty | folio.models | Pydantic model representing an OWL object property. |
NSMAP | folio.models | lxml namespace map used by OWL/XML serialization and JSON-LD @context. |
The package also exposes standard dunder metadata:
| Attribute | Value (0.3.5) |
|---|---|
__version__ | "0.3.5" |
__author__ | "ALEA Institute" |
__license__ | "MIT" |
__description__ | "Python library for FOLIO, the Federated Open Legal Information Ontology" |
__url__ | "https://openlegalstandard.org/" |
Everything else (FOLIOConfiguration, DEFAULT_* constants, get_logger) lives in folio.config, folio.graph, and folio.logger, and must be imported from those submodules directly.
class FOLIO
The main entry point. from folio import FOLIO. Instantiating a FOLIO() loads the ontology (from cache if available, otherwise from GitHub), parses it into Pydantic models, and builds the in-memory indices used by every lookup, search, and traversal method.
Constructor
FOLIO(
source_type: str = "github",
http_url: Optional[str] = None,
github_repo_owner: str = "alea-institute",
github_repo_name: str = "FOLIO",
github_repo_branch: str = "2.0.0",
use_cache: bool = True,
llm: Optional[BaseAIModel] = None,
llm_kwargs: Optional[dict] = None,
effort: Optional[str] = None,
tier: Optional[str] = None,
) -> None| Parameter | Type | Default | Description |
|---|---|---|---|
source_type | str | "github" | Where to fetch the OWL file. Either "github" or "http". |
http_url | Optional[str] | None | Required when source_type="http"; ignored otherwise. |
github_repo_owner | str | "alea-institute" | GitHub owner of the FOLIO repo. |
github_repo_name | str | "FOLIO" | GitHub repo name. |
github_repo_branch | str | "2.0.0" | Branch, tag, or ref to load. This is the correct parameter name — not branch. |
use_cache | bool | True | If True, load from ~/.folio/cache/ when available and write back after fetching. |
llm | Optional[BaseAIModel] | None | An alea_llm_client model to use for search_by_llm. If None and the [search] extra is installed, auto-initialized to alea_llm_client.OpenAIModel(model="gpt-5.4"). |
llm_kwargs | Optional[dict] | None | Extra kwargs forwarded to LLM calls (e.g. reasoning_effort, service_tier). Merged with values derived from effort and tier. |
effort | Optional[str] | None | Universal effort level: "low", "medium", or "high". Translated per-provider via alea_llm_client.get_llm_kwargs. |
tier | Optional[str] | None | Universal service tier: "flex", "standard", or "priority". Translated per-provider. |
FOLIO(branch="main") raises TypeError. The parameter is github_repo_branch. The same full names apply to github_repo_owner and github_repo_name — there is no short form.
Public attributes
All attributes below are set up during __init__ and parse_owl. Everything prefixed with _ (e.g. _cached_triples, _label_trie, _prefix_cache) is internal and may change without notice.
| Attribute | Type | Description |
|---|---|---|
classes | List[OWLClass] | Every parsed class, in insertion order. len(f) == len(f.classes). |
object_properties | List[OWLObjectProperty] | Every parsed owl:ObjectProperty. |
iri_to_index | Dict[str, int] | IRI → position in classes. Public IRI lookup. |
iri_to_property_index | Dict[str, int] | IRI → position in object_properties. |
label_to_index | Dict[str, List[int]] | Primary rdfs:label → list of class indices. |
alt_label_to_index | Dict[str, List[int]] | skos:altLabel, skos:prefLabel, and skos:hiddenLabel → class indices. |
property_label_to_index | Dict[str, List[int]] | Property label → list of property indices. |
class_edges | Dict[str, List[str]] | Parent IRI → list of child IRIs (forward adjacency). |
triples | List[Tuple[str, str, str]] | Every parsed triple as (subject_iri, prefixed_predicate, object). ~130k for 2.0.0. |
title | Optional[str] | dc:title from the ontology header. |
description | Optional[str] | dc:description from the ontology header. |
llm | Optional[BaseAIModel] | LLM client used by search_by_llm. Auto-initialized to OpenAIModel("gpt-5.4") when the [search] extra is installed. |
llm_kwargs | dict | Extra kwargs merged into every LLM call. Populated from llm_kwargs, effort, tier. |
source_type | str | "github" or "http". |
http_url | Optional[str] | HTTP URL when source_type="http". |
github_repo_owner | str | Owner, e.g. "alea-institute". |
github_repo_name | str | Repo, e.g. "FOLIO". |
github_repo_branch | str | Branch/tag/ref. |
use_cache | bool | Whether local caching is enabled. |
tree | Optional[lxml.etree._Element] | Root element of the parsed OWL XML tree. |
parser | Optional[lxml.etree.XMLParser] | Parser used by parse_owl. |
There is no classes_by_iri attribute. To look up a class by IRI use f[iri] (recommended) or f.classes[f.iri_to_index[iri]]. To check membership, use iri in f (invokes __contains__).
Loading and lifecycle
These are mostly staticmethods you call on the class itself (FOLIO.load_owl(...)), plus refresh() and the parse helpers which operate on an instance.
| Method | Signature | Description |
|---|---|---|
list_branches | FOLIO.list_branches(repo_owner="alea-institute", repo_name="FOLIO") -> List[str] | Query the GitHub API for available branches on the FOLIO repo. |
load_cache | FOLIO.load_cache(cache_path=DEFAULT_CACHE_DIR, source_type="github", http_url=None, github_repo_owner=..., github_repo_name=..., github_repo_branch=...) -> Optional[str] | Read the cached OWL buffer for a source, or return None. |
save_cache | FOLIO.save_cache(buffer, cache_path=DEFAULT_CACHE_DIR, source_type="github", ...) -> None | Write an OWL buffer to the local cache. |
load_owl_github | FOLIO.load_owl_github(repo_owner=..., repo_name=..., repo_branch=...) -> str | Fetch FOLIO.owl from raw.githubusercontent.com. |
load_owl_http | FOLIO.load_owl_http(http_url=None) -> str | Fetch the OWL file from an arbitrary HTTP URL (follows redirects). |
load_owl | FOLIO.load_owl(source_type="github", http_url=None, github_repo_owner=..., github_repo_name=..., github_repo_branch=..., use_cache=True) -> str | Orchestrates load_cache → load_owl_github/load_owl_http → save_cache. This is what the constructor calls internally. |
refresh | f.refresh() -> None | Force-reload the ontology bypassing the cache, then reparse. Useful for picking up upstream changes without restarting. |
parse_owl | f.parse_owl(buffer: str) -> None | Parse a raw OWL/XML string into classes, object_properties, triples, and all indices. Called once by __init__. |
parse_owl_class | f.parse_owl_class(node: lxml.etree._Element) -> None | Parse a single owl:Class element and append it to classes. |
parse_owl_object_property | f.parse_owl_object_property(node) -> None | Parse a single owl:ObjectProperty element and append it to object_properties. |
parse_owl_ontology | f.parse_owl_ontology(node) -> None | Extract dc:title and dc:description from the owl:Ontology header. |
parse_node | f.parse_node(node) -> None | Dispatch-by-tag helper: routes to one of the parse_owl_* methods based on the element’s type. |
Class access (dunder + helper)
IRI lookups accept any of the supported formats: short ID (R8BD30978Ccbc4C2f0f8459f), prefixed (folio:R8BD…), full URI (https://folio.openlegalstandard.org/R8BD…), or legacy soli: / http://lmss.sali.org/ forms. All are normalized via normalize_iri.
| Method | Returns | Description |
|---|---|---|
f[item] | Optional[OWLClass] | f[int] returns by position, f[str] returns by IRI (any supported form). Returns None if not found. |
iri in f | bool | True if the normalized IRI is in iri_to_index. |
len(f) | int | Number of parsed classes. |
str(f) | str | Repr like FOLIO <github/alea-institute/FOLIO/2.0.0>. |
f.get_property(item) | Optional[OWLObjectProperty] | Look up an object property by index or IRI. |
f.get_by_label(label, include_alt_labels=False) | List[OWLClass] | Exact-match lookup against primary labels. Optionally fall back to alt labels. |
f.get_by_alt_label(alt_label, include_hidden_labels=True) | List[OWLClass] | Exact-match lookup against alternative labels. |
f.get_properties_by_label(label) | List[OWLObjectProperty] | Exact-match lookup against property labels. |
Search
Lexical and semantic search. All methods return OWLClass instances (or tuples of class + score). search_by_prefix is synchronous; search_by_llm and parallel_search_by_llm are async and must be awaited.
| Method | Signature | Description |
|---|---|---|
search_by_prefix | f.search_by_prefix(prefix: str, case_sensitive: bool = False) -> List[OWLClass] | Trie-backed prefix search over labels and alt labels. Case-insensitive by default since 0.3.5; pass case_sensitive=True for the pre-0.3.5 behavior. Sorted with primary-label matches first, then by ascending label length. |
search_by_label | f.search_by_label(label: str, include_alt_labels: bool = True, limit: int = 10) -> List[Tuple[OWLClass, int | float]] | Fuzzy label search via rapidfuzz.fuzz.WRatio. |
search_by_definition | f.search_by_definition(definition: str, limit: int = 10) -> List[Tuple[OWLClass, int | float]] | Fuzzy search against skos:definition via rapidfuzz.fuzz.partial_token_set_ratio. |
search_by_llm | async f.search_by_llm(query: str, search_set: List[OWLClass], limit: int = 10, scale: int = 10, include_reason: bool = False) -> List[Tuple[OWLClass, int | float]] | LLM-ranked semantic search over a user-supplied candidate set. search_set is a required positional argument — there is no whole-ontology default. Raises RuntimeError if self.llm is None (no LLM credentials configured at construction time — see LLM Integration). |
parallel_search_by_llm | async f.parallel_search_by_llm(query: str, search_sets: Optional[List[List[OWLClass]]] = None, limit: int = 10, scale: int = 10, include_reason: bool = False, max_depth: int = DEFAULT_SEARCH_MAX_DEPTH) -> List[Tuple[OWLClass, int | float]] | Dispatches search_by_llm across multiple candidate sets concurrently via asyncio.gather. When search_sets is None, uses every FOLIO branch truncated to max_depth (default 2). |
format_classes_for_llm | f.format_classes_for_llm(owl_classes: List[OWLClass]) -> str | Serialize a list of classes into the JSONL block consumed by search_by_llm. Useful for building your own LLM prompts. |
Structured queries
Composable text and structural filters. Both query and query_properties share a match_mode control that accepts "substring" (default), "exact", "regex", or "fuzzy" — the "fuzzy" mode requires the [search] extra and uses partial_ratio >= 70 as the cutoff.
f.query(
label: Optional[str] = None,
definition: Optional[str] = None,
alt_label: Optional[str] = None,
example: Optional[str] = None,
any_text: Optional[str] = None,
branch: Optional[str] = None,
parent_iri: Optional[str] = None,
has_children: Optional[bool] = None,
deprecated: bool = False,
country: Optional[str] = None,
match_mode: str = "substring",
limit: int = 20,
) -> List[OWLClass]| Parameter | Type | Description |
|---|---|---|
label | Optional[str] | Match against rdfs:label. |
definition | Optional[str] | Match against skos:definition. |
alt_label | Optional[str] | Match against any entry in alternative_labels. |
example | Optional[str] | Match against any entry in examples. |
any_text | Optional[str] | OR across label, definition, alt labels, examples, notes, comment, description. |
branch | Optional[str] | FOLIOTypes enum name or value (e.g. "AREA_OF_LAW" or "Area of Law"). Returns [] for unknown branches. |
parent_iri | Optional[str] | Restrict to descendants of this IRI via transitive subClassOf. Normalized before use. |
has_children | Optional[bool] | True for non-leaf only, False for leaf only, None for both. |
deprecated | bool | Default False excludes deprecated classes. Set True to include them. |
country | Optional[str] | Match against the mads:country field. |
match_mode | str | "substring" / "exact" / "regex" / "fuzzy". |
limit | int | Maximum classes to return (default 20). |
f.query_properties(
label: Optional[str] = None,
definition: Optional[str] = None,
domain_iri: Optional[str] = None,
range_iri: Optional[str] = None,
has_inverse: Optional[bool] = None,
match_mode: str = "substring",
limit: int = 20,
) -> List[OWLObjectProperty]domain_iri and range_iri are normalized via normalize_iri and matched against the property’s domain / range lists (set membership). has_inverse filters on the presence of inverse_of.
Taxonomy helpers
Twenty-four branch helpers, one per member of FOLIOTypes. Every helper shares the signature (max_depth: int = DEFAULT_MAX_DEPTH) -> List[OWLClass] (where DEFAULT_MAX_DEPTH = 16) and delegates to get_children(FOLIO_TYPE_IRIS[branch], max_depth=max_depth). The default-depth class counts are against the FOLIO 2.0.0 ontology on the 2.0.0 branch.
| Method | FOLIOTypes branch | Class count (default depth) |
|---|---|---|
get_player_actors | ACTOR_PLAYER | 563 |
get_areas_of_law | AREA_OF_LAW | 174 |
get_asset_types | ASSET_TYPE | 345 |
get_communication_modalities | COMMUNICATION_MODALITY | 11 |
get_currencies | CURRENCY | 178 |
get_data_formats | DATA_FORMAT | 17 |
get_document_artifacts | DOCUMENT_ARTIFACT | 2,796 |
get_engagement_terms | ENGAGEMENT_TERMS | 343 |
get_events | EVENT | 401 |
get_forum_venues | FORUMS_VENUES | 2,180 |
get_governmental_bodies | GOVERNMENTAL_BODY | 1,585 |
get_industries | INDUSTRY | 2,137 |
get_languages | LANGUAGE | 489 |
get_folio_types | FOLIO_TYPE | 3 |
get_legal_authorities | LEGAL_AUTHORITIES | 82 |
get_legal_entities | LEGAL_ENTITY | 517 |
get_locations | LOCATION | 3,782 |
get_matter_narratives | MATTER_NARRATIVE | 13 |
get_matter_narrative_formats | MATTER_NARRATIVE_FORMAT | 2 |
get_objectives | OBJECTIVES | 5,409 |
get_services | SERVICE | 434 |
get_standards_compatibilities | STANDARDS_COMPATIBILITY | 868 |
get_statuses | STATUS | 23 |
get_system_identifiers | SYSTEM_IDENTIFIERS | 13 |
Plus the meta helper:
f.get_folio_branches(max_depth: int = DEFAULT_MAX_DEPTH) -> Dict[FOLIOTypes, List[OWLClass]]get_folio_branches returns a dict keyed by FOLIOTypes with every branch expanded in parallel, not a flat list. The docstring on the method itself says “list” — the return type is actually Dict[FOLIOTypes, List[OWLClass]] with 24 keys.
Traversal
Three primitives for walking the class hierarchy by IRI. All three accept a max_depth second argument (default 16) and accept any IRI form (normalized internally).
| Method | Signature | Description |
|---|---|---|
get_subgraph | f.get_subgraph(iri: str, max_depth: int = DEFAULT_MAX_DEPTH) -> List[OWLClass] | Returns the starting class plus every descendant reachable within max_depth hops. |
get_children | f.get_children(iri: str, max_depth: int = DEFAULT_MAX_DEPTH) -> List[OWLClass] | Like get_subgraph but excludes the starting class. May contain duplicates when a class is reachable via multiple inheritance paths — dedupe by iri if you need a unique set. |
get_parents | f.get_parents(iri: str, max_depth: int = DEFAULT_MAX_DEPTH) -> List[OWLClass] | Returns the starting class plus every ancestor along subClassOf up to max_depth. Includes a synthetic OWLClass(label=None, iri="http://www.w3.org/2002/07/owl#Thing") sentinel at the root — renderers must guard against label is None. |
Object properties
Methods for working with owl:ObjectProperty instances — the predicates that connect classes in the ontology graph.
| Method | Signature | Description |
|---|---|---|
get_all_properties | f.get_all_properties() -> List[OWLObjectProperty] | A copy of every parsed object property (175 in 2.0.0). |
get_property | f.get_property(item: str | int) -> Optional[OWLObjectProperty] | Look up a property by index or IRI. |
get_properties_by_label | f.get_properties_by_label(label: str) -> List[OWLObjectProperty] | Exact-match lookup by rdfs:label. |
find_connections | f.find_connections(subject_class, property_name=None, object_class=None) -> List[Tuple[OWLClass, OWLObjectProperty, OWLClass]] | Find (subject, property, object) triples. Accepts strings, IRIs, or instance arguments. Only returns results for root-type classes (Actor/Player, Document/Artifact, etc.) — object-property triples are declared at the type-root level, so a leaf class like Michigan returns []. |
Triples
The parsed triple store exposes the full RDF content of the ontology. The triples attribute holds all of them; the three get_triples_by_* methods filter by subject, predicate, or object.
| Method | Signature | Description |
|---|---|---|
get_triples_by_subject | f.get_triples_by_subject(subject: str) -> List[Tuple[str, str, str]] | Every triple with the given subject IRI. |
get_triples_by_predicate | f.get_triples_by_predicate(predicate: str) -> List[Tuple[str, str, str]] | Every triple with the given predicate. Predicates use prefixed-name form (rdfs:label, skos:prefLabel, dc:identifier), not full URIs. Passing a full URI returns []. |
get_triples_by_object | f.get_triples_by_object(obj: str) -> List[Tuple[str, str, str]] | Every triple with the given object (IRI or literal). |
There are 35 unique predicates in the 2.0.0 ontology — see the Properties sub-page for the full list.
Utilities
Mostly internal, but useful for advanced users building their own IRI handling or namespace logic.
| Method | Signature | Description |
|---|---|---|
get_ns_tag | FOLIO.get_ns_tag(ns: str, tag: str) -> str | Build a Clark-notation tag (e.g. {http://www.w3.org/2000/01/rdf-schema#}label) from a prefix in NSMAP and a local name. Staticmethod. |
normalize_iri | FOLIO.normalize_iri(iri: str) -> str | Normalize short IDs, folio:/soli:/lmss: prefixes, and legacy http://lmss.sali.org/ URLs to canonical https://folio.openlegalstandard.org/… form. Staticmethod, @cache-decorated. |
generate_iri | f.generate_iri() -> str | Mint a new IRI using a WebProtégé-style base64-encoded UUID4. Retries up to MAX_IRI_ATTEMPTS times if the generated IRI collides with an existing class. |
class OWLClass
from folio import OWLClass. A Pydantic v2 BaseModel representing an OWL class with every field the FOLIO ontology populates. Each field maps one-to-one onto a specific OWL, RDFS, SKOS, Dublin Core, or MADS property.
Fields
| Field | Type | Default | OWL/RDF source |
|---|---|---|---|
iri | str | required | owl:Class (the rdf:about URI) |
label | Optional[str] | None | rdfs:label |
sub_class_of | List[str] | [] | rdfs:subClassOf — parent IRIs |
parent_class_of | List[str] | [] | Reverse of rdfs:subClassOf — see note below |
is_defined_by | Optional[str] | None | rdfs:isDefinedBy |
see_also | List[str] | [] | rdfs:seeAlso |
comment | Optional[str] | None | rdfs:comment |
deprecated | bool | False | owl:deprecated |
preferred_label | Optional[str] | None | skos:prefLabel |
alternative_labels | List[str] | [] | skos:altLabel |
translations | Dict[str, str] | {} | skos:altLabel with xml:lang attribute |
hidden_label | Optional[str] | None | skos:hiddenLabel |
definition | Optional[str] | None | skos:definition |
examples | List[str] | [] | skos:example |
notes | List[str] | [] | skos:note |
history_note | Optional[str] | None | skos:historyNote |
editorial_note | Optional[str] | None | skos:editorialNote |
in_scheme | Optional[str] | None | skos:inScheme |
identifier | Optional[str] | None | dc:identifier |
description | Optional[str] | None | dc:description |
source | Optional[str] | None | dc:source |
country | Optional[str] | None | mads:country (v1 prefix in NSMAP) |
parent_class_of is misnamed. Despite the sub_class_of echo in its docstring, it actually holds children IRIs — the classes for which this class is the parent. FOLIO populates it in the reverse-edge pass of parse_owl. sub_class_of is the direction that matches OWL semantics (your own parents); parent_class_of is the reverse adjacency (your own children).
Methods
| Method | Returns | Description |
|---|---|---|
is_valid() | bool | True iff label is not None. Used to filter out unparseable classes during ingest. |
__str__() | str | "OWLClass(label=..., iri=...)". |
to_owl_element() | lxml.etree.Element | Build an owl:Class XML element with every populated field as a child element. |
to_owl_xml() | str | Pretty-printed OWL/XML string (wraps to_owl_element). |
to_markdown() | str | Human-readable Markdown document with sections for labels, definition, examples, parents, children, notes, and Dublin Core metadata. |
to_jsonld() | dict | JSON-LD dictionary with a full @context and every populated field. Returns a dict despite the docstring saying “string” — json.dumps(cls.to_jsonld()) to serialize. Note the @context includes a None key (default namespace) because it mirrors NSMAP directly. |
to_json() | str | Thin wrapper around Pydantic’s model_dump_json(). |
from_json(json_string) | OWLClass | Classmethod. Thin wrapper around model_validate_json. |
There is no to_owl_ttl method. The available serializers are OWL/XML, JSON-LD (as a dict), Markdown, and Pydantic JSON. There is no Turtle, N-Triples, or N-Quads output. If you need Turtle, serialize via to_owl_xml() and convert with a library like rdflib.
class OWLObjectProperty
from folio import OWLObjectProperty. A Pydantic v2 BaseModel representing an owl:ObjectProperty — the predicates that connect FOLIO classes (e.g. folio:observed, folio:hasFigure).
Fields
| Field | Type | Default | OWL/RDF source |
|---|---|---|---|
iri | str | required | owl:ObjectProperty (the rdf:about URI) |
label | Optional[str] | None | rdfs:label |
sub_property_of | List[str] | [] | rdfs:subPropertyOf |
domain | List[str] | [] | rdfs:domain |
range | List[str] | [] | rdfs:range |
inverse_of | Optional[str] | None | owl:inverseOf |
preferred_label | Optional[str] | None | skos:prefLabel |
alternative_labels | List[str] | [] | skos:altLabel |
definition | Optional[str] | None | skos:definition |
examples | List[str] | [] | skos:example |
Methods
Only two: is_valid() -> bool (true when label is set) and __str__() -> str. There are no to_owl_element, to_owl_xml, to_markdown, to_json, or to_jsonld methods on OWLObjectProperty — those exist on OWLClass only. To serialize an object property, call Pydantic’s prop.model_dump_json() or prop.model_dump() directly.
class FOLIOConfiguration
from folio.config import FOLIOConfiguration. A Pydantic v2 model for describing a FOLIO source in a JSON config file. Used by FOLIOConfiguration.load_config() to hydrate settings from ~/.folio/config.json.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
source | Literal["github", "http"] | required | Where the ontology lives. No default — omitting it raises pydantic.ValidationError. |
url | Optional[str] | None | HTTP URL when source="http". |
repo_owner | Optional[str] | None | GitHub owner when source="github". |
repo_name | Optional[str] | None | GitHub repo name. |
branch | Optional[str] | None | GitHub branch, tag, or ref. |
path | Optional[str] | None | Path to the OWL file within the repo or base URL. |
use_cache | bool | True | Whether local caching is enabled. |
FOLIOConfiguration() with no arguments raises pydantic.ValidationError because source is required. Only use_cache=True has a populated default. The DEFAULT_GITHUB_REPO_OWNER, DEFAULT_GITHUB_REPO_NAME, and DEFAULT_GITHUB_REPO_BRANCH values in folio.config are module-level constants, not field defaults — FOLIOConfiguration.load_config() pulls them in as fallbacks when reading ~/.folio/config.json, but the model itself has no such defaults.
The field name is source, not source_type. The FOLIO() constructor uses source_type as its parameter name for historical reasons. This asymmetry is real, and you’ll see it if you try to pass a hydrated FOLIOConfiguration straight into FOLIO() — you’ll need to rename fields.
Methods
| Method | Signature | Description |
|---|---|---|
load_config | FOLIOConfiguration.load_config(config_path: str | Path = DEFAULT_CONFIG_PATH) -> FOLIOConfiguration | Staticmethod. Loads a JSON config from ~/.folio/config.json (default) or any path you pass. Reads the top-level "folio" key, applies the module-level DEFAULT_GITHUB_* constants as fallbacks, and returns a validated FOLIOConfiguration. Raises FileNotFoundError if the file is missing. |
There is no save_config, to_json, or from_json on FOLIOConfiguration. To write a config file, call config.model_dump_json(indent=2) yourself and write the result to disk — Pydantic gives you everything you need.
Constants
FOLIOTypes
from folio import FOLIOTypes. An enum.Enum with 24 members. Each member’s .value is the human-readable branch name exactly as it appears in rdfs:label on the branch root class.
| Member | Value |
|---|---|
ACTOR_PLAYER | "Actor / Player" |
AREA_OF_LAW | "Area of Law" |
ASSET_TYPE | "Asset Type" |
COMMUNICATION_MODALITY | "Communication Modality" |
CURRENCY | "Currency" |
DATA_FORMAT | "Data Format" |
DOCUMENT_ARTIFACT | "Document / Artifact" |
ENGAGEMENT_TERMS | "Engagement Terms" |
EVENT | "Event" |
FORUMS_VENUES | "Forums and Venues" |
GOVERNMENTAL_BODY | "Governmental Body" |
INDUSTRY | "Industry" |
LANGUAGE | "Language" |
FOLIO_TYPE | "FOLIO Type" |
LEGAL_AUTHORITIES | "Legal Authorities" |
LEGAL_ENTITY | "Legal Entity" |
LOCATION | "Location" |
MATTER_NARRATIVE | "Matter Narrative" |
MATTER_NARRATIVE_FORMAT | "Matter Narrative Format" |
OBJECTIVES | "Objectives" |
SERVICE | "Service" |
STANDARDS_COMPATIBILITY | "Standards Compatibility" |
STATUS | "Status" |
SYSTEM_IDENTIFIERS | "System Identifiers" |
FOLIO_TYPE_IRIS
from folio import FOLIO_TYPE_IRIS. A Dict[FOLIOTypes, str] mapping every branch to its short IRI (the trailing segment after https://folio.openlegalstandard.org/).
| Member | Short IRI |
|---|---|
ACTOR_PLAYER | R8CdMpOM0RmyrgCCvbpiLS0 |
AREA_OF_LAW | RSYBzf149Mi5KE0YtmpUmr |
ASSET_TYPE | RCIwc6WJi6IT7xePURxsi4T |
COMMUNICATION_MODALITY | R8qItBwG2pRMFhUq1HQEMnb |
CURRENCY | R767niCLQVC5zIcO5WDQMSl |
DATA_FORMAT | R79aItNTJQwHgR002wuX3iC |
DOCUMENT_ARTIFACT | RDt4vQCYDfY0R9fZ5FNnTbj |
ENGAGEMENT_TERMS | R9kmGZf5FSmFdouXWQ1Nndm |
EVENT | R73hoH1RXYjBTYiGfolpsAF |
FORUMS_VENUES | RBjHwNNG2ASVmasLFU42otk |
GOVERNMENTAL_BODY | RBQGborh1CfXanGZipDL0Qo |
INDUSTRY | RDIwFaFcH4KY0gwEY0QlMTp |
LANGUAGE | RDOvAHsvY8TKJ1O1orXPM9o |
FOLIO_TYPE | R8uI6AZ9vSgpAdKmfGZKfTZ |
LEGAL_AUTHORITIES | RC1CZydjfH8oiM4W3rCkma3 |
LEGAL_ENTITY | R7L5eLIzH0CpOUE74uJvSjL |
LOCATION | R9aSzp9cEiBCzObnP92jYFX |
MATTER_NARRATIVE | R7ReDY2v13rer1U8AyOj55L |
MATTER_NARRATIVE_FORMAT | R8ONVC8pLVJC5dD4eKqCiZL |
OBJECTIVES | RlNFgB3TQfMzV26V4V7u4E |
SERVICE | RDK1QEdQg1T8B5HQqMK2pZN |
STANDARDS_COMPATIBILITY | RB4cFSLB4xvycDlKv73dOg6 |
STATUS | Rx69EnEj3H3TpcgTfUSoYx |
SYSTEM_IDENTIFIERS | R8EoZh39tWmXCkmP2Xzjl6E |
Values are short IDs. Prefix https://folio.openlegalstandard.org/ to get the full IRI — or just pass the short form directly to f[iri], which normalizes both forms.
NSMAP
from folio import NSMAP. The lxml namespace map used by to_owl_element, to_jsonld, and all of the get_ns_tag calls during parsing. Ten entries, including a None key for the default namespace.
NSMAP = {
None: "https://folio.openlegalstandard.org/",
"dc": "http://purl.org/dc/elements/1.1/",
"v1": "http://www.loc.gov/mads/rdf/v1#",
"owl": "http://www.w3.org/2002/07/owl#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"folio": "https://folio.openlegalstandard.org/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"xml": "http://www.w3.org/XML/1998/namespace",
}The None key is the lxml convention for the default namespace in element construction. It also appears in OWLClass.to_jsonld() output’s @context — downstream JSON-LD consumers that can’t handle a null key must strip it before parsing.
Module-level constants
From folio.graph:
| Constant | Value | Description |
|---|---|---|
OWL_THING | "http://www.w3.org/2002/07/owl#Thing" | The root sentinel used by get_parents. |
DEFAULT_CACHE_DIR | Path.home() / ".folio" / "cache" | Default on-disk cache directory. |
DEFAULT_MAX_DEPTH | 16 | Default recursion bound for get_subgraph, get_children, get_parents, and every get_<branch> helper. |
MAX_IRI_ATTEMPTS | 16 | Retry budget for generate_iri when a minted IRI collides. |
DEFAULT_MAX_TOKENS | 1024 | Default max_tokens hint for LLM calls. |
DEFAULT_SEARCH_MAX_DEPTH | 2 | Default branch traversal depth in parallel_search_by_llm when no search_sets are supplied. |
MIN_PREFIX_LENGTH | 3 | Advisory minimum prefix length. Not enforced by search_by_prefix; shorter prefixes still work but will return thousands of results. |
From folio.config:
| Constant | Value |
|---|---|
DEFAULT_CONFIG_PATH | Path.home() / ".folio" / "config.json" |
DEFAULT_GITHUB_API_URL | "https://api.github.com" |
DEFAULT_GITHUB_OBJECT_URL | "https://raw.githubusercontent.com" |
DEFAULT_SOURCE_TYPE | "github" |
DEFAULT_HTTP_URL | None |
DEFAULT_GITHUB_REPO_OWNER | "alea-institute" |
DEFAULT_GITHUB_REPO_NAME | "FOLIO" |
DEFAULT_GITHUB_REPO_BRANCH | "2.0.0" |
These are plain module-level names, not FOLIOConfiguration field defaults. Import them directly: from folio.config import DEFAULT_GITHUB_REPO_BRANCH.
Logger
from folio.logger import get_logger. Returns a standard logging.Logger configured at WARNING level by default. The library uses it internally for load/parse timing messages, cache hits, and LLM failures. To surface those messages in your own app, attach a handler or set the level:
import logging
from folio.logger import get_logger
logger = get_logger("folio")
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())Every submodule (folio.graph, folio.config, folio.models) calls get_logger(__name__), so setting the level on the parent "folio" logger will cascade to all of them.
See also
Every section above has a narrative sub-page with worked examples. Start with Getting Started to install and load the ontology, then follow Searching and Querying for lookup patterns, Taxonomy for branch helpers and traversal, Properties & Relationships for object properties and the triples API, Serialization for to_* output formats, and LLM Integration for search_by_llm and parallel_search_by_llm.