{
  "openapi": "3.1.0",
  "info": {
    "title": "AmezPrice Reddit Integration API",
    "version": "2026-10-21",
    "description": "Public documentation for an authenticated operator-managed integration. Documented access does not imply Reddit approval. Current fetch scope is exactly two HTTPS POST endpoints. Maximum signed body is 16 KiB. Sign timestamp + a period + the exact JSON bytes with HMAC-SHA256 using the configured secret string as UTF-8, without hex-decoding. Timestamp window: five minutes. Registration nonce replay window: ten minutes. Route throttle: 600 requests/minute.",
    "contact": {
      "email": "support@amezprice.com"
    },
    "termsOfService": "https://amezprice.com/developers/reddit-terms.html"
  },
  "servers": [
    {
      "url": "https://amezprice.com/api/social-media/reddit"
    }
  ],
  "externalDocs": {
    "description": "Human-readable API, privacy and commercial-use documentation",
    "url": "https://amezprice.com/developers/reddit-api.html"
  },
  "paths": {
    "/catalogue": {
      "post": {
        "operationId": "readCatalogue",
        "summary": "Read current category/subcategory names; never registers or enables a destination",
        "security": [
          {
            "AmezTimestamp": [],
            "AmezSignature": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "app",
                  "country"
                ],
                "properties": {
                  "app": {
                    "type": "string",
                    "const": "amezprice"
                  },
                  "country": {
                    "type": "string",
                    "enum": [
                      "IN",
                      "UK",
                      "US"
                    ],
                    "description": "Marketplaces currently exposed by the Devvit app."
                  }
                }
              },
              "example": {
                "app": "amezprice",
                "country": "IN"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. Replayed registration nonces return only status and replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "catalogue"
                  ],
                  "properties": {
                    "catalogue": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "description": "Category names map to distinct subcategory names. An empty catalogue is {}."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, invalid or stale HMAC authentication; no registration is performed."
          },
          "422": {
            "description": "Payload validation failed."
          },
          "429": {
            "description": "Route throttle exceeded."
          },
          "500": {
            "description": "Unexpected backend error. Do not assume a registration or verification succeeded."
          }
        }
      }
    },
    "/installations": {
      "post": {
        "operationId": "registerInstallation",
        "summary": "Register moderator preferences and heartbeat; does not publish a deal",
        "security": [
          {
            "AmezTimestamp": [],
            "AmezSignature": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "app",
                  "country",
                  "subreddit",
                  "subreddit_id",
                  "nonce",
                  "enabled",
                  "discount_mode",
                  "categories"
                ],
                "properties": {
                  "app": {
                    "type": "string",
                    "const": "amezprice"
                  },
                  "country": {
                    "type": "string",
                    "enum": [
                      "IN",
                      "UK",
                      "US"
                    ],
                    "description": "Marketplaces currently exposed by the Devvit app."
                  },
                  "subreddit": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_]{3,21}$"
                  },
                  "subreddit_id": {
                    "type": "string",
                    "pattern": "^t5_[a-z0-9]+$"
                  },
                  "nonce": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "discount_mode": {
                    "type": "string",
                    "enum": [
                      "min",
                      "max",
                      "both",
                      "all"
                    ]
                  },
                  "minimum_discount": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 5,
                    "maximum": 100,
                    "multipleOf": 0.01
                  },
                  "maximum_discount": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 5,
                    "maximum": 100,
                    "multipleOf": 0.01
                  },
                  "categories": {
                    "type": "object",
                    "maxProperties": 100,
                    "additionalProperties": {
                      "type": "array",
                      "minItems": 1,
                      "maxItems": 100,
                      "items": {
                        "type": "string",
                        "maxLength": 200
                      }
                    },
                    "description": "{} means all. A * parent selects subcategories across parents; a * value selects all subcategories for that parent."
                  },
                  "discount_rules": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 2,
                    "items": {
                      "$ref": "#/components/schemas/DiscountRule"
                    }
                  }
                }
              },
              "example": {
                "app": "amezprice",
                "subreddit": "ExampleDeals",
                "subreddit_id": "t5_demo123",
                "nonce": "00000000-0000-4000-8000-000000000001",
                "enabled": false,
                "country": "IN",
                "discount_mode": "all",
                "minimum_discount": null,
                "maximum_discount": null,
                "categories": {
                  "*": [
                    "Smartphones",
                    "Fiction"
                  ]
                },
                "discount_rules": [
                  {
                    "enabled": false,
                    "discount_mode": "both",
                    "minimum_discount": 5,
                    "maximum_discount": 15,
                    "flair": "deal_radar",
                    "flair_text": "Deal Radar"
                  },
                  {
                    "enabled": false,
                    "discount_mode": "min",
                    "minimum_discount": 15.01,
                    "maximum_discount": null,
                    "flair": "amezdeals",
                    "flair_text": "AmezDeals"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. Replayed registration nonces return only status and replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "verified": {
                      "type": "boolean"
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "catalogue": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "description": "Category names map to distinct subcategory names. An empty catalogue is {}."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, malformed, invalid or stale HMAC authentication; no registration is performed."
          },
          "422": {
            "description": "Payload validation failed."
          },
          "429": {
            "description": "Route throttle exceeded."
          },
          "500": {
            "description": "Unexpected backend error. Do not assume a registration or verification succeeded."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "AmezTimestamp": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Amez-Timestamp",
        "description": "Ten-digit Unix timestamp in seconds; accepted within five minutes of server time."
      },
      "AmezSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Amez-Signature",
        "description": "Lowercase hex HMAC-SHA256(timestamp + \".\" + exact_request_body), using the operator-managed server secret. The secret itself is never sent."
      }
    },
    "schemas": {
      "DiscountRule": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "discount_mode",
          "flair",
          "flair_text"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "discount_mode": {
            "type": "string",
            "enum": [
              "min",
              "max",
              "both",
              "all"
            ]
          },
          "minimum_discount": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 5,
            "maximum": 100,
            "multipleOf": 0.01
          },
          "maximum_discount": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 5,
            "maximum": 100,
            "multipleOf": 0.01
          },
          "flair": {
            "type": "string",
            "pattern": "^(amezdeals|deal_radar|[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$"
          },
          "flair_text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        },
        "description": "Minimum is used by min/both; maximum by max/both. Both bounds are inclusive and min cannot exceed max. Unused bounds are null."
      }
    }
  },
  "x-privacy-policy": "https://amezprice.com/developers/reddit-privacy.html"
}
