A client for the CanLII REST API (Canadian court decisions and legislation).
Build a client once with make-client (or client-from-env) and pass it as
the first argument to every endpoint function.
Every endpoint returns a result map rather than throwing:
A successful call is (:success result); an integer :error-code always means
the server responded. Option keys are kebab-case keywords and are translated to
the API's camelCase query parameters automatically.
A client for the CanLII REST API (Canadian court decisions and legislation).
Build a client once with `make-client` (or `client-from-env`) and pass it as
the first argument to every endpoint function.
Every endpoint returns a result map rather than throwing:
- success: {:success true, :data <decoded JSON body>}
- HTTP error: {:success false, :error-code <status int>, :message <str>}
- transport error: {:success false, :error-code :exception,
:error-category :timeout|:connection|:transport,
:message <str>}
A successful call is `(:success result)`; an integer `:error-code` always means
the server responded. Option keys are kebab-case keywords and are translated to
the API's camelCase query parameters automatically.(browse-cases client
{:keys [language database-id offset result-count published-before
published-after modified-before modified-after
changed-before changed-after decision-date-before
decision-date-after]
:or {offset 0 result-count 10}})Browse decisions in a caselaw database.
Options: :language - "en" or "fr" (required) :database-id - database to browse, e.g. "onca" (required) :offset - index of the first result; defaults to 0 :result-count - number of results to return; defaults to 10
Optional inclusive date filters (each "YYYY-MM-DD"): :published-before / :published-after :modified-before / :modified-after :changed-before / :changed-after :decision-date-before / :decision-date-after
Browse decisions in a caselaw database. Options: :language - "en" or "fr" (required) :database-id - database to browse, e.g. "onca" (required) :offset - index of the first result; defaults to 0 :result-count - number of results to return; defaults to 10 Optional inclusive date filters (each "YYYY-MM-DD"): :published-before / :published-after :modified-before / :modified-after :changed-before / :changed-after :decision-date-before / :decision-date-after
(browse-legislation client {:keys [language database-id]})List the legislation in the database identified by :language and
:database-id.
List the legislation in the database identified by `:language` and `:database-id`.
(case-metadata client {:keys [language database-id case-id]})Fetch metadata for a single case identified by :language, :database-id,
and :case-id.
Fetch metadata for a single case identified by `:language`, `:database-id`, and `:case-id`.
(cited-cases client {:keys [database-id case-id]})List the cases cited by the case identified by :database-id and :case-id.
Only English is supported, so the language is always "en".
List the cases cited by the case identified by `:database-id` and `:case-id`. Only English is supported, so the language is always "en".
(cited-legislations client {:keys [database-id case-id]})List the legislation cited by the case identified by :database-id and
:case-id.
Only English is supported, so the language is always "en".
List the legislation cited by the case identified by `:database-id` and `:case-id`. Only English is supported, so the language is always "en".
(citing-cases client {:keys [database-id case-id]})List the cases that cite the case identified by :database-id and :case-id.
Only English is supported, so the language is always "en".
List the cases that cite the case identified by `:database-id` and `:case-id`. Only English is supported, so the language is always "en".
(client-from-env)(client-from-env opts)Build a client using the API key from the CANLII_API_KEY environment variable.
Accepts the same option map as make-client for any non-key overrides.
Build a client using the API key from the CANLII_API_KEY environment variable. Accepts the same option map as `make-client` for any non-key overrides.
(legislation-metadata client {:keys [language database-id legislation-id]})Fetch metadata for a single statute or regulation identified by :language,
:database-id, and :legislation-id.
Fetch metadata for a single statute or regulation identified by `:language`, `:database-id`, and `:legislation-id`.
(list-case-databases client {:keys [language]})List the available court and tribunal databases for :language ("en" or "fr").
List the available court and tribunal databases for `:language` ("en" or "fr").
(list-legislation-databases client {:keys [language]})List the available legislation and regulation databases for :language
("en" or "fr").
List the available legislation and regulation databases for `:language`
("en" or "fr").(make-client {:keys [api-key base-url timeout http-client]
:or {base-url (:base-url defaults) timeout (:timeout defaults)}})Build a CanLII API client to pass as the first argument to every endpoint.
Options: :api-key - CanLII API key (required; blank keys are rejected) :base-url - API base URL; defaults to the public CanLII endpoint :timeout - connect and request timeout in ms; defaults to 5000 :http-client - a pre-built hato client to use instead of building one
Throws ex-info when :api-key is missing or blank.
Build a CanLII API client to pass as the first argument to every endpoint. Options: :api-key - CanLII API key (required; blank keys are rejected) :base-url - API base URL; defaults to the public CanLII endpoint :timeout - connect and request timeout in ms; defaults to 5000 :http-client - a pre-built hato client to use instead of building one Throws `ex-info` when `:api-key` is missing or blank.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |