Upload mp3 melody (motif) track
December 13, 2024
Table of contents
Upload mp3 audio file up to 5GB in size. Use id
value to reference uploaded melody when using the parameter motif_id
of POST /music/create-advanced. Uploaded file will not be visible for other users of the Mureka.ai
POST raw content using Make.com and similar nocode tools.
https://api.useapi.net/v1/mureka/files/motif/?…
Request Headers
Authorization: Bearer {API token}
Content-Type: audio/mpeg
API token
is required, see Setup useapi.net for details.Content-Type
is required, onlyaudio/mpeg
supported.
Query Parameters
account
is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.
Responses
-
The response contains an
id
that you can use to reference the uploaded melody when using the parametermotif_id
of POST /music/create-advanced.{ "id": "user:777-mureka:987654321-file:123456789", "url": "https://<song download url>.mp3", "duration_milliseconds": 50000 }
-
{ "error": "<Error message>", "code": 400 }
-
{ "error": "Unauthorized", "code": 401 }
Model
{ // TypeScript, all fields are optional
id: string
url: string
duration_milliseconds: number
}
Examples
-
curl "https://api.useapi.net/v1/mureka/files/motif/?account=<account>" \ -H "Authorization: Bearer …" \ -H "Content-Type: audio/mpeg" \ --data-binary /path/to/your/audio.mp3
-
const token = "API token"; const account = "Previously configured account account"; const apiUrl = `https://api.useapi.net/v1/mureka/files/motif/?account=${account}`; let blob; /* // Example 1: Fetch audio from URL const url = "https://upload.wikimedia.org/wikipedia/commons/7/7d/sound.mp3"; const response = await fetch(url); blob = await responseImage.blob(); */ /* // Example 2: Load audio from local file (Blob) const fsp = require('fs').promises; const fileName = "./music.mp3"; blob = new Blob([await fsp.readFile(fileName)]); */ /* // Example 3: Load from input file html element // <input id="music-file" type="file"> const musicFile = document.getElementById(`music-file`); if (musicFile.files[0]) blob = musicFile.files[0]); */ const response = await fetch(apiUrl, { method: "POST" headers: { "Authorization": `Bearer ${token}`, }, body: blob }); const result = await response.json(); console.log("response", {response, result});
-
import requests token = "API token" account = "Previously configured account account" apiUrl = f"https://api.useapi.net/v1/mureka/files/motif/?account={account}" headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'audio/mpeg' } # # Example 1: Fetch audio from URL # url = "https://upload.wikimedia.org/wikipedia/commons/7/7d/audio.mp3" # response_audio = requests.get(url) # file_content = response_audio.content # # Example 2: Load audio from local file # audio_file_path = "./audio.mp3" # with open(audio_file_path, 'rb') as audio_file: # file_content = audio_file.read() response = requests.post(api_url, headers=headers, data=file_content) print(response, response.json())