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__.

NameSourceDescription
FOLIOfolio.graphMain client class for loading and querying the ontology.
FOLIOTypesfolio.graphEnum of the 24 top-level taxonomy branches.
FOLIO_TYPE_IRISfolio.graphDict[FOLIOTypes, str] mapping each branch to its short IRI.
OWLClassfolio.modelsPydantic model representing an OWL class.
OWLObjectPropertyfolio.modelsPydantic model representing an OWL object property.
NSMAPfolio.modelslxml namespace map used by OWL/XML serialization and JSON-LD @context.

The package also exposes standard dunder metadata:

AttributeValue (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
ParameterTypeDefaultDescription
source_typestr"github"Where to fetch the OWL file. Either "github" or "http".
http_urlOptional[str]NoneRequired when source_type="http"; ignored otherwise.
github_repo_ownerstr"alea-institute"GitHub owner of the FOLIO repo.
github_repo_namestr"FOLIO"GitHub repo name.
github_repo_branchstr"2.0.0"Branch, tag, or ref to load. This is the correct parameter name — not branch.
use_cacheboolTrueIf True, load from ~/.folio/cache/ when available and write back after fetching.
llmOptional[BaseAIModel]NoneAn 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_kwargsOptional[dict]NoneExtra kwargs forwarded to LLM calls (e.g. reasoning_effort, service_tier). Merged with values derived from effort and tier.
effortOptional[str]NoneUniversal effort level: "low", "medium", or "high". Translated per-provider via alea_llm_client.get_llm_kwargs.
tierOptional[str]NoneUniversal 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.

AttributeTypeDescription
classesList[OWLClass]Every parsed class, in insertion order. len(f) == len(f.classes).
object_propertiesList[OWLObjectProperty]Every parsed owl:ObjectProperty.
iri_to_indexDict[str, int]IRI → position in classes. Public IRI lookup.
iri_to_property_indexDict[str, int]IRI → position in object_properties.
label_to_indexDict[str, List[int]]Primary rdfs:label → list of class indices.
alt_label_to_indexDict[str, List[int]]skos:altLabel, skos:prefLabel, and skos:hiddenLabel → class indices.
property_label_to_indexDict[str, List[int]]Property label → list of property indices.
class_edgesDict[str, List[str]]Parent IRI → list of child IRIs (forward adjacency).
triplesList[Tuple[str, str, str]]Every parsed triple as (subject_iri, prefixed_predicate, object). ~130k for 2.0.0.
titleOptional[str]dc:title from the ontology header.
descriptionOptional[str]dc:description from the ontology header.
llmOptional[BaseAIModel]LLM client used by search_by_llm. Auto-initialized to OpenAIModel("gpt-5.4") when the [search] extra is installed.
llm_kwargsdictExtra kwargs merged into every LLM call. Populated from llm_kwargs, effort, tier.
source_typestr"github" or "http".
http_urlOptional[str]HTTP URL when source_type="http".
github_repo_ownerstrOwner, e.g. "alea-institute".
github_repo_namestrRepo, e.g. "FOLIO".
github_repo_branchstrBranch/tag/ref.
use_cacheboolWhether local caching is enabled.
treeOptional[lxml.etree._Element]Root element of the parsed OWL XML tree.
parserOptional[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.

MethodSignatureDescription
list_branchesFOLIO.list_branches(repo_owner="alea-institute", repo_name="FOLIO") -> List[str]Query the GitHub API for available branches on the FOLIO repo.
load_cacheFOLIO.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_cacheFOLIO.save_cache(buffer, cache_path=DEFAULT_CACHE_DIR, source_type="github", ...) -> NoneWrite an OWL buffer to the local cache.
load_owl_githubFOLIO.load_owl_github(repo_owner=..., repo_name=..., repo_branch=...) -> strFetch FOLIO.owl from raw.githubusercontent.com.
load_owl_httpFOLIO.load_owl_http(http_url=None) -> strFetch the OWL file from an arbitrary HTTP URL (follows redirects).
load_owlFOLIO.load_owl(source_type="github", http_url=None, github_repo_owner=..., github_repo_name=..., github_repo_branch=..., use_cache=True) -> strOrchestrates load_cacheload_owl_github/load_owl_httpsave_cache. This is what the constructor calls internally.
refreshf.refresh() -> NoneForce-reload the ontology bypassing the cache, then reparse. Useful for picking up upstream changes without restarting.
parse_owlf.parse_owl(buffer: str) -> NoneParse a raw OWL/XML string into classes, object_properties, triples, and all indices. Called once by __init__.
parse_owl_classf.parse_owl_class(node: lxml.etree._Element) -> NoneParse a single owl:Class element and append it to classes.
parse_owl_object_propertyf.parse_owl_object_property(node) -> NoneParse a single owl:ObjectProperty element and append it to object_properties.
parse_owl_ontologyf.parse_owl_ontology(node) -> NoneExtract dc:title and dc:description from the owl:Ontology header.
parse_nodef.parse_node(node) -> NoneDispatch-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.

MethodReturnsDescription
f[item]Optional[OWLClass]f[int] returns by position, f[str] returns by IRI (any supported form). Returns None if not found.
iri in fboolTrue if the normalized IRI is in iri_to_index.
len(f)intNumber of parsed classes.
str(f)strRepr 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.

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.

MethodSignatureDescription
search_by_prefixf.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_labelf.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_definitionf.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_llmasync 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_llmasync 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_llmf.format_classes_for_llm(owl_classes: List[OWLClass]) -> strSerialize 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]
ParameterTypeDescription
labelOptional[str]Match against rdfs:label.
definitionOptional[str]Match against skos:definition.
alt_labelOptional[str]Match against any entry in alternative_labels.
exampleOptional[str]Match against any entry in examples.
any_textOptional[str]OR across label, definition, alt labels, examples, notes, comment, description.
branchOptional[str]FOLIOTypes enum name or value (e.g. "AREA_OF_LAW" or "Area of Law"). Returns [] for unknown branches.
parent_iriOptional[str]Restrict to descendants of this IRI via transitive subClassOf. Normalized before use.
has_childrenOptional[bool]True for non-leaf only, False for leaf only, None for both.
deprecatedboolDefault False excludes deprecated classes. Set True to include them.
countryOptional[str]Match against the mads:country field.
match_modestr"substring" / "exact" / "regex" / "fuzzy".
limitintMaximum 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.

MethodFOLIOTypes branchClass count (default depth)
get_player_actorsACTOR_PLAYER563
get_areas_of_lawAREA_OF_LAW174
get_asset_typesASSET_TYPE345
get_communication_modalitiesCOMMUNICATION_MODALITY11
get_currenciesCURRENCY178
get_data_formatsDATA_FORMAT17
get_document_artifactsDOCUMENT_ARTIFACT2,796
get_engagement_termsENGAGEMENT_TERMS343
get_eventsEVENT401
get_forum_venuesFORUMS_VENUES2,180
get_governmental_bodiesGOVERNMENTAL_BODY1,585
get_industriesINDUSTRY2,137
get_languagesLANGUAGE489
get_folio_typesFOLIO_TYPE3
get_legal_authoritiesLEGAL_AUTHORITIES82
get_legal_entitiesLEGAL_ENTITY517
get_locationsLOCATION3,782
get_matter_narrativesMATTER_NARRATIVE13
get_matter_narrative_formatsMATTER_NARRATIVE_FORMAT2
get_objectivesOBJECTIVES5,409
get_servicesSERVICE434
get_standards_compatibilitiesSTANDARDS_COMPATIBILITY868
get_statusesSTATUS23
get_system_identifiersSYSTEM_IDENTIFIERS13

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).

MethodSignatureDescription
get_subgraphf.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_childrenf.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_parentsf.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.

MethodSignatureDescription
get_all_propertiesf.get_all_properties() -> List[OWLObjectProperty]A copy of every parsed object property (175 in 2.0.0).
get_propertyf.get_property(item: str | int) -> Optional[OWLObjectProperty]Look up a property by index or IRI.
get_properties_by_labelf.get_properties_by_label(label: str) -> List[OWLObjectProperty]Exact-match lookup by rdfs:label.
find_connectionsf.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.

MethodSignatureDescription
get_triples_by_subjectf.get_triples_by_subject(subject: str) -> List[Tuple[str, str, str]]Every triple with the given subject IRI.
get_triples_by_predicatef.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_objectf.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.

MethodSignatureDescription
get_ns_tagFOLIO.get_ns_tag(ns: str, tag: str) -> strBuild 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_iriFOLIO.normalize_iri(iri: str) -> strNormalize short IDs, folio:/soli:/lmss: prefixes, and legacy http://lmss.sali.org/ URLs to canonical https://folio.openlegalstandard.org/… form. Staticmethod, @cache-decorated.
generate_irif.generate_iri() -> strMint 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

FieldTypeDefaultOWL/RDF source
iristrrequiredowl:Class (the rdf:about URI)
labelOptional[str]Nonerdfs:label
sub_class_ofList[str][]rdfs:subClassOfparent IRIs
parent_class_ofList[str][]Reverse of rdfs:subClassOf — see note below
is_defined_byOptional[str]Nonerdfs:isDefinedBy
see_alsoList[str][]rdfs:seeAlso
commentOptional[str]Nonerdfs:comment
deprecatedboolFalseowl:deprecated
preferred_labelOptional[str]Noneskos:prefLabel
alternative_labelsList[str][]skos:altLabel
translationsDict[str, str]{}skos:altLabel with xml:lang attribute
hidden_labelOptional[str]Noneskos:hiddenLabel
definitionOptional[str]Noneskos:definition
examplesList[str][]skos:example
notesList[str][]skos:note
history_noteOptional[str]Noneskos:historyNote
editorial_noteOptional[str]Noneskos:editorialNote
in_schemeOptional[str]Noneskos:inScheme
identifierOptional[str]Nonedc:identifier
descriptionOptional[str]Nonedc:description
sourceOptional[str]Nonedc:source
countryOptional[str]Nonemads: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

MethodReturnsDescription
is_valid()boolTrue iff label is not None. Used to filter out unparseable classes during ingest.
__str__()str"OWLClass(label=..., iri=...)".
to_owl_element()lxml.etree.ElementBuild an owl:Class XML element with every populated field as a child element.
to_owl_xml()strPretty-printed OWL/XML string (wraps to_owl_element).
to_markdown()strHuman-readable Markdown document with sections for labels, definition, examples, parents, children, notes, and Dublin Core metadata.
to_jsonld()dictJSON-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()strThin wrapper around Pydantic’s model_dump_json().
from_json(json_string)OWLClassClassmethod. 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

FieldTypeDefaultOWL/RDF source
iristrrequiredowl:ObjectProperty (the rdf:about URI)
labelOptional[str]Nonerdfs:label
sub_property_ofList[str][]rdfs:subPropertyOf
domainList[str][]rdfs:domain
rangeList[str][]rdfs:range
inverse_ofOptional[str]Noneowl:inverseOf
preferred_labelOptional[str]Noneskos:prefLabel
alternative_labelsList[str][]skos:altLabel
definitionOptional[str]Noneskos:definition
examplesList[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

FieldTypeDefaultDescription
sourceLiteral["github", "http"]requiredWhere the ontology lives. No default — omitting it raises pydantic.ValidationError.
urlOptional[str]NoneHTTP URL when source="http".
repo_ownerOptional[str]NoneGitHub owner when source="github".
repo_nameOptional[str]NoneGitHub repo name.
branchOptional[str]NoneGitHub branch, tag, or ref.
pathOptional[str]NonePath to the OWL file within the repo or base URL.
use_cacheboolTrueWhether 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

MethodSignatureDescription
load_configFOLIOConfiguration.load_config(config_path: str | Path = DEFAULT_CONFIG_PATH) -> FOLIOConfigurationStaticmethod. 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.

MemberValue
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/).

MemberShort IRI
ACTOR_PLAYERR8CdMpOM0RmyrgCCvbpiLS0
AREA_OF_LAWRSYBzf149Mi5KE0YtmpUmr
ASSET_TYPERCIwc6WJi6IT7xePURxsi4T
COMMUNICATION_MODALITYR8qItBwG2pRMFhUq1HQEMnb
CURRENCYR767niCLQVC5zIcO5WDQMSl
DATA_FORMATR79aItNTJQwHgR002wuX3iC
DOCUMENT_ARTIFACTRDt4vQCYDfY0R9fZ5FNnTbj
ENGAGEMENT_TERMSR9kmGZf5FSmFdouXWQ1Nndm
EVENTR73hoH1RXYjBTYiGfolpsAF
FORUMS_VENUESRBjHwNNG2ASVmasLFU42otk
GOVERNMENTAL_BODYRBQGborh1CfXanGZipDL0Qo
INDUSTRYRDIwFaFcH4KY0gwEY0QlMTp
LANGUAGERDOvAHsvY8TKJ1O1orXPM9o
FOLIO_TYPER8uI6AZ9vSgpAdKmfGZKfTZ
LEGAL_AUTHORITIESRC1CZydjfH8oiM4W3rCkma3
LEGAL_ENTITYR7L5eLIzH0CpOUE74uJvSjL
LOCATIONR9aSzp9cEiBCzObnP92jYFX
MATTER_NARRATIVER7ReDY2v13rer1U8AyOj55L
MATTER_NARRATIVE_FORMATR8ONVC8pLVJC5dD4eKqCiZL
OBJECTIVESRlNFgB3TQfMzV26V4V7u4E
SERVICERDK1QEdQg1T8B5HQqMK2pZN
STANDARDS_COMPATIBILITYRB4cFSLB4xvycDlKv73dOg6
STATUSRx69EnEj3H3TpcgTfUSoYx
SYSTEM_IDENTIFIERSR8EoZh39tWmXCkmP2Xzjl6E

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:

ConstantValueDescription
OWL_THING"http://www.w3.org/2002/07/owl#Thing"The root sentinel used by get_parents.
DEFAULT_CACHE_DIRPath.home() / ".folio" / "cache"Default on-disk cache directory.
DEFAULT_MAX_DEPTH16Default recursion bound for get_subgraph, get_children, get_parents, and every get_<branch> helper.
MAX_IRI_ATTEMPTS16Retry budget for generate_iri when a minted IRI collides.
DEFAULT_MAX_TOKENS1024Default max_tokens hint for LLM calls.
DEFAULT_SEARCH_MAX_DEPTH2Default branch traversal depth in parallel_search_by_llm when no search_sets are supplied.
MIN_PREFIX_LENGTH3Advisory minimum prefix length. Not enforced by search_by_prefix; shorter prefixes still work but will return thousands of results.

From folio.config:

ConstantValue
DEFAULT_CONFIG_PATHPath.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_URLNone
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.