{
  "openapi": "3.1.0",
  "info": {
    "title": "Language Detection API",
    "version": "1.0.0",
    "description": "Detect the language of any text from 180 candidates with confidence scores and ranked alternatives.\n\nDetect the language of any text from about 180 candidates, with ranked alternatives, confidence scores, readable language names and a reliability flag for short inputs. Pure computation on the platform, no third-party calls.",
    "contact": {
      "name": "Data and APIs",
      "url": "https://dataandapis.com/contact"
    },
    "termsOfService": "https://dataandapis.com/terms-of-service",
    "license": {
      "name": "Data and APIs Terms of Service",
      "url": "https://dataandapis.com/terms-of-service"
    },
    "x-logo": {
      "url": "https://dataandapis.com/images/language-detection.webp"
    }
  },
  "externalDocs": {
    "description": "Documentation, live tester and pricing",
    "url": "https://dataandapis.com/apis/language-detection"
  },
  "servers": [
    {
      "url": "https://api-language-detection.dataandapis.com"
    }
  ],
  "tags": [
    {
      "name": "Tools",
      "description": "Language Detection API belongs to the Tools category of the Data and APIs catalog."
    }
  ],
  "paths": {
    "/v1/detect": {
      "get": {
        "operationId": "detectLanguage",
        "summary": "Detect Language",
        "description": "Detect Language endpoint of the Language Detection API. Costs 1 token per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/language-detection/detect-language"
        },
        "parameters": [
          {
            "name": "candidates",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "3"
          },
          {
            "name": "text",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "This is a simple English sentence for testing."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "text_length": 47,
                  "detected": "eng",
                  "name": "English",
                  "reliable": true,
                  "candidates": [
                    {
                      "code": "eng",
                      "name": "English",
                      "score": 1
                    },
                    {
                      "code": "sco",
                      "name": "Scots",
                      "score": 0.8812
                    },
                    {
                      "code": "deu",
                      "name": "German",
                      "score": 0.7544
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      },
      "post": {
        "operationId": "detectLanguagePost",
        "summary": "Detect Language (POST)",
        "description": "Detect Language (POST) endpoint of the Language Detection API. Costs 1 token per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/language-detection/detect-language-post"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              },
              "example": {
                "text": "Ceci est un texte en français pour tester la détection.",
                "candidates": 3
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "text_length": 55,
                  "detected": "fra",
                  "name": "French",
                  "reliable": true,
                  "candidates": [
                    {
                      "code": "fra",
                      "name": "French",
                      "score": 1
                    },
                    {
                      "code": "glg",
                      "name": "Galician",
                      "score": 0.7217
                    },
                    {
                      "code": "cat",
                      "name": "Catalan",
                      "score": 0.6945
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Create a free key at https://dataandapis.com/sign-up. 500 tokens a month on the Free plan; this API costs 1 token per call."
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}