HashiCorp Consul Catalog API

Register and query services and nodes

OpenAPI Specification

consul-catalog-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: HashiCorp Consul HTTP ACL Catalog API
  description: The Consul HTTP API provides full access to Consul functionality including service discovery, health checking, key/value storage, ACL management, Connect service mesh, configuration entries, and multi-datacenter operations.
  version: 1.18.0
  contact:
    name: HashiCorp
    url: https://www.consul.io/
  license:
    name: Business Source License 1.1
    url: https://github.com/hashicorp/consul/blob/main/LICENSE
servers:
- url: http://localhost:8500/v1
  description: Local Consul agent
- url: https://{consul_host}:{port}/v1
  description: Custom Consul server
  variables:
    consul_host:
      default: localhost
    port:
      default: '8500'
security:
- ConsulToken: []
tags:
- name: Catalog
  description: Register and query services and nodes
paths:
  /catalog/register:
    put:
      operationId: catalogRegister
      summary: Register entity
      description: Registers or updates entries in the catalog (low-level).
      tags:
      - Catalog
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogRegistration'
      responses:
        '200':
          description: Entity registered
  /catalog/deregister:
    put:
      operationId: catalogDeregister
      summary: Deregister entity
      description: Directly removes entries from the catalog.
      tags:
      - Catalog
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                Node:
                  type: string
                Datacenter:
                  type: string
                ServiceID:
                  type: string
                CheckID:
                  type: string
      responses:
        '200':
          description: Entity deregistered
  /catalog/datacenters:
    get:
      operationId: listDatacenters
      summary: List datacenters
      description: Returns the list of all known datacenters sorted by estimated round trip time.
      tags:
      - Catalog
      responses:
        '200':
          description: List of datacenter names
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
  /catalog/nodes:
    get:
      operationId: listCatalogNodes
      summary: List nodes
      description: Returns the nodes registered in a given datacenter.
      tags:
      - Catalog
      parameters:
      - $ref: '#/components/parameters/dc'
      - name: near
        in: query
        schema:
          type: string
      - name: filter
        in: query
        schema:
          type: string
      responses:
        '200':
          description: List of catalog nodes
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CatalogNode'
  /catalog/services:
    get:
      operationId: listCatalogServices
      summary: List services
      description: Returns the services registered in a given datacenter.
      tags:
      - Catalog
      parameters:
      - $ref: '#/components/parameters/dc'
      - name: ns
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Map of service names to tags
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
  /catalog/service/{serviceName}:
    get:
      operationId: getCatalogService
      summary: List nodes for a service
      description: Returns the nodes providing a given service in a datacenter.
      tags:
      - Catalog
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      - $ref: '#/components/parameters/dc'
      - name: tag
        in: query
        schema:
          type: string
      - name: near
        in: query
        schema:
          type: string
      - name: filter
        in: query
        schema:
          type: string
      responses:
        '200':
          description: List of service instances
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CatalogServiceInstance'
  /catalog/node/{node}:
    get:
      operationId: getCatalogNode
      summary: List services for a node
      description: Returns the node's registered services.
      tags:
      - Catalog
      parameters:
      - name: node
        in: path
        required: true
        schema:
          type: string
      - $ref: '#/components/parameters/dc'
      - name: filter
        in: query
        schema:
          type: string
      responses:
        '200':
          description: Node info with services
          content:
            application/json:
              schema:
                type: object
                properties:
                  Node:
                    $ref: '#/components/schemas/CatalogNode'
                  Services:
                    type: object
                    additionalProperties:
                      $ref: '#/components/schemas/AgentService'
components:
  schemas:
    AgentService:
      type: object
      properties:
        ID:
          type: string
        Service:
          type: string
        Tags:
          type: array
          items:
            type: string
        Meta:
          type: object
          additionalProperties:
            type: string
        Port:
          type: integer
        Address:
          type: string
        EnableTagOverride:
          type: boolean
        Weights:
          type: object
          properties:
            Passing:
              type: integer
            Warning:
              type: integer
        Namespace:
          type: string
    CatalogRegistration:
      type: object
      required:
      - Node
      - Address
      properties:
        Node:
          type: string
        Address:
          type: string
        Datacenter:
          type: string
        TaggedAddresses:
          type: object
          additionalProperties:
            type: string
        NodeMeta:
          type: object
          additionalProperties:
            type: string
        Service:
          $ref: '#/components/schemas/AgentService'
        Check:
          $ref: '#/components/schemas/HealthCheck'
    CatalogNode:
      type: object
      properties:
        ID:
          type: string
        Node:
          type: string
        Address:
          type: string
        Datacenter:
          type: string
        TaggedAddresses:
          type: object
          additionalProperties:
            type: string
        Meta:
          type: object
          additionalProperties:
            type: string
        CreateIndex:
          type: integer
        ModifyIndex:
          type: integer
    CatalogServiceInstance:
      type: object
      properties:
        ID:
          type: string
        Node:
          type: string
        Address:
          type: string
        Datacenter:
          type: string
        ServiceID:
          type: string
        ServiceName:
          type: string
        ServiceTags:
          type: array
          items:
            type: string
        ServiceAddress:
          type: string
        ServicePort:
          type: integer
        ServiceMeta:
          type: object
          additionalProperties:
            type: string
        ServiceWeights:
          type: object
          properties:
            Passing:
              type: integer
            Warning:
              type: integer
        CreateIndex:
          type: integer
        ModifyIndex:
          type: integer
    HealthCheck:
      type: object
      properties:
        Node:
          type: string
        CheckID:
          type: string
        Name:
          type: string
        Status:
          type: string
          enum:
          - passing
          - warning
          - critical
        Notes:
          type: string
        Output:
          type: string
        ServiceID:
          type: string
        ServiceName:
          type: string
        ServiceTags:
          type: array
          items:
            type: string
        Type:
          type: string
        CreateIndex:
          type: integer
        ModifyIndex:
          type: integer
  parameters:
    dc:
      name: dc
      in: query
      description: Datacenter to query (defaults to agent's datacenter)
      schema:
        type: string
  securitySchemes:
    ConsulToken:
      type: apiKey
      name: X-Consul-Token
      in: header
      description: ACL token for authentication