{
  "openapi": "3.1.0",
  "info": {
    "title": "Market Invoice Data API",
    "summary": "Read-only public data on UK invoice finance providers and rates.",
    "description": "Machine-readable access to the Market Invoice UK Invoice Finance Rate Index: verified provider terms (advance rate, service charge, minimum turnover, setup speed) and a current market snapshot. Source of truth is the on-site Rate Index Dataset. Read-only, no authentication, no PII, CC BY 4.0. Also exposed as an MCP server at /mcp (see /.well-known/mcp.json).",
    "version": "2026-05-24",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "contact": {
      "name": "Market Invoice",
      "url": "https://marketinvoice.co.uk/data/api/"
    }
  },
  "servers": [
    { "url": "https://marketinvoice.co.uk", "description": "Production" }
  ],
  "externalDocs": {
    "description": "Human-readable API documentation",
    "url": "https://marketinvoice.co.uk/data/api/"
  },
  "paths": {
    "/api/providers": {
      "get": {
        "operationId": "listProviders",
        "summary": "List verified UK invoice finance providers",
        "description": "Returns all tracked providers, or a filtered subset when query params are supplied.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Free-text match on provider name, summary and best-for tags.",
            "schema": { "type": "string" }
          },
          {
            "name": "cluster",
            "in": "query",
            "required": false,
            "description": "Filter by provider category.",
            "schema": {
              "type": "string",
              "enum": ["high-street", "independent", "recruitment-specialist", "fintech", "mid-market"]
            }
          },
          {
            "name": "confidential",
            "in": "query",
            "required": false,
            "description": "Set to true to return only providers offering confidential invoice discounting.",
            "schema": { "type": "boolean" }
          },
          {
            "name": "factoring",
            "in": "query",
            "required": false,
            "description": "Set to true to return only providers offering factoring.",
            "schema": { "type": "boolean" }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of providers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema_version": { "type": "string" },
                    "source": { "type": "string", "format": "uri" },
                    "license": { "type": "string", "format": "uri" },
                    "count": { "type": "integer" },
                    "providers": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Provider" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/providers/{slug}": {
      "get": {
        "operationId": "getProvider",
        "summary": "Get a single provider by slug",
        "description": "Accepts the canonical slug (e.g. bibby-financial-services) or the short profile slug (e.g. bibby).",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "example": "bibby-financial-services"
          }
        ],
        "responses": {
          "200": {
            "description": "The matching provider.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema_version": { "type": "string" },
                    "source": { "type": "string", "format": "uri" },
                    "license": { "type": "string", "format": "uri" },
                    "provider": { "$ref": "#/components/schemas/Provider" }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No provider matches the slug.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    },
    "/api/rates": {
      "get": {
        "operationId": "getRates",
        "summary": "Current UK invoice finance market snapshot",
        "description": "Advance-rate range across tracked providers plus the Bank of England base rate as a dated reference.",
        "responses": {
          "200": {
            "description": "Market snapshot.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RatesSnapshot" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Provider": {
        "type": "object",
        "properties": {
          "slug": { "type": "string" },
          "name": { "type": "string" },
          "legal_name": { "type": "string" },
          "company_number": { "type": "string" },
          "founded_year": { "type": "integer" },
          "homepage": { "type": "string", "format": "uri" },
          "profile_url": { "type": "string", "format": "uri" },
          "product_type": { "type": "string" },
          "cluster": { "type": "string" },
          "minimum_turnover": { "type": "string" },
          "advance_rate": { "type": "string" },
          "typical_rate": { "type": "string" },
          "setup_speed": { "type": "string" },
          "confidential_invoice_discounting": { "type": "boolean" },
          "factoring": { "type": "boolean" },
          "rating": {
            "type": "object",
            "properties": {
              "overall": { "type": "number" },
              "transparency": { "type": "number" },
              "speed": { "type": "number" },
              "flexibility": { "type": "number" }
            }
          },
          "summary": { "type": "string" },
          "pros": { "type": "array", "items": { "type": "string" } },
          "cons": { "type": "array", "items": { "type": "string" } },
          "best_for": { "type": "array", "items": { "type": "string" } },
          "weak_at": { "type": "array", "items": { "type": "string" } },
          "last_reviewed": { "type": "string", "format": "date" },
          "wikidata": { "type": "string" }
        },
        "required": ["slug", "name", "homepage", "product_type", "cluster"]
      },
      "RatesSnapshot": {
        "type": "object",
        "properties": {
          "schema_version": { "type": "string" },
          "as_of": { "type": "string", "format": "date" },
          "currency": { "type": "string" },
          "region": { "type": "string" },
          "bank_of_england_base_rate": {
            "type": "object",
            "properties": {
              "value": { "type": "number" },
              "unit": { "type": "string" },
              "as_of": { "type": "string", "format": "date" },
              "source": { "type": "string", "format": "uri" },
              "note": { "type": "string" }
            }
          },
          "advance_rate": {
            "type": "object",
            "properties": {
              "min_percent": { "type": ["number", "null"] },
              "max_percent": { "type": ["number", "null"] },
              "note": { "type": "string" }
            }
          },
          "providers_count": { "type": "integer" },
          "source": { "type": "string", "format": "uri" },
          "license": { "type": "string", "format": "uri" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "detail": { "type": "string" }
        }
      }
    }
  }
}
