{
  "openapi": "3.1.0",
  "info": {
    "title": "Global Tender Signals API",
    "version": "0.4.0",
    "termsOfService": "https://global-tender-signals.vercel.app/terms/",
    "x-logo": {"url": "https://global-tender-signals.vercel.app/favicon.svg", "altText": "Global Tender Signals logo"},
    "description": "Customer-facing contract for Global Tender Signals through the RapidAPI gateway. Query normalized public procurement records, ranked opportunity signals, buyer intelligence and explicit market coverage metadata. Opportunity scores prioritize evidence; they do not guarantee future procurement outcomes."
  },
  "externalDocs": {"description": "Official developer guide and API onboarding", "url": "https://global-tender-signals.vercel.app/developers/"},
  "servers": [
    {
      "url": "https://global-tender-signals1.p.rapidapi.com",
      "description": "RapidAPI customer gateway"
    }
  ],
  "tags": [
    { "name": "Service", "description": "Service and bounded discovery surfaces." },
    { "name": "Markets", "description": "Market availability, locale context and source coverage." },
    { "name": "Intelligence", "description": "Subscription endpoints for opportunities, records and buyers." }
  ],
  "components": {
    "securitySchemes": {
      "RapidApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-RapidAPI-Key",
        "description": "Your RapidAPI application key. Obtain it by subscribing to a Global Tender Signals plan on RapidAPI."
      }
    },
    "parameters": {
      "RapidApiHost": {
        "name": "X-RapidAPI-Host",
        "in": "header",
        "required": true,
        "schema": { "type": "string", "const": "global-tender-signals1.p.rapidapi.com" },
        "example": "global-tender-signals1.p.rapidapi.com"
      },
      "Country": {
        "name": "country",
        "in": "query",
        "schema": { "type": "string", "pattern": "^[A-Z]{2}$" },
        "description": "Single ISO 3166-1 alpha-2 market code, for example US, GB or CA."
      },
      "Countries": {
        "name": "countries",
        "in": "query",
        "schema": { "type": "string" },
        "description": "Comma-separated ISO alpha-2 market codes. Up to 25 valid codes are applied."
      },
      "Region": {
        "name": "region",
        "in": "query",
        "schema": { "type": "string", "enum": ["africa", "americas", "asia", "europe", "oceania"] },
        "description": "Named regional scope. Ignored when country or countries is supplied."
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 }
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "schema": { "type": "integer", "minimum": 0, "maximum": 10000, "default": 0 }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "message": { "type": "string" }
        },
        "required": ["error"]
      },
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "limit": { "type": "integer" },
          "offset": { "type": "integer" },
          "next_offset": { "type": ["integer", "null"] },
          "sort": { "type": "string" }
        },
        "required": ["limit", "offset", "next_offset", "sort"]
      },
      "BuyerSummary": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "region_name": { "type": ["string", "null"] },
          "city": { "type": ["string", "null"] }
        }
      },
      "Opportunity": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "country_code": { "type": "string" },
          "headline": { "type": "string" },
          "source_url": { "type": ["string", "null"], "format": "uri" },
          "sector_code": { "type": ["string", "null"] },
          "cpv_prefix": { "type": ["string", "null"] },
          "signal_type": { "type": "string" },
          "score": { "type": "number" },
          "confidence": { "type": ["number", "null"] },
          "predicted_date": { "type": ["string", "null"], "format": "date" },
          "window_start": { "type": ["string", "null"], "format": "date" },
          "window_end": { "type": ["string", "null"], "format": "date" },
          "estimated_value": { "type": ["number", "null"] },
          "currency": { "type": ["string", "null"] },
          "estimated_value_eur": { "type": ["number", "null"] },
          "evidence_count": { "type": ["integer", "null"] },
          "explanation": { "type": ["object", "null"], "additionalProperties": true },
          "buyers": { "$ref": "#/components/schemas/BuyerSummary" }
        }
      },
      "ProcurementRecord": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "source_id": { "type": "string" },
          "external_id": { "type": "string" },
          "country_code": { "type": "string" },
          "record_type": { "type": ["string", "null"] },
          "notice_type": { "type": ["string", "null"] },
          "status": { "type": ["string", "null"] },
          "title": { "type": "string" },
          "description": { "type": ["string", "null"] },
          "cpv_codes": { "type": ["array", "null"], "items": { "type": "string" } },
          "sector_code": { "type": ["string", "null"] },
          "estimated_value": { "type": ["number", "null"] },
          "awarded_value": { "type": ["number", "null"] },
          "currency": { "type": ["string", "null"] },
          "publication_date": { "type": ["string", "null"], "format": "date" },
          "deadline_at": { "type": ["string", "null"], "format": "date-time" },
          "award_date": { "type": ["string", "null"], "format": "date" },
          "contract_start_date": { "type": ["string", "null"], "format": "date" },
          "contract_end_date": { "type": ["string", "null"], "format": "date" },
          "source_url": { "type": ["string", "null"], "format": "uri" },
          "buyers": { "type": ["object", "null"], "additionalProperties": true },
          "record_suppliers": { "type": ["array", "null"], "items": { "type": "object", "additionalProperties": true } }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid filter, region, sort or request parameter.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Problem" } } }
      },
      "Unauthorized": {
        "description": "A valid RapidAPI subscription/application key is required for this request.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Problem" } } }
      },
      "NotFound": {
        "description": "Endpoint or requested resource was not found.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Problem" } } }
      },
      "RateLimit": {
        "description": "RapidAPI plan or gateway rate limit reached. Upgrade or wait for the applicable reset."
      },
      "ServerError": {
        "description": "Temporary GTS or upstream dependency failure.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Problem" } } }
      }
    }
  },
  "security": [
    { "RapidApiKey": [] }
  ],
  "paths": {
    "/health": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Service"],
        "summary": "Service health and index counts",
        "responses": {
          "200": { "description": "Current service status, API version, market counts and indexed object counts." },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/showcase": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Service"],
        "summary": "Bounded product showcase",
        "description": "Returns featured live markets, current index counts and representative top signals. Searchable opportunity and record endpoints are separate subscription surfaces.",
        "responses": {
          "200": { "description": "Showcase payload." },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/context": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Markets"],
        "summary": "Suggested market and locale context",
        "description": "Returns detected country, suggested locale and whether the detected market is available. Manual market and locale overrides remain supported by clients.",
        "responses": {
          "200": { "description": "Detected context." },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/locales": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Markets"],
        "summary": "Enabled UI locales",
        "responses": {
          "200": { "description": "Enabled locale definitions." },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/markets": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Markets"],
        "summary": "Market availability and commercial delivery status",
        "parameters": [
          { "$ref": "#/components/parameters/Region" },
          { "name": "status", "in": "query", "schema": { "type": "string" } },
          { "name": "commercial_tier", "in": "query", "schema": { "type": "string", "enum": ["live", "priority", "catalog"] } },
          { "name": "delivery_mode", "in": "query", "schema": { "type": "string", "enum": ["indexed", "integration_queue", "on_demand_planned"] } },
          { "name": "featured", "in": "query", "schema": { "type": "boolean" } }
        ],
        "responses": {
          "200": { "description": "Ordered market list with coverage and commercial metadata." },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/coverage": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Markets"],
        "summary": "Official-source coverage metadata",
        "parameters": [{ "$ref": "#/components/parameters/Country" }],
        "responses": {
          "200": { "description": "Enabled market/source coverage rows including provenance, licensing and source status metadata." },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/opportunities": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Intelligence"],
        "summary": "Ranked commercial opportunity signals",
        "parameters": [
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/Countries" },
          { "$ref": "#/components/parameters/Region" },
          { "name": "sector", "in": "query", "schema": { "type": "string" } },
          { "name": "type", "in": "query", "schema": { "type": "string" }, "description": "Signal type, for example expiring_contract." },
          { "name": "min_score", "in": "query", "schema": { "type": "number", "default": 0 } },
          { "name": "min_value", "in": "query", "schema": { "type": "number", "minimum": 0, "default": 0 } },
          { "name": "q", "in": "query", "schema": { "type": "string" }, "description": "Case-insensitive headline text search." },
          { "name": "days", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 730, "default": 365 } },
          { "name": "sort", "in": "query", "schema": { "type": "string", "enum": ["score", "deadline", "date", "value"], "default": "score" } },
          { "$ref": "#/components/parameters/Limit" },
          { "$ref": "#/components/parameters/Offset" }
        ],
        "responses": {
          "200": {
            "description": "Opportunity rows plus pagination and query context.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": { "type": "array", "items": { "$ref": "#/components/schemas/Opportunity" } },
                    "meta": { "$ref": "#/components/schemas/PaginationMeta" }
                  },
                  "required": ["data", "meta"]
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/records": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Intelligence"],
        "summary": "Normalized procurement records",
        "parameters": [
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/Countries" },
          { "$ref": "#/components/parameters/Region" },
          { "name": "type", "in": "query", "schema": { "type": "string" }, "description": "Normalized record_type filter." },
          { "name": "cpv", "in": "query", "schema": { "type": "string" }, "description": "Exact CPV code contained in the record CPV array." },
          { "name": "q", "in": "query", "schema": { "type": "string" }, "description": "Case-insensitive title text search." },
          { "name": "sort", "in": "query", "schema": { "type": "string", "enum": ["latest", "deadline", "value", "award"], "default": "latest" } },
          { "$ref": "#/components/parameters/Limit" },
          { "$ref": "#/components/parameters/Offset" }
        ],
        "responses": {
          "200": {
            "description": "Normalized procurement rows plus pagination and query context.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": { "type": "array", "items": { "$ref": "#/components/schemas/ProcurementRecord" } },
                    "meta": { "$ref": "#/components/schemas/PaginationMeta" }
                  },
                  "required": ["data", "meta"]
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/v1/buyers/{id}": {
      "parameters": [{ "$ref": "#/components/parameters/RapidApiHost" }],
      "get": {
        "tags": ["Intelligence"],
        "summary": "Buyer history and active signals",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": {
            "description": "Buyer profile together with up to 200 recent procurement-history records and current active signals."
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/RateLimit" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    }
  }
}
