Binance · API Governance Rules

Binance API Rules

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

30 Rules error 8 warn 19 info 3
View Rules File View on GitHub

Rule Categories

binance error no query schema servers

Rules

error
binance-info-title-prefix
API title must start with "Binance"
$.info.title
error
binance-info-version-present
API info must have a version field
$.info
warn
binance-info-contact-present
API info must include contact details
$.info
error
binance-operation-summary-prefix
Operation summaries must start with "Binance"
$.paths[*][*].summary
warn
binance-operation-id-camel-case
Operation IDs must be camelCase
$.paths[*][*].operationId
warn
binance-operation-tags-present
Every operation must have at least one tag
$.paths[*][*]
warn
binance-operation-description-present
Every operation must have a description
$.paths[*][*]
warn
binance-path-kebab-case
Path segments must use kebab-case or standard patterns
$.paths
error
binance-request-body-post
POST operations must have a request body
$.paths[*].post
error
binance-response-success-present
Every operation must define a success response
$.paths[*][*].responses
warn
binance-schema-title-present
All schemas must have a title
$.components.schemas[*]
warn
binance-schema-description-present
All schemas must have a description
$.components.schemas[*]
error
binance-security-scheme-present
API must define at least one security scheme
$.components
warn
binance-hmac-auth-used
Binance APIs use HMAC SHA256 signed requests
$.components.securitySchemes[*]
warn
binance-operation-security-present
Private operations must declare security
$.paths[*][post,delete]
warn
binance-tags-defined
All tags used in operations must be defined at top level
$.tags
error
binance-servers-present
API must define servers
$
error
binance-server-https
Server URL must use HTTPS
$.servers[*].url
warn
binance-operation-examples-present
Responses with content should include examples
$.paths[*][*].responses[*].content[*]
warn
binance-microcks-operation-present
Every operation must include x-microcks-operation extension
$.paths[*][*]
warn
binance-timestamp-parameter
Signed endpoints should include timestamp parameter
$.paths[*][get,post,delete].parameters[?(@.name=='timestamp')]
info
binance-recvwindow-parameter
Signed endpoints may include recvWindow parameter
$.paths[*][*].parameters[?(@.name=='recvWindow')]
warn
binance-license-present
API info must include license
$.info
warn
binance-schema-properties-described
Schema properties must have descriptions
$.components.schemas[*].properties[*]
warn
servers-expected-domain
Server URLs should be on the binance.com domain.
$.servers[*].url
info
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be camelCase (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (Error) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# binance — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 24/26 servers on binance.com
#   - query-params-casing: snake @ 56% (n=850)
#   - operationid-casing: camel @ 99% (n=180)
#   - schema-names-casing: pascal @ 100% (n=30)
#   - schema-properties-casing: camel @ 67% (n=310)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - pagination params observed: ['limit', 'offset', 'page', 'pageSize', 'size']
#   - merge: kept 24 existing, added 6 measured, upgraded 0
#   - added: servers-expected-domain, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  binance-info-title-prefix:
    description: API title must start with "Binance"
    message: 'Info title must start with "Binance": {{value}}'
    severity: error
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Binance
  binance-info-version-present:
    description: API info must have a version field
    message: Info object must include a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  binance-info-contact-present:
    description: API info must include contact details
    message: Info object must include contact
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  binance-operation-summary-prefix:
    description: Operation summaries must start with "Binance"
    message: 'Operation summary must start with "Binance": {{value}}'
    severity: error
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: ^Binance
  binance-operation-id-camel-case:
    description: Operation IDs must be camelCase
    message: 'OperationId must be camelCase: {{value}}'
    severity: warn
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  binance-operation-tags-present:
    description: Every operation must have at least one tag
    message: Operations must include tags
    severity: warn
    given: $.paths[*][*]
    then:
      field: tags
      function: truthy
  binance-operation-description-present:
    description: Every operation must have a description
    message: Operations must include description
    severity: warn
    given: $.paths[*][*]
    then:
      field: description
      function: truthy
  binance-path-kebab-case:
    description: Path segments must use kebab-case or standard patterns
    message: 'Path segments should be lowercase: {{value}}'
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9/_{}.]*)+$
  binance-request-body-post:
    description: POST operations must have a request body
    message: POST operations must include requestBody
    severity: error
    given: $.paths[*].post
    then:
      field: requestBody
      function: truthy
  binance-response-success-present:
    description: Every operation must define a success response
    message: Operations must include a 200 or 201 response
    severity: error
    given: $.paths[*][*].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
  binance-schema-title-present:
    description: All schemas must have a title
    message: Schemas must include title
    severity: warn
    given: $.components.schemas[*]
    then:
      field: title
      function: truthy
  binance-schema-description-present:
    description: All schemas must have a description
    message: Schemas must include description
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  binance-security-scheme-present:
    description: API must define at least one security scheme
    message: Components must include securitySchemes
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  binance-hmac-auth-used:
    description: Binance APIs use HMAC SHA256 signed requests
    message: Security scheme must include API key authentication
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      function: truthy
  binance-operation-security-present:
    description: Private operations must declare security
    message: Trade operations must include security definition
    severity: warn
    given: $.paths[*][post,delete]
    then:
      field: security
      function: truthy
  binance-tags-defined:
    description: All tags used in operations must be defined at top level
    message: Tags must be defined in the global tags section
    severity: warn
    given: $.tags
    then:
      function: truthy
  binance-servers-present:
    description: API must define servers
    message: Servers array must be present and non-empty
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  binance-server-https:
    description: Server URL must use HTTPS
    message: 'Server URL must use HTTPS: {{value}}'
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  binance-operation-examples-present:
    description: Responses with content should include examples
    message: Response content should include examples
    severity: warn
    given: $.paths[*][*].responses[*].content[*]
    then:
      field: examples
      function: truthy
  binance-microcks-operation-present:
    description: Every operation must include x-microcks-operation extension
    message: Operations must include x-microcks-operation
    severity: warn
    given: $.paths[*][*]
    then:
      field: x-microcks-operation
      function: truthy
  binance-timestamp-parameter:
    description: Signed endpoints should include timestamp parameter
    message: Signed endpoint parameters should include timestamp
    severity: warn
    given: $.paths[*][get,post,delete].parameters[?(@.name=='timestamp')]
    then:
      function: truthy
  binance-recvwindow-parameter:
    description: Signed endpoints may include recvWindow parameter
    message: recvWindow parameter should be optional integer
    severity: info
    given: $.paths[*][*].parameters[?(@.name=='recvWindow')]
    then:
      function: truthy
  binance-license-present:
    description: API info must include license
    message: Info must include license
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy
  binance-schema-properties-described:
    description: Schema properties must have descriptions
    message: Schema properties must include description
    severity: warn
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the binance.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: binance\.com
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be camelCase (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: camel
  error-schema-defined:
    description: A shared error schema (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy