{
  "openapi": "3.1.0",
  "info": {
    "title": "Deals Agent Public API",
    "version": "1.1.0",
    "description": "Read-only US, Canadian and Mexican publisher deals and observed prices. No user contact data. Default market is US. 90 requests/minute/IP. Cite citationUrl for DealsAgent observations and the publisher link for original promotions. Outbound publisher links carry service-level UTM labels. No checkout verification."
  },
  "servers": [
    {
      "url": "https://dealsagent.net"
    }
  ],
  "paths": {
    "/api/v1/offers": {
      "get": {
        "operationId": "searchDeals",
        "summary": "Search one market and currency",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search words",
            "schema": {
              "type": "string",
              "maxLength": 500
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "US=USD, CA=CAD, MX=MXN; no currency conversion",
            "schema": {
              "type": "string",
              "enum": [
                "US",
                "CA",
                "MX"
              ],
              "default": "US"
            }
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "description": "Ceiling in the selected currency; excludes unknown prices",
            "schema": {
              "type": "number",
              "minimum": 0
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Exact category",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Source ID from source coverage",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 24
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Pagination offset",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Publisher evidence. Prices are not checkout verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters"
          },
          "429": {
            "description": "Rate limit; retry after the response interval"
          }
        }
      }
    },
    "/api/v1/offers/{id}": {
      "get": {
        "operationId": "getOffer",
        "summary": "Read a publisher offer and observations",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Publisher evidence. Prices are not checkout verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Detail"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters"
          },
          "429": {
            "description": "Rate limit; retry after the response interval"
          },
          "404": {
            "description": "Offer not found"
          }
        }
      }
    },
    "/api/v1/offers/{id}/history": {
      "get": {
        "operationId": "getPriceHistory",
        "summary": "Read up to 100 observations and their price range",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Publisher evidence. Prices are not checkout verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/History"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters"
          },
          "429": {
            "description": "Rate limit; retry after the response interval"
          },
          "404": {
            "description": "Offer not found"
          }
        }
      }
    },
    "/api/v1/sources": {
      "get": {
        "operationId": "getSourceCoverage",
        "summary": "Read source coverage, collection status, country and currency",
        "responses": {
          "200": {
            "description": "Publisher evidence. Prices are not checkout verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceCoverage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters"
          },
          "429": {
            "description": "Rate limit; retry after the response interval"
          }
        }
      }
    },
    "/api/v1/offers/{id}/evidence": {
      "get": {
        "operationId": "getOfferEvidence",
        "summary": "Check freshness, source status, price history and citation provenance",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current eligibility plus historical evidence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Evidence"
                }
              }
            }
          },
          "400": {
            "description": "Invalid offer ID"
          },
          "404": {
            "description": "Offer not found"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Offer": {
        "type": "object",
        "required": [
          "id",
          "title",
          "url",
          "sourceUrl",
          "citationUrl",
          "price",
          "priceBasis",
          "currency",
          "fetchedAt"
        ],
        "properties": {
          "publisherOfferUrl": {
            "type": "string",
            "format": "uri",
            "description": "Original publisher offer destination with DealsAgent UTM attribution, consistent across search, detail, evidence and history."
          },
          "id": {
            "type": "string",
            "pattern": "^[a-f0-9]{20}$"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "In REST search/detail: publisher offer URL with UTM attribution. In evidence/history: canonical DealsAgent page."
          },
          "citationUrl": {
            "type": "string",
            "format": "uri",
            "description": "Stable DealsAgent evidence page; cite for our recorded observations."
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri",
            "description": "In REST search/detail: source website; use url for publisher offer. In evidence/history: publisher offer URL."
          },
          "sourceId": {
            "type": "string"
          },
          "sourceName": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "price": {
            "type": [
              "number",
              "null"
            ]
          },
          "referencePrice": {
            "type": [
              "number",
              "null"
            ]
          },
          "priceBasis": {
            "type": "string",
            "enum": [
              "structured",
              "headline",
              "listing",
              "unknown"
            ]
          },
          "offerType": {
            "type": "string",
            "enum": [
              "product",
              "promotion"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD",
              "CAD",
              "MXN"
            ]
          },
          "country": {
            "type": "string",
            "enum": [
              "US",
              "CA",
              "MX"
            ]
          },
          "category": {
            "type": "string"
          },
          "merchant": {
            "type": "string"
          },
          "conditions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fetchedAt": {
            "type": "string",
            "format": "date-time"
          },
          "publishedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "required": [
          "deals",
          "total"
        ],
        "properties": {
          "deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Offer"
            }
          },
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        }
      },
      "Detail": {
        "type": "object",
        "required": [
          "deal",
          "presentInLatestFeed",
          "observations"
        ],
        "properties": {
          "deal": {
            "$ref": "#/components/schemas/Offer"
          },
          "presentInLatestFeed": {
            "type": "boolean",
            "description": "Presence alone is not freshness. Use evidence eligibility."
          },
          "observations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "observedAt": {
                  "type": "string"
                },
                "price": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "currency": {
                  "type": "string"
                },
                "basis": {
                  "type": "string"
                },
                "imported": {
                  "type": "integer"
                },
                "jobId": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "History": {
        "type": "object",
        "properties": {
          "offer": {
            "$ref": "#/components/schemas/Offer"
          },
          "presentInLatestFeed": {
            "type": "boolean"
          },
          "observations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "observedAt": {
                  "type": "string"
                },
                "price": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "currency": {
                  "type": "string"
                },
                "basis": {
                  "type": "string"
                },
                "imported": {
                  "type": "integer"
                },
                "jobId": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "summary": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string"
              },
              "observationCount": {
                "type": "integer"
              },
              "lowestObserved": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "highestObserved": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          },
          "limitation": {
            "type": "string"
          }
        }
      },
      "SourceCoverage": {
        "type": "object",
        "properties": {
          "scope": {
            "type": "string"
          },
          "markets": {
            "type": "object"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "country": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                },
                "method": {
                  "type": "string"
                },
                "website": {
                  "type": "string"
                },
                "feedUrl": {
                  "type": "string"
                },
                "pages": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "coverage": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ok",
                    "blocked",
                    "error",
                    "pending"
                  ]
                },
                "count": {
                  "type": "integer"
                },
                "checkedAt": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Evidence": {
        "type": "object",
        "required": [
          "offer",
          "eligibility",
          "history",
          "citation"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string"
          },
          "generatedAt": {
            "type": "string"
          },
          "offer": {
            "$ref": "#/components/schemas/Offer"
          },
          "eligibility": {
            "type": "object",
            "properties": {
              "inFreshCollection": {
                "type": "boolean"
              },
              "presentInLatestFeed": {
                "type": "boolean"
              },
              "sourceStatus": {
                "type": "string"
              },
              "sourceCheckedAt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "checkoutVerified": {
                "type": "boolean",
                "const": false
              },
              "inventoryVerified": {
                "type": "boolean",
                "const": false
              }
            }
          },
          "history": {
            "$ref": "#/components/schemas/History"
          },
          "citation": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string"
              },
              "publisher": {
                "type": "string"
              },
              "publisherUrl": {
                "type": "string"
              },
              "observedAt": {
                "type": "string"
              },
              "instruction": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
