Transport for the FDIC BankFind Suite API: the settings resolver (per-call opts first, then context variables, then defaults), a typed HttpError, JSON GETs, and query-string building that drops unset values.

opts keyContext variableDefault
api-keyfdic.bankfind.api-keynone: the API needs no key today
base-urlfdic.bankfind.base-urlhttps://api.fdic.gov/banks

The key goes in the URL. FDIC documents only the api_key query parameter, so every HttpError field is redacted (redact-url, redact-value), and api_key is dropped from the parameters a response echoes in meta.parameters.

Per-call credentials. api-key in opts is masked in call records and never written to context, so parallel flows and tenants in one run don't see each other's keys. Present but blank or null, it is an error, never a fallback to context. A per-call base-url without an api-key in the same opts sends no key: the context key is never sent to a per-call URL.

Context Vars

Optional
  • fdic.bankfind.api-key
  • fdic.bankfind.base-url

Values

BASE_URL

BASE_URL: Str "https://api.fdic.gov/banks"

PACKAGE_AGENT

PACKAGE_AGENT: Str "hot-dev-fdic-bankfind-pkg/0.1 (+https://hot.dev)"

SOURCE

SOURCE: Str "fdic-bankfind"

Functions

body-detail

fn (body: Any): Str?

decode-body

fn (response: ::hot::http/HttpResponse, url: Str): Any

The decoded JSON of a 2xx response without api_key in meta.parameters, or an Err carrying HttpError when the body is not JSON (pure). Exposed for testing.

drop-key

fn (body: Any): Any

body without api_key in the meta.parameters the API echoes (pure).

get-json

fn (url: Str, headers: Map): Any

GET a JSON resource and return the decoded body, or an Err carrying HttpError.

given

fn (v: Any): Bool

True for a non-null value that is not a blank string.

http-error

fn (response: ::hot::http/HttpResponse, url: Str): HttpError

Build an HttpError from a non-2xx response. Exposed for testing; every request uses it.

not-json-error

fn (response: ::hot::http/HttpResponse, url: Str): HttpError

An HttpError for a 2xx response that is not JSON, such as a maintenance page, which would otherwise read as an empty result. Exposed for testing.

pick

fn (opts: Map, key: Str, ctx-key: Str, default: Any): Any

query-string

fn (params: Map): Str

Build a ?a=1&b=2 suffix from a Map, dropping null and blank values (pure); "" when nothing remains.

redact

fn (text: Str, api-key: Str?): Str

text with any api_key value and every literal copy of api-key replaced by REDACTED (pure). api-key may be null.

redact-url

fn (url: Str): Str

url with any api_key value replaced by REDACTED (pure).

redact-value

fn (value: Any, api-key: Str?): Any

redact over a whole response value: a string, or every string inside a Map or Vec (pure).

request

fn (method: Str, url: Str, headers: Map): ::hot::http/HttpResponse

GET (or another method) a BankFind URL with headers, returning the HttpResponse on 2xx or an Err carrying HttpError. A transport failure stays its own Err, with any key redacted.

resolve

fn (opts: Map): Map

Resolve settings for one call: {api-key, base-url}. Values in opts win over context; an api-key in opts is used for that call only and comes back unchanged. api-key is null when none is set, which the API accepts, and null when opts has a base-url but no api-key. An Err when api-key is in opts but blank or null.

Example

cfg ::fdic::bankfind::api/resolve({api-key: tenant.fdic-key})

retry-after

fn (headers: Map): Int?

strip-slash

fn (url: Str): Str

url-key

fn (url: Str): Str?

Types

HttpError

HttpError type {
    source: Str,
    status: Int,
    url: Str,
    headers: Map,
    body: Any,
    retry-after: Int?,
    message: Str
}

A failed FDIC response. source is "fdic-bankfind"; url the requested URL with any key redacted; headers and body redacted too; retry-after the parsed Retry-After seconds on 429s; message a one-line summary that never includes credentials. status is normally non-2xx, but it is 200 when the site answered with something other than JSON (see decode-body).