US Census Bureau · API Governance Rules

US Census Bureau API Rules

Spectral linting rules defining API design standards and conventions for US Census Bureau.

7 Rules error 3 warn 4
View Rules File View on GitHub

Rule Categories

census

Rules

error
census-info-contact-required
Every Census Bureau API must publish a contact under `info.contact`.
$.info
error
census-info-license-required
All Census Bureau APIs are released under CC0 / Public Domain — `info.license` must be present.
$.info
warn
census-server-must-use-api-census-gov
Census Data and Microdata APIs must be served from `https://api.census.gov/data`.
$.servers[*].url
warn
census-operations-title-case-summary
Operation summaries must use Title Case (sentence-style summaries are not allowed).
$.paths.*.*.summary
error
census-operations-operationid-camelcase
operationId must be camelCase.
$.paths.*.*.operationId
warn
census-data-api-key-required
All Census Data API operations (excluding metadata endpoints) must declare `ApiKeyQuery` security.
$.paths['/{vintage}/acs/acs5','/{vintage}/acs/acs1','/{vintage}/dec/pl','/{vintage}/cbp','/{vintage}/pep/population','/{vintage}/pulse'].get
warn
census-paths-must-include-vintage
Census Data API paths must include a `{vintage}` path parameter so consumers can target the correct reference year.
$.paths

Spectral Ruleset

Raw ↑
extends: [[spectral:oas, all]]
rules:
  census-info-contact-required:
    description: Every Census Bureau API must publish a contact under `info.contact`.
    severity: error
    given: $.info
    then:
      field: contact
      function: truthy
  census-info-license-required:
    description: All Census Bureau APIs are released under CC0 / Public Domain — `info.license` must be present.
    severity: error
    given: $.info
    then:
      field: license
      function: truthy
  census-server-must-use-api-census-gov:
    description: Census Data and Microdata APIs must be served from `https://api.census.gov/data`.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: '^https://(api\.census\.gov/data|geocoding\.geo\.census\.gov|tigerweb\.geo\.census\.gov|www\.census\.gov).*'
  census-operations-title-case-summary:
    description: Operation summaries must use Title Case (sentence-style summaries are not allowed).
    severity: warn
    given: $.paths.*.*.summary
    then:
      function: pattern
      functionOptions:
        match: '^[A-Z0-9][A-Za-z0-9]*(\s(A|An|And|As|At|But|By|For|From|In|Into|Of|On|Or|The|To|With|[A-Z0-9][A-Za-z0-9]*))*$'
  census-operations-operationid-camelcase:
    description: operationId must be camelCase.
    severity: error
    given: $.paths.*.*.operationId
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]+$'
  census-data-api-key-required:
    description: All Census Data API operations (excluding metadata endpoints) must declare `ApiKeyQuery` security.
    severity: warn
    given: $.paths['/{vintage}/acs/acs5','/{vintage}/acs/acs1','/{vintage}/dec/pl','/{vintage}/cbp','/{vintage}/pep/population','/{vintage}/pulse'].get
    then:
      field: security
      function: truthy
  census-paths-must-include-vintage:
    description: Census Data API paths must include a `{vintage}` path parameter so consumers can target the correct reference year.
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: '\{vintage\}'