CoinGecko · API Governance Rules

CoinGecko API Rules

Spectral linting rules defining API design standards and conventions for CoinGecko.

10 Rules error 3 warn 5 info 2
View Rules File View on GitHub

Rule Categories

coingecko

Rules

error
coingecko-info-contact
API contact information must be present.
$.info
error
coingecko-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
coingecko-server-host
Server URLs must reference a CoinGecko host.
$.servers[*].url
info
coingecko-versioned-path
Server URLs should expose /api/v3 versioning.
$.servers[*].url
warn
coingecko-api-key-header
Authenticated APIs should use x-cg-demo-api-key or x-cg-pro-api-key.
$.components.securitySchemes[*]
error
coingecko-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
coingecko-operation-tags
Operations must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
coingecko-operation-summary
Operations should declare a summary.
$.paths[*][get,post,put,patch,delete]
warn
coingecko-error-responses
GET operations should declare 401 and 429 error responses.
$.paths[*].get.responses
info
coingecko-currency-param
Pricing endpoints should accept vs_currency or vs_currencies.
$.paths[*].get.parameters[?(@.in == 'query')]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for CoinGecko APIs (Crypto Market Data, Pro,
# Onchain DEX). Tuned to api.coingecko.com / pro-api.coingecko.com host
# conventions, x-cg-demo-api-key / x-cg-pro-api-key auth headers, and
# the /api/v3 versioned URI prefix.
rules:
  coingecko-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

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

  coingecko-server-host:
    description: Server URLs must reference a CoinGecko host.
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "(api\\.coingecko\\.com|pro-api\\.coingecko\\.com)"

  coingecko-versioned-path:
    description: Server URLs should expose /api/v3 versioning.
    severity: info
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "/api/v3"

  coingecko-api-key-header:
    description: Authenticated APIs should use x-cg-demo-api-key or x-cg-pro-api-key.
    severity: warn
    given: "$.components.securitySchemes[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              const: apiKey
            in:
              const: header
            name:
              enum:
                - x-cg-demo-api-key
                - x-cg-pro-api-key

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

  coingecko-operation-tags:
    description: Operations 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

  coingecko-operation-summary:
    description: Operations should declare a summary.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  coingecko-error-responses:
    description: GET operations should declare 401 and 429 error responses.
    severity: warn
    given: "$.paths[*].get.responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["401"]
            - required: ["429"]

  coingecko-currency-param:
    description: Pricing endpoints should accept vs_currency or vs_currencies.
    severity: info
    given: "$.paths[*].get.parameters[?(@.in == 'query')]"
    then:
      field: name
      function: enumeration
      functionOptions:
        values:
          - vs_currency
          - vs_currencies
          - ids
          - id
          - contract_address
          - addresses
          - days
          - precision
          - per_page
          - page
          - order
          - category