{ "openapi": "3.0.1", "info": { "title": "Wikibot REST API", "description": "Wikibot REST API to manage knowledege bases and interacting with the bot", "license": { "name": "MIT" }, "version": "1.0.0" }, "servers": [ { "url": "https://api.wikibot.pro/api/bot" } ], "paths": { "/set-webhook-url": { "post": { "requestBody": { "description": "Задать webhook URL для бота", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Webhook" } } }, "required": true }, "responses": { "200": { "description": "Create webhook url response" }, "400": { "description": "Unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/ask": { "get": { "description": "Запрос возвращает синхронный ответ, либо вызывает webhook URL в зависимости от способа взаимодействия.", "parameters": [ { "name": "chatId", "in": "query", "description": "Внешний идентификатор чата с клиентом", "schema": { "type": "string" }, "required": true }, { "name": "query", "in": "query", "description": "Запрос", "schema": { "type": "string" }, "required": true }, { "name": "format", "in": "query", "description": "Форматирование ответа: links - добавить ссылки вида (name)[link], raw - неформатированный ответ", "schema": { "type": "string", "enum": [ "links", "raw" ] } }, { "name": "msgId", "in": "query", "description": "Идентификатор сообщения", "schema": { "type": "string" } } ], "responses": { "200": { "description": "Ask query response", "content": { "application/json": { "schema": { "type": "object", "$ref": "#/components/schemas/Answer" } } } }, "400": { "description": "Unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/search": { "get": { "description": "Запрос возвращает список наиболее релевантных документов", "parameters": [ { "name": "q", "in": "query", "description": "Поисковый запрос", "schema": { "type": "string" }, "required": true }, { "name": "skip", "in": "query", "description": "Взять первые N записей", "schema": { "type": "string" } }, { "name": "take", "in": "query", "description": "Пропустить первые N записей", "schema": { "type": "string" } } ], "responses": { "200": { "description": "Search response", "content": { "application/json": { "schema": { "type": "object", "$ref": "#/components/schemas/SearchAnswer" } } } }, "400": { "description": "Unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/kb": { "get": { "description": "Запросить информацию по базе знаний", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "type": "object", "$ref": "#/components/schemas/KbUrl" } } } }, "400": { "description": "error" } } } }, "/kb-create": { "post": { "requestBody": { "description": "Создать базу знаний", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/KbUrl" } } }, "required": true }, "description": "Создать базу знаний1", "responses": { "200": { "description": "success" }, "400": { "description": "fail" } } } } }, "components": { "schemas": { "Webhook": { "required": [ "url" ], "type": "object", "properties": { "url": { "description": "Адрес вебхука", "type": "string" } } }, "KbUrl": { "required": [ "url" ], "type": "object", "properties": { "url": { "description": "Адрес источника данных", "type": "string" } } }, "Answer": { "required": [ "answer", "botId", "chatId", "type" ], "type": "object", "properties": { "answer": { "description": "Ответ на вопрос", "type": "string" }, "botId": { "description": "Идентификатор бота", "type": "string" }, "chatId": { "description": "Идентификатор бота", "type": "string" }, "msgId": { "description": "Идентификатор сообщения, переданный в запросе", "type": "string" }, "type": { "description": "Тип ответа: SUCCESS - успешный ответ, FALLBACK - альтернативная генерация ответа, NO_ANSWER - нет ответа, ERROR - внутренняя ошибка сервера, например таймаут, GREETING - содержит только приветствие, OPERATOR - вызов оператора, SKIP - пропуск сообщения, GRATITUDE - содержит только благодарность", "type": "string", "enum": [ "SUCCESS", "FALLBACK", "NO_ANSWER", "ERROR", "GREETING", "OPERATOR", "SKIP", "GRATITUDE" ] } } }, "SearchAnswer": { "required": [ "answer", "botId", "chatId", "type" ], "type": "object", "properties": { "articles": { "type": "array", "items": { "type": "object", "properties": { "link": { "description": "Ссылка на документ", "type": "string" }, "title": { "description": "Заголовок", "type": "string" }, "content": { "description": "Контент", "type": "string" }, "indexedAt": { "description": "Дата индексации", "type": "string" } } } } } }, "Error": { "required": [ "error", "message" ], "type": "object", "properties": { "error": { "type": "integer", "format": "int32" }, "message": { "type": "string" } } } }, "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } } } }