List MIDI files

May 15, 2025 (November 16, 2026)

Table of contents

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

This endpoint retrieves a list of MIDI files that you’ve previously uploaded using POST music/midi. These MIDI files can be used as templates for music generation with POST music/song.

https://api.useapi.net/v1/tempolor/music/midi/?…

Request Headers
Authorization: Bearer {API token}
Query Parameters
  • user_id is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • cursor is optional. Pagination cursor for fetching additional pages of results.

Responses
  • 200 OK

    {
      "records": [
        {
          "opType": "upload",
          "ucid": "user_id",
          "midiItemId": "user:12345-tempolor:user_id-midi:abcdef123456789",
          "name": "Piano Composition",
          "midiUrl": "https://ugc-cdn.api.instabeat.ai/midi/file/abcdef123456789.mid"
        },
        {
          "opType": "upload",
          "ucid": "user_id",
          "midiItemId": "user:12345-tempolor:user_id-midi:fedcba987654321",
          "name": "Guitar Progression",
          "midiUrl": "https://ugc-cdn.api.instabeat.ai/midi/file/fedcba987654321.mid"
        }
      ],
      "hasNext": false,
      "cursor": ""
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
  • 596 Account signed out

    TemPolor signed the account out, so its session ticket no longer works. The API stops using the account until you add it again with fresh credentials at POST accounts, see Setup TemPolor. Requests without user_id use your other accounts in the meantime.

    {
      "error": "TemPolor signed out account 101441809 (You are currently logged out (400006)). Add it again with POST /v1/tempolor/accounts using fresh credentials, see https://useapi.net/docs/start-here/setup-tempolor",
      "code": 596
    }
    

    If every account you have is in this state, a request without user_id returns 596 as well.

Model

A page of your uploaded MIDI files, each with its midiItemId, name and midiUrl, plus hasNext and cursor for paging.

The list of MIDI files, field by field
{   // TypeScript, all fields are optional
    records: {
        opType: string
        ucid: string
        midiItemId: string
        name: string
        midiUrl: string
        midiType?: string
        midiValue?: string
    }[]
    hasNext: boolean
    cursor: string
    error: string
    code: number
}
Examples
  • # List all MIDI files
    curl -H "Authorization: Bearer …" \
         https://api.useapi.net/v1/tempolor/music/midi/?user_id=user_id
    
    # Paginate through results using cursor
    curl -H "Authorization: Bearer …" \
         "https://api.useapi.net/v1/tempolor/music/midi/?user_id=user_id&cursor=next_page_cursor_token"
    
  • const token = "API token";
    const user_id = "user_id"; 
    const cursor = ""; // for pagination
    
    // Build the URL with query parameters
    let apiUrl = `https://api.useapi.net/v1/tempolor/music/midi/?user_id=${user_id}`;
    if (cursor) apiUrl += `&cursor=${cursor}`;
    
    const response = await fetch(apiUrl, {
      method: "GET",
      headers: {
        "Authorization": `Bearer ${token}`
      }
    });
    const result = await response.json();
    console.log(`Found ${result.records?.length || 0} MIDI files`);
    
    // Example of fetching all pages
    async function fetchAllMidiFiles(userId) {
      let allRecords = [];
      let nextCursor = "";
      let hasMore = true;
      
      while (hasMore) {
        let url = `https://api.useapi.net/v1/tempolor/music/midi/?user_id=${userId}`;
        if (nextCursor) url += `&cursor=${nextCursor}`;
        
        const response = await fetch(url, {
          method: "GET",
          headers: { "Authorization": `Bearer ${token}` }
        });
        
        const data = await response.json();
        
        if (data.records && data.records.length > 0) {
          allRecords = [...allRecords, ...data.records];
        }
        
        hasMore = data.hasNext;
        nextCursor = data.cursor;
        
        // Break if no more pages or no cursor
        if (!hasMore || !nextCursor) break;
      }
      
      return allRecords;
    }
    
  • import requests
    
    token = "API token"
    user_id = "user_id"
    cursor = ""  # for pagination
    
    # Build the URL with query parameters
    apiUrl = f"https://api.useapi.net/v1/tempolor/music/midi/?user_id={user_id}"
    if cursor:
        apiUrl += f"&cursor={cursor}"
    
    headers = {
        "Authorization": f"Bearer {token}"
    }
    
    response = requests.get(apiUrl, headers=headers)
    result = response.json()
    print(f"Found {len(result.get('records', []))} MIDI files")
    
    # Example of fetching all pages
    def fetch_all_midi_files(user_id):
        all_records = []
        next_cursor = ""
        has_more = True
        
        while has_more:
            url = f"https://api.useapi.net/v1/tempolor/music/midi/?user_id={user_id}"
            if next_cursor:
                url += f"&cursor={next_cursor}"
            
            response = requests.get(url, headers=headers)
            data = response.json()
            
            if data.get('records'):
                all_records.extend(data.get('records'))
            
            has_more = data.get('hasNext', False)
            next_cursor = data.get('cursor', "")
            
            # Break if no more pages or no cursor
            if not has_more or not next_cursor:
                break
        
        return all_records
    
Try It