{
  "openapi": "3.1.0",
  "info": {
    "title": "CPV.no search",
    "version": "1.0.0",
    "description": "Read-only search of Norway's public procurement classification."
  },
  "servers": [{ "url": "https://cpv.no" }],
  "paths": {
    "/api/search": {
      "get": {
        "operationId": "searchCpv",
        "summary": "Search main and supplementary CPV codes",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "CPV code, code prefix, or Norwegian or English keywords.",
            "schema": { "type": "string", "minLength": 1, "maxLength": 100 },
            "example": "72000000-5"
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Pass nextOffset from a previous page.",
            "schema": { "type": "integer", "minimum": 0, "default": 0 }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching codes and pagination.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["total", "nextOffset", "results"],
                  "properties": {
                    "total": { "type": "integer", "minimum": 0 },
                    "nextOffset": { "type": ["integer", "null"], "minimum": 0 },
                    "results": {
                      "type": "array",
                      "maxItems": 24,
                      "items": {
                        "type": "object",
                        "required": ["code", "norwegian", "english", "url"],
                        "properties": {
                          "code": { "type": "string" },
                          "norwegian": { "type": ["string", "null"] },
                          "english": { "type": "string" },
                          "url": { "type": "string", "format": "uri" }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": { "description": "Invalid query or offset." }
        }
      }
    }
  }
}
