Yandex Translate API Language Detection API

Operations for detecting the language of text

OpenAPI Specification

yandex-translate-language-detection-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Yandex Translate Language Detection API
  description: Yandex Translate is a machine translation REST API from Yandex Cloud that supports 100+ languages. It provides text translation between any supported language pair, automatic source language detection, and listing of all supported languages. The API uses neural machine translation technology and supports glossaries for domain-specific vocabulary.
  version: v2
  contact:
    url: https://yandex.cloud/en/docs/translate/
  license:
    name: Yandex Cloud Terms of Service
    url: https://yandex.cloud/en/legal/cloud_termsofuse/
servers:
- url: https://translate.api.cloud.yandex.net
  description: Yandex Cloud Translate API endpoint
security:
- BearerAuth: []
- ApiKeyAuth: []
tags:
- name: Language Detection
  description: Operations for detecting the language of text
paths:
  /translate/v2/detect:
    post:
      operationId: detectLanguage
      summary: Detect language
      description: Detects the language of the provided text. You can provide language hints to improve detection accuracy.
      tags:
      - Language Detection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DetectLanguageRequest'
            example:
              text: Bonjour le monde
              languageCodeHints:
              - fr
              - en
              folderId: b1gd3hm2nj34ibndf3sd
      responses:
        '200':
          description: Successful language detection response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetectLanguageResponse'
              example:
                languageCode: fr
        '400':
          description: Bad request - invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    DetectLanguageResponse:
      type: object
      description: Response containing the detected language code
      properties:
        languageCode:
          type: string
          description: Detected language code. Most languages use ISO 639-1 format (e.g., 'fr'). Use ListLanguages to get the language name from the code.
          example: fr
    ErrorResponse:
      type: object
      description: Error response from the API
      properties:
        code:
          type: integer
          description: HTTP status code.
        message:
          type: string
          description: Human-readable error message.
        details:
          type: array
          description: Additional error details.
          items:
            type: object
    DetectLanguageRequest:
      type: object
      description: Request body for detecting the language of text
      required:
      - text
      properties:
        text:
          type: string
          maxLength: 1000
          description: The text to detect the language for.
          example: Bonjour le monde
        languageCodeHints:
          type: array
          description: List of the most likely languages. These languages will be given preference when detecting the text language. Uses ISO 639-1 format.
          maxItems: 10
          items:
            type: string
            maxLength: 3
          example:
          - fr
          - en
        folderId:
          type: string
          maxLength: 50
          description: ID of the folder to which you have access. Required for user account authorization. Do not specify when using a service account.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'IAM token obtained from Yandex Identity and Access Management (IAM). Pass as ''Authorization: Bearer <IAM_TOKEN>''.'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key for service accounts. Pass as ''Authorization: Api-Key <API_KEY>''.'
externalDocs:
  description: Yandex Translate API Reference
  url: https://yandex.cloud/en/docs/translate/api-ref/