{
  "openapi": "3.1.0",
  "info": {
    "title": "Sentor AI Sentiment Analysis API",
    "description": "Entity-based sentiment analysis API for customer feedback analytics. Analyze sentiment on specific entities with high accuracy using advanced BERT and RoBERTa models.",
    "version": "1.0.0",
    "contact": {
      "name": "NIKX Technologies B.V.",
      "email": "sentor@nikx.one",
      "url": "https://sentor.app"
    }
  },
  "servers": [
    {
      "url": "https://sentor.app/api",
      "description": "Production API Server"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/predicts": {
      "post": {
        "summary": "Analyze sentiment for one or more documents with entity focus",
        "operationId": "analyzeSentiment",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "description": "Language code (en, nl). Default: en",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "nl"
              ],
              "default": "en"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "docs"
                ],
                "properties": {
                  "docs": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "doc",
                        "doc_id",
                        "entities"
                      ],
                      "properties": {
                        "doc": {
                          "type": "string",
                          "description": "Text to analyze"
                        },
                        "doc_id": {
                          "type": "string",
                          "description": "Unique document identifier"
                        },
                        "entities": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "List of entities to analyze sentiment for"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful sentiment analysis",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "doc_id": {
                            "type": "string"
                          },
                          "predicted_class": {
                            "type": "integer"
                          },
                          "predicted_label": {
                            "type": "string"
                          },
                          "probabilities": {
                            "type": "object",
                            "properties": {
                              "negative": {
                                "type": "number"
                              },
                              "neutral": {
                                "type": "number"
                              },
                              "positive": {
                                "type": "number"
                              }
                            }
                          },
                          "entity_sentiments": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "entity": {
                                  "type": "string"
                                },
                                "sentiment": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/predicts/health": {
      "get": {
        "summary": "Health check endpoint",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    },
                    "uptime": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/predicts/cluster": {
      "post": {
        "summary": "Cluster documents using BERTopic",
        "operationId": "clusterDocuments",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "description": "Language code (en, nl). Default: en",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "nl"
              ],
              "default": "en"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "documents"
                ],
                "properties": {
                  "documents": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "doc_id",
                        "text",
                        "entities"
                      ],
                      "properties": {
                        "doc_id": {
                          "type": "string"
                        },
                        "text": {
                          "type": "string"
                        },
                        "entities": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful clustering",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/predicts/topic-name": {
      "post": {
        "summary": "Generate a descriptive topic name for a cluster",
        "operationId": "nameTopic",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "description": "Language code (en, nl). Default: en",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "nl"
              ],
              "default": "en"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "cluster_id",
                  "documents"
                ],
                "properties": {
                  "cluster_id": {
                    "type": "integer"
                  },
                  "documents": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "entities": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "top_words": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful topic naming",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "topic_name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}