{
    "openapi": "3.1.0",
    "info": {
        "title": "agentfirewall.ru API",
        "version": "1.0.0",
        "description": "Справочник ИИ-ботов, проверка сайта и генератор правил доступа. Данные CC BY 4.0.",
        "contact": {
            "email": "info@a2aprotocol.ru"
        },
        "license": {
            "name": "CC BY 4.0",
            "url": "https://creativecommons.org/licenses/by/4.0/"
        }
    },
    "servers": [
        {
            "url": "https://agentfirewall.ru"
        }
    ],
    "paths": {
        "/api/v1/bots": {
            "get": {
                "operationId": "listBots",
                "summary": "Список ботов справочника",
                "parameters": [
                    {
                        "name": "purpose",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "train",
                                "search",
                                "agent",
                                "other"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BotList"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/bots/{slug}": {
            "get": {
                "operationId": "getBot",
                "summary": "Карточка бота",
                "parameters": [
                    {
                        "name": "slug",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Bot"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Нет такого бота"
                    }
                }
            }
        },
        "/api/v1/rules": {
            "get": {
                "operationId": "buildRules",
                "summary": "Собрать robots.txt по сценарию",
                "parameters": [
                    {
                        "name": "preset",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "open_all",
                                "search_agents",
                                "block_train"
                            ]
                        }
                    },
                    {
                        "name": "on",
                        "in": "query",
                        "description": "Список групп через запятую: search,agent,train,other,neuro,unknown",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "server",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "enum": [
                                0,
                                1
                            ]
                        }
                    },
                    {
                        "name": "sitemap",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "uri"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Rules"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/check": {
            "get": {
                "operationId": "checkSite",
                "summary": "Проверить robots.txt и llms.txt сайта",
                "parameters": [
                    {
                        "name": "u",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Домен или адрес сайта"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Результат проверки",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/CheckResult"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Неверный адрес"
                    },
                    "429": {
                        "description": "Лимит проверок"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Bot": {
                "type": "object",
                "properties": {
                    "slug": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "owner": {
                        "type": "string"
                    },
                    "purpose": {
                        "type": "string",
                        "enum": [
                            "train",
                            "search",
                            "agent",
                            "other"
                        ]
                    },
                    "user_agents": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "robots_token": {
                        "type": "string"
                    },
                    "respects_robots": {
                        "type": "string",
                        "enum": [
                            "yes",
                            "partial",
                            "no",
                            "unknown"
                        ]
                    },
                    "verify_method": {
                        "type": "string",
                        "enum": [
                            "ip_list",
                            "reverse_dns",
                            "asn",
                            "ua_only",
                            "none"
                        ]
                    },
                    "ip_ranges_url": {
                        "type": "string"
                    },
                    "docs_url": {
                        "type": "string"
                    },
                    "risk": {
                        "type": "string",
                        "enum": [
                            "low",
                            "mid",
                            "high"
                        ]
                    },
                    "control_only": {
                        "type": "boolean"
                    },
                    "checked_at": {
                        "type": "string",
                        "format": "date"
                    },
                    "takes": {
                        "type": "string"
                    },
                    "notes": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    }
                }
            },
            "BotList": {
                "type": "object",
                "properties": {
                    "updated_at": {
                        "type": "string",
                        "format": "date"
                    },
                    "count": {
                        "type": "integer"
                    },
                    "bots": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Bot"
                        }
                    }
                }
            },
            "Rules": {
                "type": "object",
                "properties": {
                    "on": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "robots": {
                        "type": "string"
                    },
                    "llms": {
                        "type": "string"
                    },
                    "nginx": {
                        "type": "string"
                    },
                    "htaccess": {
                        "type": "string"
                    }
                }
            },
            "CheckResult": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean"
                    },
                    "site": {
                        "type": "string"
                    },
                    "robots": {
                        "type": "object"
                    },
                    "llms": {
                        "type": "object"
                    },
                    "bots": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "slug": {
                                    "type": "string"
                                },
                                "status": {
                                    "type": "string",
                                    "enum": [
                                        "allow",
                                        "block",
                                        "default_allow",
                                        "default_block",
                                        "open"
                                    ]
                                },
                                "rule": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "remarks": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "level": {
                                    "type": "string"
                                },
                                "text": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}