ClinicalTrials.gov · API Governance Rules

ClinicalTrials.gov API Rules

Spectral linting rules defining API design standards and conventions for ClinicalTrials.gov.

9 Rules error 3 warn 5 info 1
View Rules File View on GitHub

Rule Categories

ctg

Rules

error
ctg-info-contact
API contact information must be present.
$.info
warn
ctg-info-license
API license must be declared.
$.info
error
ctg-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
ctg-server-versioned
Data API server URL must include /api/v2.
$.servers[?(@.url && @.url.indexOf('clinicaltrials.gov') > -1)].url
warn
ctg-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
ctg-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
error
ctg-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
info
ctg-pagination-page-size
List endpoints should support pageSize and pageToken parameters.
$.paths[?(@property == '/studies')].get.parameters[*].name
warn
ctg-nct-id-pattern
nctId path parameters should match the NCT identifier pattern.
$.paths[?(@property.match(/{nctId}/))]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for the ClinicalTrials.gov Data API v2.
# https://clinicaltrials.gov/data-api/api — open, unauthenticated,
# JSON-by-default REST API hosted at https://clinicaltrials.gov/api/v2.
rules:
  ctg-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  ctg-info-license:
    description: API license must be declared.
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy

  ctg-server-https:
    description: All server URLs must use HTTPS.
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  ctg-server-versioned:
    description: Data API server URL must include /api/v2.
    severity: warn
    given: "$.servers[?(@.url && @.url.indexOf('clinicaltrials.gov') > -1)].url"
    then:
      function: pattern
      functionOptions:
        match: "/api/v2$"

  ctg-operation-tags:
    description: Every operation must declare at least one tag.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  ctg-operation-summary:
    description: Every operation must include a short summary.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  ctg-operation-id:
    description: Every operation must declare a unique operationId.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  ctg-pagination-page-size:
    description: List endpoints should support pageSize and pageToken parameters.
    severity: info
    given: "$.paths[?(@property == '/studies')].get.parameters[*].name"
    then:
      function: enumeration
      functionOptions:
        values:
          - pageSize
          - pageToken
          - query.term
          - query.cond
          - query.intr
          - query.locn
          - filter.overallStatus
          - format
          - countTotal
          - fields

  ctg-nct-id-pattern:
    description: nctId path parameters should match the NCT identifier pattern.
    severity: warn
    given: "$.paths[?(@property.match(/{nctId}/))]"
    then:
      function: truthy

Work with this as data

Every ruleset here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for spectral rules

4 MCP tools reach this
  • find_rulesBrowse and filter every ruleset in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This ruleset
curl "https://apis.io/api/v1/rules/clinical-trials-gov-rules"
All spectral rules
curl "https://apis.io/api/v1/rules?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.