The Regulations.gov API v4 (https://api.regulations.gov/v4):
documents, dockets and public comments, read-only. Posting comments
is not wrapped.
Auth: a free api.data.gov key in the X-Api-Key header. Set
regulations-gov.api-key or pass {api-key: ...} per call.
Paging: lists take page-size (5 to 250) and page. next-page
gives the next page number. The API documents pages 1 to 20, so one
query reaches 5,000 records: all-documents, all-comments and
all-dockets go past that by sorting on lastModifiedDate and
restarting from the last record seen, the procedure the API
documents. lastModifiedDate is in beta upstream and may be removed.
Context Vars
regulations-gov.api-keyregulations-gov.base-url
Values
MAX_PAGE
MAX_PAGE: Int 20
MAX_PAGE_SIZE
MAX_PAGE_SIZE: Int 250
MIN_PAGE_SIZE
MIN_PAGE_SIZE: Int 5
Functions
all-comments
fn (opts: Map, limit: Int): Vec
Up to limit comments matching opts.filters, oldest change first,
however many there are. Filter on one document with commentOnId.
Example
::reg ::regulations-gov
doc ::reg/document("FAA-2018-1084-0001")
rows ::reg/all-comments({filters: {commentOnId: doc.data.attributes.objectId}}, 20000)
all-dockets
fn (opts: Map, limit: Int): Vec
Up to limit dockets matching opts.filters, oldest change first,
however many there are.
Example
rows ::regulations-gov/all-dockets({filters: {agencyId: "FAA"}}, 1000)
length(rows)
all-documents
fn (opts: Map, limit: Int): Vec
Up to limit documents matching opts.filters, oldest change first,
however many there are. A lastModifiedDate filter is in Eastern
time, yyyy-MM-dd HH:mm:ss.
Example
rows ::regulations-gov/all-documents({filters: {docketId: "EOIR-2020-0003"}}, 20000)
collect-windows
fn (fetch: Fn, opts: Map, sort: Str, limit: Int): Vec
Fetch up to limit rows, past the paging ceiling of one query: read
20 pages of 250 sorted by sort, then restart from the last row's
lastModifiedDate, dropping the rows the overlap repeats. A full
page 20 restarts whatever hasNextPage says, so exactly 5,000 rows
costs one more request. fetch takes opts and returns one page.
all-documents, all-comments and all-dockets call this. Each
page is one request against the hourly limit.
Example
// A stand-in for `documents`: one page, no more after it
one-page {data: [{id: "a"}, {id: "b"}], meta: {hasNextPage: false}}
rows ::regulations-gov/collect-windows((o) { one-page }, {}, "lastModifiedDate,documentId", 10)
map(rows, %.id) // ["a", "b"]
comment
fn (id: Str): Map?
fn (id: Str, opts: Map): Map?
One comment, or null when there is none: {data, included}.
data.attributes.comment is the text. Attachments are only returned
with {include-attachments: true}, in included.
Example
c ::regulations-gov/comment("FAA-2018-1084-0002")
c.data.attributes.comment
with-files ::regulations-gov/comment("FAA-2018-1084-0002", {include-attachments: true})
with-files.included
comments
fn (): Map
fn (opts: Map): Map
One page of public comments: {data, meta}. opts: filters,
sort, page-size, page, plus api-key. Filters: agencyId,
searchTerm, postedDate, lastModifiedDate, commentOnId (a
document's objectId, not its id). Sort on postedDate,
lastModifiedDate or documentId.
Example
doc ::regulations-gov/document("FAA-2018-1084-0001")
page ::regulations-gov/comments({filters: {commentOnId: doc.data.attributes.objectId}, page-size: 50})
page.meta.totalElements
docket
fn (id: Str): Map?
fn (id: Str, opts: Map): Map?
One docket, or null when there is none: {data}. The RIN is
data.attributes.rin, which documents does not return.
Example
d ::regulations-gov/docket("FAA-2018-1084")
d.data.attributes.rin
dockets
fn (): Map
fn (opts: Map): Map
One page of dockets: {data, meta}. opts: filters, sort,
page-size, page, plus api-key. Filters: agencyId, searchTerm,
lastModifiedDate, docketType. Sort on title, docketId or
lastModifiedDate.
Example
page ::regulations-gov/dockets({
filters: {agencyId: "FAA", docketType: "Rulemaking"},
sort: "-lastModifiedDate",
page-size: 25
})
map(page.data, %.id)
document
fn (id: Str): Map?
fn (id: Str, opts: Map): Map?
One document, or null when there is none: {data, included}.
data.attributes.fileFormats has the download links. Attachments are
only returned with {include-attachments: true}, in included.
Example
doc ::regulations-gov/document("FAA-2018-1084-0001")
doc.data.attributes.title
with-files ::regulations-gov/document("FAA-2018-1084-0001", {include-attachments: true})
with-files.included
documents
fn (): Map
fn (opts: Map): Map
One page of documents: {data, meta}. Each row has id and
attributes with docketId, documentType, title, postedDate,
commentEndDate, lastModifiedDate, frDocNum, objectId (what
filter[commentOnId] takes) and withdrawn.
opts: filters, sort, page-size, page, plus api-key.
Filters: agencyId, commentEndDate, docketId, documentType,
frDocNum, searchTerm, postedDate, lastModifiedDate, subtype,
withinCommentPeriod. Sort on commentEndDate, postedDate,
lastModifiedDate, documentId or title, with a leading - for
descending.
Example
page ::regulations-gov/documents({
filters: {agencyId: "CFPB", postedDate: {ge: "2026-10-01"}},
sort: "-postedDate",
page-size: 25
})
first(page.data).attributes.title
eastern-date-time
fn (utc: Str): Str
The lastModifiedDate of a row, as the API returns it in UTC, in the
form the lastModifiedDate filter takes: Eastern time,
yyyy-MM-dd HH:mm:ss (pure).
Example
::regulations-gov/eastern-date-time("2020-08-10T15:58:52Z") // "2020-08-10 11:58:52"
filter-params
fn (filters: Map?): Map
filter[...] parameters from a Map of field → value (pure). A Map
value gives the ge and le forms. withinCommentPeriod: false is
dropped, as the API accepts only true.
Example
::regulations-gov/filter-params({agencyId: "EPA", postedDate: {ge: "2026-01-01"}})
// {"filter[agencyId]": "EPA", "filter[postedDate][ge]": "2026-01-01"}
list-params
fn (opts: Map): Map
Query parameters for a list call (pure): the filters, sort and
paging from opts.
Example
params ::regulations-gov/list-params({filters: {agencyId: "EPA"}, sort: "-postedDate", page-size: 25, page: 2})
get(params, "filter[agencyId]") // "EPA"
params.sort // "-postedDate"
get(params, "page[size]") // 25
next-cursor
fn (rows: Vec, cursor: Str?): Str
The ge value that starts the next window: the last row's
lastModifiedDate in Eastern time. An Err when it would not move past
cursor, which means one timestamp holds a whole window of records
(pure).
Example
rows [{attributes: {lastModifiedDate: "2020-08-10T15:58:52Z"}}]
::regulations-gov/next-cursor(rows, null) // "2020-08-10 11:58:52"
is-err(::regulations-gov/next-cursor(rows, "2020-08-10 11:58:52")) // true
next-page
fn (page: Any): Int?
The page number after page from meta, or null on the last page or
after page 20, the end of the API's documented range (pure).
Example
::regulations-gov/next-page({meta: {pageNumber: 2, hasNextPage: true}}) // 3
::regulations-gov/next-page({meta: {pageNumber: 2, hasNextPage: false}}) // null
::regulations-gov/next-page({meta: {pageNumber: 20, hasNextPage: true}}) // null
page-params
fn (opts: Map): Map
page[size] (held to 5 to 250) and page[number] from opts.page-size
and opts.page, null when unset, which query-string drops (pure).
Example
::regulations-gov/page-params({page-size: 1000, page: 2}) // {"page[size]": 250, "page[number]": 2}
window-opts
fn (opts: Map, sort: Str, cursor: Str?, page-number: Int): Map
opts for one page of a window (pure): the sort, the largest page
size, and filter[lastModifiedDate][ge] set to cursor when there is
one. Any le the caller gave stays.
Example
o ::regulations-gov/window-opts({filters: {agencyId: "EPA"}}, "lastModifiedDate,documentId", "2026-01-01 00:00:00", 1)
o.filters // {agencyId: "EPA", lastModifiedDate: {ge: "2026-01-01 00:00:00"}}
o.page-size // 250