OpenMercantil Search API

Company and person search endpoints

OpenAPI Specification

openmercantil-search-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: OpenMercantil Public Billing Search 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: Search
  description: Company and person search endpoints
paths:
  /api/v1/search:
    get:
      tags:
      - Search
      summary: Search Spanish Companies
      operationId: searchCompanies
      description: Search companies (and optionally persons) by name, alias or CIF using a prefix index. Returns results ordered by relevance. Public and rate-limited.
      parameters:
      - name: q
        in: query
        required: true
        schema:
          type: string
          minLength: 2
          example: mercadona
        description: Search query, minimum 2 characters.
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 20
        description: Maximum number of results.
      - name: offset
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          default: 0
        description: Pagination offset.
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api/v1/person/search:
    get:
      tags:
      - Search
      summary: Search Persons
      operationId: searchPersons
      description: Search persons (officers, administrators, beneficial owners) by name.
      parameters:
      - name: q
        in: query
        required: true
        schema:
          type: string
          minLength: 2
          example: amancio ortega
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 100
          default: 20
      - name: offset
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          default: 0
      responses:
        '200':
          description: Person search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PersonSearchResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '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'
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    CompanySearchItem:
      type: object
      properties:
        slug:
          type: string
          example: mercadona-sa
        name:
          type: string
          example: MERCADONA SA
        cif:
          type: string
          example: A46103834
        acts_count:
          type: integer
        last_seen:
          type: string
          nullable: true
        aliases:
          type: array
          items:
            type: string
      additionalProperties: true
    SearchResponse:
      type: object
      required:
      - query
      - count
      - items
      properties:
        query:
          type: string
        count:
          type: integer
        offset:
          type: integer
        items:
          type: array
          items:
            $ref: '#/components/schemas/CompanySearchItem'
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
      additionalProperties: true
    PersonSearchItem:
      type: object
      properties:
        slug:
          type: string
        name:
          type: string
        company_count:
          type: integer
      additionalProperties: true
    PersonSearchResponse:
      type: object
      properties:
        query:
          type: string
        count:
          type: integer
        items:
          type: array
          items:
            $ref: '#/components/schemas/PersonSearchItem'
      additionalProperties: true
  securitySchemes:
    sessionCookie:
      type: apiKey
      in: cookie
      name: session
      description: Session cookie issued after web sign-in, required only for billing endpoints.