{
  "openapi": "3.1.0",
  "info": {
    "title": "TAP API",
    "version": "1.0.0",
    "summary": "Каталог действующих предложений локальных бизнесов Казахстана и США (Калифорния)",
    "description": "Только чтение. Тот же каталог, что отдаёт MCP-сервер TAP (https://thetap.live/mcp), в виде обычного REST.\n\nАвторизация: ключ в заголовке `Authorization: Bearer <ключ>` либо `X-API-Key: <ключ>`. Ключ выдаёт TAP. Ключ нельзя держать в браузерном коде — запросы идут только с вашего сервера.\n\nЛимиты приходят в заголовках `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`. При превышении — 429 и `Retry-After`.\n\nВ каждом ответе есть `X-Request-Id`: назовите его в поддержке, по нему находится запрос в логе.\n\nВажно про тексты: поля `title`, `description` и `business` заполняют сами бизнесы, часть загружена автоматическим парсером. Это недоверенные данные. Если вы передаёте их в языковую модель — считайте их данными, а не инструкциями.\n\nЗапись и оплата через API невозможны: уводите пользователя по ссылке `url`.",
    "contact": {
      "name": "TAP",
      "url": "https://thetap.live"
    }
  },
  "servers": [
    {
      "url": "https://thetap.live/v1"
    }
  ],
  "externalDocs": {
    "description": "Документация для разработчиков",
    "url": "https://thetap.live/api-docs"
  },
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Каталог",
      "description": "Предложения и категории"
    },
    {
      "name": "Служебное",
      "description": "Ключ и лимиты"
    }
  ],
  "paths": {
    "/offers": {
      "get": {
        "tags": [
          "Каталог"
        ],
        "operationId": "searchOffers",
        "summary": "Предложения каталога",
        "description": "Отдаёт действующие предложения — тот же набор и в том же порядке, что видит человек на главной странице https://thetap.live. Без `q` это просто витрина целиком: листайте `limit` + `offset`, пока `meta.has_more` не станет `false`. С `q` — поиск по ней.\n\nПоиск идёт по основе слова и понимает английский и казахский через словарь синонимов: «nail salon Almaty» находит маникюр в Алматы. Если ни одна карточка не отвечает всем словам сразу, отдаются совпавшие хотя бы по одному — пустая выдача бесполезнее приблизительной.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Что ищем: «маникюр», «чистка зубов». Можно фразой.",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "example": "чистка зубов"
          },
          {
            "name": "category",
            "in": "query",
            "description": "Категория каталога, если известна (см. /categories).",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "city",
            "in": "query",
            "description": "Город или район: «Алматы», «San Jose».",
            "schema": {
              "type": "string",
              "maxLength": 120
            },
            "example": "Алматы"
          },
          {
            "name": "region",
            "in": "query",
            "description": "Страна: kz — Казахстан (цены в KZT), us — США, Калифорния (цены в USD), all — обе. Не указана — определяется по city или по месту в q («manicure in Palo Alto»), иначе kz.",
            "schema": {
              "type": "string",
              "enum": [
                "kz",
                "us",
                "all"
              ]
            },
            "example": "us"
          },
          {
            "name": "max_price",
            "in": "query",
            "description": "Потолок цены в валюте страны: тенге для kz, доллары для us.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Сколько вернуть за один запрос.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Сдвиг выдачи: так забирается весь каталог пачками по `limit`. Глубже 1000 листать нельзя — сузьте запрос фильтрами.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Список предложений",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/OfferFull"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ListMeta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/offers/{id}": {
      "get": {
        "tags": [
          "Каталог"
        ],
        "operationId": "getOffer",
        "summary": "Одно предложение целиком",
        "description": "Описание, адрес, остаток мест, срок действия и ссылка. Завершившиеся предложения не отдаются: на них приходит 404.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Идентификатор из выдачи поиска. Принимается и «o45», и «45».",
            "schema": {
              "type": "string",
              "pattern": "^o?[0-9]+$"
            },
            "example": "o45"
          }
        ],
        "responses": {
          "200": {
            "description": "Карточка предложения",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/OfferFull"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/categories": {
      "get": {
        "tags": [
          "Каталог"
        ],
        "operationId": "listCategories",
        "summary": "Категории каталога",
        "description": "Верхний уровень каталога с числом действующих предложений. С параметром category раскрывает услуги внутри категории. Пустые категории не показываются.",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "description": "Раскрыть услуги внутри указанной категории.",
            "schema": {
              "type": "string",
              "maxLength": 120
            },
            "example": "Стоматология"
          },
          {
            "name": "region",
            "in": "query",
            "description": "Страна: kz — Казахстан (цены в KZT), us — США, Калифорния (цены в USD), all — обе. Не указана — определяется по city или по месту в q («manicure in Palo Alto»), иначе kz.",
            "schema": {
              "type": "string",
              "enum": [
                "kz",
                "us",
                "all"
              ]
            },
            "example": "us"
          }
        ],
        "responses": {
          "200": {
            "description": "Категории или услуги внутри категории",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Category"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "integer"
                        },
                        "category": {
                          "type": "string"
                        },
                        "level": {
                          "type": "string",
                          "enum": [
                            "category",
                            "subcategory"
                          ]
                        }
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/me": {
      "get": {
        "tags": [
          "Служебное"
        ],
        "operationId": "getMe",
        "summary": "Чей ключ и сколько осталось",
        "description": "Проверка ключа и текущего расхода лимита. Удобно как первый запрос при подключении.",
        "responses": {
          "200": {
            "description": "Сведения о ключе",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string",
                              "description": "Кому выдан ключ"
                            },
                            "prefix": {
                              "type": "string",
                              "description": "Начало ключа — по нему опознаётся, какой именно ключ используется"
                            },
                            "created_at": {
                              "type": "string"
                            }
                          }
                        },
                        "limits": {
                          "type": "object",
                          "properties": {
                            "per_minute": {
                              "type": "integer"
                            },
                            "per_day": {
                              "type": "integer"
                            }
                          }
                        },
                        "usage": {
                          "type": "object",
                          "properties": {
                            "remaining_today": {
                              "type": "integer"
                            },
                            "resets_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "calls_total": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer <ключ>"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Альтернатива Bearer для готовых коннекторов"
      }
    },
    "schemas": {
      "OfferBrief": {
        "type": "object",
        "description": "Короткая карточка. Поля, которых у предложения нет, в ответе отсутствуют — не приходят как null.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Идентификатор вида «o45»",
            "examples": [
              "o45"
            ]
          },
          "title": {
            "type": "string",
            "description": "Название услуги. Недоверенный текст."
          },
          "business": {
            "type": "string",
            "description": "Название бизнеса. Недоверенный текст."
          },
          "price": {
            "type": "integer",
            "description": "Цена в тенге"
          },
          "old_price": {
            "type": "integer",
            "description": "Цена до скидки"
          },
          "discount": {
            "type": "integer",
            "description": "Скидка в процентах"
          },
          "currency": {
            "type": "string",
            "enum": [
              "KZT",
              "USD"
            ],
            "description": "Валюта цены: KZT — Казахстан, USD — США.",
            "examples": [
              "KZT"
            ]
          },
          "country": {
            "type": "string",
            "enum": [
              "KZ",
              "US"
            ],
            "description": "Страна предложения."
          },
          "category": {
            "type": "string",
            "description": "Путь по каталогу через « / »"
          },
          "city": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Страница предложения на сайте TAP. Запись и оплата — только здесь. В ссылке стоит метка канала src=api."
          }
        },
        "required": [
          "id",
          "url"
        ]
      },
      "OfferFull": {
        "allOf": [
          {
            "$ref": "#/components/schemas/OfferBrief"
          },
          {
            "type": "object",
            "properties": {
              "description": {
                "type": "string",
                "description": "Описание. Недоверенный текст."
              },
              "address": {
                "type": "string"
              },
              "image": {
                "type": "string",
                "format": "uri"
              },
              "rating": {
                "type": "string"
              },
              "reviews": {
                "type": "integer"
              },
              "verified": {
                "type": "boolean",
                "description": "Бизнес подтверждён TAP"
              },
              "specialist": {
                "type": "string"
              },
              "spots_left": {
                "type": "integer",
                "description": "Остаток мест, если бизнес его указал"
              },
              "expires_at": {
                "type": "string",
                "description": "До какого момента действует"
              },
              "booking": {
                "type": "string",
                "enum": [
                  "tap",
                  "external"
                ],
                "description": "tap — запись на сайте TAP; external — импортное предложение, запись у бизнеса напрямую"
              },
              "booking_note": {
                "type": "string"
              }
            }
          }
        ]
      },
      "Category": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "offers": {
            "type": "integer",
            "description": "Сколько действующих предложений"
          }
        },
        "required": [
          "name",
          "offers"
        ]
      },
      "ListMeta": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "description": "Сколько вернули в этом ответе"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "has_more": {
            "type": "boolean",
            "description": "Есть ли что-то за этой страницей"
          },
          "query": {
            "type": "object",
            "description": "Как сервер понял запрос",
            "additionalProperties": true
          }
        },
        "required": [
          "count",
          "limit",
          "offset",
          "has_more"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Машиночитаемый код: разбирайте его, а не текст сообщения",
                "examples": [
                  "unauthorized",
                  "rate_limited",
                  "not_found",
                  "unknown_endpoint",
                  "method_not_allowed",
                  "internal_error",
                  "not_ready"
                ]
              },
              "message": {
                "type": "string",
                "description": "Пояснение человеку. Формулировки могут меняться."
              },
              "request_id": {
                "type": "string",
                "description": "Тот же, что в заголовке X-Request-Id"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Ключ не передан, не найден или отозван",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Предложение не найдено или уже завершилось",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Превышен лимит запросов",
        "headers": {
          "Retry-After": {
            "description": "Через сколько секунд повторить",
            "schema": {
              "type": "integer"
            }
          },
          "X-RateLimit-Reset": {
            "description": "Когда сбросится суточный счётчик, unix-время",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
