OpenMercantil Sectors API

CNAE sector taxonomy and sector statistics

OpenAPI Specification

openmercantil-sectors-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: OpenMercantil Public Billing Sectors API
  version: 1.4.0
  description: 'Public JSON API for Spanish company information derived from BORME and other

    public sources. OpenMercantil is independent and informational; it is not

    the BOE, BORME or Registro Mercantil and does not replace official

    certificates or registry extracts. The API is free and public, requires no

    API key, and is rate-limited per IP. Versions v1.0 through v1.4 are

    available and documented at https://openmercantil.es/api/documentacion.

    '
  termsOfService: https://openmercantil.es/terminos-de-uso
  contact:
    name: OpenMercantil
    url: https://openmercantil.es/soporte
    email: social@openmercantil.es
  license:
    name: CC BY 4.0 For Derived Public-Data Outputs
    url: https://creativecommons.org/licenses/by/4.0/
servers:
- url: https://openmercantil.es
  description: Production
tags:
- name: Sectors
  description: CNAE sector taxonomy and sector statistics
paths:
  /api/v1/cnae/tree:
    get:
      tags:
      - Sectors
      summary: Get CNAE Hierarchy Tree
      operationId: getCnaeTree
      description: Return the hierarchical CNAE 2009 sector taxonomy (v1.1).
      responses:
        '200':
          description: CNAE tree
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api/v1/cnae/{code}:
    get:
      tags:
      - Sectors
      summary: Get CNAE Code Info
      operationId: getCnaeCode
      description: Return the CNAE 2009 sector descriptor for a given code (v1.1).
      parameters:
      - name: code
        in: path
        required: true
        schema:
          type: string
          example: '4711'
      responses:
        '200':
          description: CNAE descriptor
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api/v1/sector/{code}/companies:
    get:
      tags:
      - Sectors
      summary: List Companies In A Sector
      operationId: getSectorCompanies
      description: List companies in a CNAE sector (v1.1).
      parameters:
      - name: code
        in: path
        required: true
        schema:
          type: string
          example: '4711'
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 20
      responses:
        '200':
          description: Sector companies
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api/v1/sector/{code}/ratios:
    get:
      tags:
      - Sectors
      summary: Get Sector Financial Ratios
      operationId: getSectorRatios
      description: Return aggregated financial ratios for a CNAE sector (BdE data) (v1.1).
      parameters:
      - name: code
        in: path
        required: true
        schema:
          type: string
          example: '4711'
      responses:
        '200':
          description: Sector ratios
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api/v1/sectores/stats:
    get:
      tags:
      - Sectors
      summary: Get Sector Aggregate Statistics
      operationId: getSectorStats
      description: Return aggregate company counts and growth statistics across CNAE sectors.
      responses:
        '200':
          description: Sector stats
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api/v1/sectores/stats.csv:
    get:
      tags:
      - Sectors
      summary: Export Sector Aggregate Statistics As CSV
      operationId: getSectorStatsCsv
      description: CSV download of aggregate sector statistics.
      responses:
        '200':
          description: CSV download
          content:
            text/csv:
              schema:
                type: string
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  responses:
    TooManyRequests:
      description: Rate limit exceeded
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Maximum requests per window (60 per minute by IP on the public anonymous tier).
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Remaining requests in the current window.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: Unix timestamp when the rate-limit counter resets.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
      additionalProperties: true
  securitySchemes:
    sessionCookie:
      type: apiKey
      in: cookie
      name: session
      description: Session cookie issued after web sign-in, required only for billing endpoints.