# List the audio formats this server can write

> With whether each one takes a bit rate: FLAC and WAV are lossless and refuse one.

Source: https://tools.vukem.dev/docs/api/tools.audio-convert.formats/

## Authentication

No key is needed. This route is public.

## Responses

### 200 OK

Content type `application/json`. Schema: [`AudioCapabilities`](/docs/api/schemas#audiocapabilities).

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `formats` | array of [`AudioFormat`](/docs/api/schemas#audioformat) | - | Every output format, with whether this server can write it |
| `loudness_target` | `number (double)` | - | The integrated loudness normalisation aims at, in LUFS |
| `max_seconds` | `number (double)` | - | The longest recording this server converts, in seconds |
| `readable` | array of `string` | - | The media types this server accepts, including video, since extracting a soundtrack is the same conversion |
| `sample_rates` | array of `integer` | - | The sample rates a conversion may ask for. 0 keeps the source's |
| `writable` | array of `string` | - | The formats this server can write, by name |

### Any other status

Content type `application/problem+json`. Error (RFC 9457 problem details). Schema: [`Problem`](/docs/api/schemas#problem).

The error follows RFC 9457. See [Errors](/docs/api/overview#errors).

```bash
curl -X GET "http://localhost:3000/api/v1/tools/audio-convert/formats"
```

```python
import requests

response = requests.get(
    "http://localhost:3000/api/v1/tools/audio-convert/formats",
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

```javascript
const response = await fetch("http://localhost:3000/api/v1/tools/audio-convert/formats", {
  method: "GET",
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
console.log(await response.json());
```

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "http://localhost:3000/api/v1/tools/audio-convert/formats"
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		panic(err)
	}

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, err := io.ReadAll(res.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Status, string(out))
}
```

```php
<?php

$ch = curl_init("http://localhost:3000/api/v1/tools/audio-convert/formats");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new RuntimeException(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $response, PHP_EOL;
```

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("http://localhost:3000/api/v1/tools/audio-convert/formats"))
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
```

```csharp
using System;
using System.Net.Http;

using var client = new HttpClient();
using var request = new HttpRequestMessage(
    HttpMethod.Get, "http://localhost:3000/api/v1/tools/audio-convert/formats");

using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

```ruby
require "net/http"
require "uri"

uri = URI("http://localhost:3000/api/v1/tools/audio-convert/formats")
request = Net::HTTP::Get.new(uri)

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
puts "#{response.code} #{response.body}"
```

**Response examples**

```json
{
  "formats": [
    {
      "extension": ".mp3",
      "label": "MP3",
      "lossy": true,
      "mime": "audio/mpeg",
      "name": "mp3",
      "write": true
    },
    {
      "extension": ".flac",
      "label": "FLAC",
      "lossy": false,
      "mime": "audio/flac",
      "name": "flac",
      "write": true
    }
  ],
  "loudness_target": -16,
  "max_seconds": 14400,
  "readable": [
    "audio/aac",
    "audio/flac",
    "audio/mpeg",
    "audio/ogg",
    "audio/wav",
    "video/mp4",
    "video/quicktime",
    "video/webm",
    "video/x-matroska",
    "video/x-msvideo"
  ],
  "sample_rates": [
    44100,
    48000
  ],
  "writable": [
    "mp3",
    "wav",
    "flac",
    "opus",
    "aac"
  ]
}
```

The examples are built from the schemas, so every value is a placeholder of its type. The tables above hold the fields that carry the real values.
