Transport for SEC EDGAR: the settings resolver (per-call opts
first, then context variables), a typed HttpError, JSON GETs, and
query-string building that drops unset values.
| opts key | Context variable | Default |
|---|---|---|
user-agent | sec.edgar.user-agent | none: calls fail without it |
Per-call User-Agent. user-agent 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 contact details. Present but blank
or null, it is an error, never a fallback to context.
Context Vars
sec.edgar.user-agent
Values
SOURCE
SOURCE: Str "sec-edgar"
Functions
body-detail
fn (body: Any): Str?
columns-to-rows
fn (columns: Map, limit: Int): Vec<Map>
Turn a columnar Map ({a: [1, 2], b: [3, 4]}, as in EDGAR's
filings.recent) into a Vec of row Maps ([{a: 1, b: 3}, {a: 2, b: 4}]), at most limit rows. Columns shorter than the first are
padded with null. 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.
is-not-found
fn (e: Any): Bool
True when e is an HttpError with status 404.
path-segment
fn (value: Any): Str
Percent-encode one path segment.
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.
request
fn (method: Str, url: Str, headers: Map): ::hot::http/HttpResponse
GET (or another method) a SEC URL with headers, returning
the HttpResponse on 2xx or an Err carrying HttpError. A
transport failure passes through as its own Err.
require-user-agent
fn (cfg: Map): Str
The User-Agent from resolved settings, or an Err explaining that SEC requires one with contact details.
resolve
fn (opts: Map): Map
Resolve settings for one call: {user-agent}. A value in opts
wins over context; it is used for that call only and comes back
unchanged. An Err when user-agent is in opts but blank or null.
Example
cfg ::sec::edgar::api/resolve({user-agent: "Tenant Co ops@tenant.example"})
retry-after
fn (headers: Map): Int?
Types
HttpError
HttpError type {
source: Str,
status: Int,
url: Str,
headers: Map,
body: Any,
retry-after: Int?,
message: Str
}
A non-2xx SEC response. source is "sec-edgar"; url the
requested URL (SEC takes no credentials in URLs); retry-after
the parsed Retry-After seconds on 429s; message a one-line
summary that never includes credentials.