Upload mp3 audio track to your music collection

December 13, 2024

Table of contents

  1. Request Headers
  2. Query Parameters
  3. Responses
  4. Model
  5. Examples
  6. Try It

Upload mp3 audio file up to 5GB in size. Files uploaded using this endpoint will be visible to all users of Mureka.ai website. To retrieve a full list of all your uploaded tracks use GET /files.

POST raw content using Make.com and similar nocode tools.

https://api.useapi.net/v1/mureka/files/?…

Request Headers
Authorization: Bearer {API token}
Content-Type: audio/mpeg 
  • API token is required, see Setup useapi.net for details.
  • Content-Type is required, only audio/mpeg supported.
Query Parameters
  • account is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • title is required.

  • genre is required. Provide the genre of your track. See supported values using GET /music/moods-and-genres.

  • mood is required. Provide the mood of your track. See supported values using GET /music/moods-and-genres.

  • url is optional. Provide the original YouTube url if applicable.

Responses
  • 200 OK

    The response contains an id that you can use to reference the uploaded audio file when using the parameter ref_id of POST /music/create-advanced.

    {
      "id": 1122334455,
      "url": "https://<song download url>.mp3",
      "duration_milliseconds": 30000,
      "mood": "relaxed",
      "title": "<song title>",
      "genre": "afrobeat"
    }
    
  • 400 Bad Request

    {
        "error": "<Error message>",
        "code": 400
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
Model
{ // TypeScript, all fields are optional
  id: number
  url: string
  duration_milliseconds: number
  mood: string
  title: string
  genre: string
}
Examples
  • curl "https://api.useapi.net/v1/mureka/files/?account=<account>&title=<title>&genre=<genre>&mood=<mood>" \
      -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 title = "song title";
    const mood = "song mood";
    const genre = "song genre";
    const apiUrl = `https://api.useapi.net/v1/mureka/files/?account=${account}&title=${title}&genre=${genre}&mood=${mood}`; 
    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"
    title = "song title"
    mood = "song mood"
    genre = "song genre"
    apiUrl = f"https://api.useapi.net/v1/mureka/files/?account={account}&title={title}&genre={genre}&mood={mood}"
    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())
    
Try It