> ## Documentation Index
> Fetch the complete documentation index at: https://docs.submagic.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Languages

> Retrieve a list of all supported languages for video transcription

# Get Languages

Retrieve a comprehensive list of all supported languages for video transcription and caption generation. This endpoint returns language codes and names that can be used when creating projects.

<Note>
  This endpoint requires authentication and has a rate limit of 100 requests per
  minute.
</Note>

## Authentication

<ParamField header="x-api-key" type="string" required>
  Your Submagic API key starting with `sk-`
</ParamField>

## Response

<ResponseField name="languages" type="array">
  Array of supported language objects

  <Expandable title="Language Object" defaultOpen>
    <ResponseField name="name" type="string">
      Human-readable name of the language (e.g., "English", "Spanish")
    </ResponseField>

    <ResponseField name="code" type="string">
      ISO language code used for API requests (e.g., "en", "es", "fr")
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.submagic.co/v1/languages" \
    -H "x-api-key: sk-your-api-key-here"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.submagic.co/v1/languages", {
    headers: {
      "x-api-key": "sk-your-api-key-here",
    },
  });

  const data = await response.json();
  console.log(data.languages);
  ```

  ```python Python theme={null}
  import requests

  headers = {
      'x-api-key': 'sk-your-api-key-here'
  }

  response = requests.get('https://api.submagic.co/v1/languages', headers=headers)
  data = response.json()

  for language in data['languages']:
      print(f"{language['name']}: {language['code']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "languages": [
      {
        "name": "English",
        "code": "en"
      },
      {
        "name": "Spanish",
        "code": "es"
      },
      {
        "name": "French",
        "code": "fr"
      },
      {
        "name": "German",
        "code": "de"
      },
      {
        "name": "Italian",
        "code": "it"
      },
      {
        "name": "Portuguese",
        "code": "pt"
      },
      {
        "name": "Dutch",
        "code": "nl"
      },
      {
        "name": "Russian",
        "code": "ru"
      },
      {
        "name": "Chinese (Simplified)",
        "code": "zh"
      },
      {
        "name": "Japanese",
        "code": "ja"
      },
      {
        "name": "Korean",
        "code": "ko"
      },
      {
        "name": "Arabic",
        "code": "ar"
      },
      {
        "name": "Hindi",
        "code": "hi"
      }
    ]
  }
  ```
</ResponseExample>

## Popular Languages

Here are some of the most commonly used language codes:

<CardGroup cols={3}>
  <Card title="English" icon="globe">
    **Code:** `en` Most widely supported with highest accuracy
  </Card>

  <Card title="Spanish" icon="globe">
    **Code:** `es` Excellent support for Latin American and European Spanish
  </Card>

  <Card title="French" icon="globe">
    **Code:** `fr` High accuracy for both European and Canadian French
  </Card>

  <Card title="German" icon="globe">
    **Code:** `de` Great support for German language nuances
  </Card>

  <Card title="Italian" icon="globe">
    **Code:** `it` Optimized for Italian pronunciation patterns
  </Card>

  <Card title="Portuguese" icon="globe">
    **Code:** `pt` Supports both Brazilian and European Portuguese
  </Card>
</CardGroup>

## Using Language Codes

Once you have the language codes, you can use them when creating projects:

```json theme={null}
{
  "title": "My Spanish Video",
  "language": "es",
  "videoUrl": "https://example.com/spanish-video.mp4"
}
```

## Best Practices

### Caching Language Data

Since the list of supported languages doesn't change frequently, consider caching the response:

```javascript theme={null}
class LanguageCache {
  constructor() {
    this.cache = null;
    this.lastFetch = null;
    this.cacheDuration = 24 * 60 * 60 * 1000; // 24 hours
  }

  async getLanguages() {
    const now = Date.now();

    if (
      this.cache &&
      this.lastFetch &&
      now - this.lastFetch < this.cacheDuration
    ) {
      return this.cache;
    }

    const response = await fetch("https://api.submagic.co/v1/languages", {
      headers: { "x-api-key": process.env.SUBMAGIC_API_KEY },
    });

    this.cache = await response.json();
    this.lastFetch = now;

    return this.cache;
  }
}
```

### Building Language Selectors

Create user-friendly language selection interfaces:

```javascript theme={null}
const buildLanguageSelector = (languages) => {
  return languages
    .sort((a, b) => a.name.localeCompare(b.name))
    .map((lang) => ({
      value: lang.code,
      label: lang.name,
      flag: getFlagEmoji(lang.code), // Helper function for flag emojis
    }));
};
```

## Error Responses

<ResponseField name="401 Unauthorized" type="object">
  ```json theme={null}
  {
    "error": "UNAUTHORIZED",
    "message": "Invalid or missing API key"
  }
  ```
</ResponseField>

<ResponseField name="429 Rate Limited" type="object">
  ```json theme={null}
  {
    "error": "RATE_LIMIT_EXCEEDED",
    "message": "Too many requests",
    "retryAfter": 30
  }
  ```
</ResponseField>

<ResponseField name="500 Server Error" type="object">
  ```json theme={null}
  {
    "error": "INTERNAL_SERVER_ERROR",
    "message": "An unexpected error occurred"
  }
  ```
</ResponseField>

<Tip>
  The language list is updated periodically as we add support for new languages.
  We recommend fetching this list dynamically rather than hard-coding language
  options in your application.
</Tip>

{" "}
