{
  "openapi": "3.0.3",
  "info": {
    "title": "Language Detection",
    "version": "1.0.0",
    "description": "Detect the language of any text across 187 languages using the franc library. No external API dependency. Returns ISO 639-3 language codes with a confidence score, plus a batch endpoint for up to 20 texts and a list of supported languages.\n",
    "contact": {
      "name": "Language Detection API Support",
      "email": "api@hiroapp.cc"
    }
  },
  "servers": [
    {
      "url": "https://api.sprytools.com/v1/language",
      "description": "Production (SpryTools API Gateway)"
    }
  ],
  "tags": [
    {
      "name": "Detection"
    },
    {
      "name": "Reference"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "RapidApiProxy": []
    }
  ],
  "paths": {
    "/api/v1/detect": {
      "post": {
        "operationId": "detectLanguage",
        "summary": "Detect the language of a single text",
        "tags": [
          "Detection"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "Text to analyse (max 50 KB)"
                  }
                }
              },
              "example": {
                "text": "Bonjour tout le monde, comment allez-vous ?"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Detection result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetectResult"
                },
                "example": {
                  "language": "fra",
                  "name": "French",
                  "iso6391": "fr",
                  "confidence": 0.98
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/detect/batch": {
      "post": {
        "operationId": "detectLanguageBatch",
        "summary": "Detect languages for multiple texts (max 20)",
        "tags": [
          "Detection"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "texts"
                ],
                "properties": {
                  "texts": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 20,
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "texts": [
                  "Hello world",
                  "Hola mundo",
                  "Hallo Welt"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch detection results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DetectResult"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/languages": {
      "get": {
        "operationId": "listLanguages",
        "summary": "List supported languages",
        "tags": [
          "Reference"
        ],
        "responses": {
          "200": {
            "description": "Supported languages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "languages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "RapidApiProxy": {
        "type": "apiKey",
        "in": "header",
        "name": "x-rapidapi-proxy-secret"
      }
    },
    "schemas": {
      "DetectResult": {
        "type": "object",
        "properties": {
          "language": {
            "type": "string",
            "description": "ISO 639-3 code"
          },
          "name": {
            "type": "string"
          },
          "iso6391": {
            "type": "string",
            "nullable": true,
            "description": "ISO 639-1 code"
          },
          "confidence": {
            "type": "number"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Missing or invalid input",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "'text' must be a non-empty string"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key missing",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "API key required"
            }
          }
        }
      },
      "TooLarge": {
        "description": "Input exceeds size limit",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Text exceeds 50KB limit"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded (100 requests per minute)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded"
            }
          }
        }
      }
    }
  }
}