Skip to content

Builder pattern

Each facade exposes a fluent builder that composes a request by method chaining, terminated by .execute().

results = (
code.search()
.in_code(NomCode.CC)
.article_number("1382")
.with_formatter()
.execute()
)

Builders return Self to allow chaining; they take the LegifranceClient as the first argument.

BuilderEntry pointTypical methods
CodeSearchBuilderCode.search().in_code(), .text(), .article_number(), .at_date(), .with_formatter(), .paginate(), .execute()
CodeConsultFetcherCode.fetch_code(id).include_abrogated(), .section(), .at(date)
ArticleFetcherCode.fetch_article(id).at(date)
  • Readability: the request reads like a sentence.
  • Progressivity: each step is optional and composable.
  • Typing: each method narrows the permissible parameters (e.g. in_code accepts a NomCode, not a str).
  • Discoverability: autocompletion guides the user towards valid methods.