Upload Audio
You can upload an audio file and get an audio URL. You can then use this audio URL for other tasks, such as the Suno AI Extend task.
POST
https://api.apiframe.pro/upload-audio
Headers
Name
Value
Content-Type
multipart/form-data
Authorization*
Your APIFRAME API Key
Body
Name
Type
Description
audio
*
binary
The audio file you want to upload. Maximum 2MB and 60 seconds!
Response
// Success, the task is complete
{
"audioURL": "https://cdn.apiframe.pro/songs/xxxxxxxxxxxxxxxxxxx.mp4"
}
// Bad request
{
"errors": [{ msg: "Invalid request" }]
}
// Invalid API Key
{}
// A server error occured
{}
Code samples
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('audio', fs.createReadStream('..../audio.mp4'));
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.apiframe.pro/upload-audio',
headers: {
'Authorization': 'YOUR_API_KEY',
...data.getHeaders()
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import requests
url = "https://api.apiframe.pro/upload-audio"
payload = {}
files=[
('image',('audio.mp4',open('..../audio.mp4','rb'),'audio/mp4'))
]
headers = {
'Authorization': 'YOUR_API_KEY'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.apiframe.pro/upload-audio',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('audio'=> new CURLFILE('..../audio.mp4')),
CURLOPT_HTTPHEADER => array(
'Authorization: YOUR_API_KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("audio","",
RequestBody.create(MediaType.parse("application/octet-stream"),
new File("..../audio.mp4")))
.build();
Request request = new Request.Builder()
.url("https://api.apiframe.pro/upload-audio")
.method("POST", body)
.addHeader("Authorization", "YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Authorization': 'YOUR_API_KEY'
};
var data = FormData.fromMap({
'files': [
await MultipartFile.fromFile('..../audio.mp4', filename: '')
],
});
var dio = Dio();
var response = await dio.request(
'https://api.apiframe.pro/upload-audio',
options: Options(
method: 'POST',
headers: headers,
),
data: data,
);
if (response.statusCode == 200) {
print(json.encode(response.data));
}
else {
print(response.statusMessage);
}
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.apiframe.pro/upload-audio");
request.Headers.Add("Authorization", "YOUR_API_KEY");
var content = new MultipartFormDataContent();
content.Add(new StreamContent(File.OpenRead("..../audio.mp4")), "audio", "zlpGHQ2ic/Audio.mp4");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
require "uri"
require "net/http"
url = URI("https://api.apiframe.pro/upload-audio")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "YOUR_API_KEY"
form_data = [['audio', File.open('.../audio.mp4')]]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body
Last updated
Was this helpful?