AgentSkillsCN

ecfr

通过 eCFR API 查询美国联邦法规(涵盖各机构、搜索功能、结构化数据与 XML 格式)

SKILL.md
--- frontmatter
name: ecfr
description: Query US Code of Federal Regulations via eCFR API (agencies, search, structure, XML)

eCFR API - US Code of Federal Regulations

Base URL: https://www.ecfr.gov

Admin Service

GET /api/admin/v1/agencies.json

Returns all agencies with their CFR references.

Parameters: None

Response fields: name, short_name, display_name, sortable_name, slug, children[], cfr_references[{title, chapter}]

GET /api/admin/v1/corrections.json

Returns all eCFR corrections.

Parameters:

NameTypeDescription
datestring (query)Restricts to corrections on/before this date AND corrected on/after. Format: YYYY-MM-DD
titlestring (query)Title number: '1', '2', '50', etc
error_corrected_datestring (query)Only corrections corrected on this date. Format: YYYY-MM-DD

Response fields: ecfr_corrections[{id, cfr_references[], corrective_action, error_corrected, error_occurred, fr_citation, position, display_in_toc, title, year, last_modified}]

GET /api/admin/v1/corrections/title/{title}.json

Returns corrections for a specific title.

Parameters:

NameTypeRequiredDescription
titlestring (path)YesTitle number: '1', '2', '50', etc

Search Service

All search endpoints share these common parameters:

NameTypeDescription
querystring (query)Search term; searches headings and full text
agency_slugs[]array[string] (query)Limit to agencies (get slugs from agencies endpoint)
datestring (query)Limit to content present on this date (YYYY-MM-DD)
last_modified_afterstring (query)Content modified after this date (YYYY-MM-DD)
last_modified_on_or_afterstring (query)Content modified on or after this date (YYYY-MM-DD)
last_modified_beforestring (query)Content modified before this date (YYYY-MM-DD)
last_modified_on_or_beforestring (query)Content modified on or before this date (YYYY-MM-DD)

GET /api/search/v1/results

Search results with pagination.

Additional parameters:

NameTypeDescription
per_pageinteger (query)Results per page (max 1000)
pageinteger (query)Page number (can't paginate beyond 10,000 total results)
orderstring (query)Order of results
paginate_bystring (query)'date' groups results by date on same page (requires last_modified_* param)

Response: {results[], meta: {description, current_page, total_count, total_pages, max_score, min_date, max_date}}

GET /api/search/v1/count

Returns count of matching results.

GET /api/search/v1/summary

Returns search summary details.

GET /api/search/v1/counts/daily

Returns result counts grouped by date.

GET /api/search/v1/counts/titles

Returns result counts grouped by CFR title.

GET /api/search/v1/counts/hierarchy

Returns result counts grouped by hierarchy level.

GET /api/search/v1/suggestions

Returns search suggestions/autocomplete.

Versioner Service

GET /api/versioner/v1/titles.json

Summary information about each title.

Parameters: None

Response: {titles[{number, name, latest_amended_on, latest_issue_date, up_to_date_as_of, reserved, processing_in_progress?}], meta: {date, import_in_progress}}

GET /api/versioner/v1/structure/{date}/title-{title}.json

Complete structure of a title as JSON (no content, just hierarchy).

Parameters:

NameTypeRequiredDescription
datestring (path)YesYYYY-MM-DD (use 'current' for latest)
titlestring (path)YesTitle number: '1', '2', '50', etc

Response: Nested structure with {type, label, label_level, label_description, identifier, reserved?, children[], section_range?}

GET /api/versioner/v1/full/{date}/title-{title}.xml

Source XML for a title or subset. Returns downloadable XML for full titles, processed XML for subsets.

Parameters:

NameTypeRequiredDescription
datestring (path)YesYYYY-MM-DD
titlestring (path)YesTitle number: '1', '2', '50', etc
subtitlestring (query)NoUppercase letter: 'A', 'B', 'C'
chapterstring (query)NoRoman numerals or digits: 'I', 'X', '1'
subchapterstring (query)NoRequires chapter. Uppercase letters: 'A', 'B', 'I'
partstring (query)NoPart identifier
subpartstring (query)NoRequires part. Generally uppercase letter: 'A', 'B', 'C'
sectionstring (query)NoRequires part. Format: '121.1', '13.4', '1.9'
appendixstring (query)NoRequires subtitle, chapter, or part. Formats: 'A', 'III', 'App. A'

GET /api/versioner/v1/ancestry/{date}/title-{title}.json

Returns complete hierarchy path from leaf node to title root.

Parameters: Same as full XML endpoint above.

Response: Array of ancestors from title down to requested node, each with {type, label, label_level, label_description, identifier, reserved?, section_range?}

GET /api/versioner/v1/versions/title-{title}.json

Returns all sections and appendices in a title with version history.

Parameters:

NameTypeRequiredDescription
titlestring (path)YesTitle number: '1', '2', '50', etc
issue_date[on]string (query)NoContent added on this issue date
issue_date[lte]string (query)NoContent added on or before this date
issue_date[gte]string (query)NoContent added on or after this date
subtitlestring (query)NoUppercase letter: 'A', 'B', 'C'
chapterstring (query)NoRoman numerals or digits: 'I', 'X', '1'
subchapterstring (query)NoRequires chapter.
partstring (query)NoPart identifier
subpartstring (query)NoRequires part.
sectionstring (query)NoRequires part.
appendixstring (query)NoRequires subtitle, chapter, or part.

Response: {content_versions[{date, amendment_date, issue_date, identifier, name, part, substantive, removed, subpart, title, type}], meta: {title, result_count, issue_date, latest_amendment_date, latest_issue_date}}

Error codes: 400 (bad request with message), 503 (title being processed, check Retry-After header)

CFR Title Reference

#Subject
1General Provisions
2Federal Financial Assistance
3The President
7Agriculture
10Energy
12Banks and Banking
14Aeronautics and Space
17Commodity and Securities Exchanges
20Employees' Benefits
21Food and Drugs
26Internal Revenue
29Labor
40Protection of Environment
42Public Health
45Public Welfare
47Telecommunication
49Transportation
50Wildlife and Fisheries

Hierarchy Dependency Rules

  • subchapter requires chapter
  • subpart requires part
  • section requires part
  • appendix requires subtitle, chapter, or part