Liking cljdoc? Tell your friends :D

canlii-api-client.core

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.

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.
raw docstring

browse-casesclj

(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
sourceraw docstring

browse-legislationclj

(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`.
sourceraw docstring

case-metadataclj

(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`.
sourceraw docstring

cited-casesclj

(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".
sourceraw docstring

cited-legislationsclj

(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".
sourceraw docstring

citing-casesclj

(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".
sourceraw docstring

client-from-envclj

(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.
sourceraw docstring

legislation-metadataclj

(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`.
sourceraw docstring

list-case-databasesclj

(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").
sourceraw docstring

list-legislation-databasesclj

(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").
sourceraw docstring

make-clientclj

(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.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close