All Products
Search
Document Center

ApsaraVideo VOD:Query media asset information

Last Updated:Feb 10, 2026

Locating specific media assets can be challenging when your library contains many audio, video, and image files. ApsaraVideo VOD (VOD) provides a powerful media search feature that lets you search, filter, and sort assets across multiple dimensions. You can use the console or an API or SDK to efficiently and accurately retrieve the media assets you need from large datasets.

Scenario 1: Search using the console

To search for audio or video information, follow these steps:

  1. Log on to the ApsaraVideo VOD console.

  2. In the left navigation pane, choose Media Files > Audio/Video to go to the Audio/Video management page.

  3. Use the filter and search features at the top of the page to locate media assets.搜索媒资信息1.png

    • Search: Supports fuzzy search for Video Title and exact match for Media ID and Tag Name.

    • Filter: Supports filtering audio and video files by Address, Type, Category, Status, Source, and Storage Class. You can also sort the results by Created At in ascending or descending order.

Scenario 2: Search for media assets using an API or SDK

Note

Use a server-side software development kit (SDK) to call the API to search for media asset information. For more information, see VOD SDKs.

Use the SearchMedia operation to integrate search capabilities into your business systems and automate media asset retrieval. You can filter media assets by fields such as VideoId, CateId, StorageLocation, Title, and Tags. For more information, see Protocol for media asset search. The following code provides examples:

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.vod.model.v20170321.SearchMediaRequest;
import com.aliyuncs.vod.model.v20170321.SearchMediaResponse;

public class SearchMediaExample {
    public static void main(String[] args) {
        // Initialize the client.
        DefaultProfile profile = DefaultProfile.getProfile(
            "cn-shanghai",          // The region ID.
            "YOUR_ACCESS_KEY_ID",   // The AccessKey ID.
            "YOUR_ACCESS_KEY_SECRET"// The AccessKey secret.
        );
        IAcsClient client = new DefaultAcsClient(profile);
        
        // Build the request.
        SearchMediaRequest request = new SearchMediaRequest();
        request.setMatch("Title='VOD' AND Status='Normal'");
        request.setFields("Title,CoverURL,Duration,Size");
        request.setSortBy("CreationTime:Desc");
        request.setPageSize(20);
        request.setPageNo(1);
        
        try {
            SearchMediaResponse response = client.getAcsResponse(request);
            System.out.println("Total Records: " + response.getTotal());
            for (SearchMediaResponse.Media media : response.getMediaList()) {
                System.out.println("VideoId: " + media.getMediaId() + ", Title: " + media.getVideo().getTitle());
            }
        } catch (Exception e) {
            System.err.println("An error occurred: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
from aliyunsdkcore.client import AcsClient
from aliyunsdkvod.request.v20170321 import SearchMediaRequest
import json

# Initialize the client.
client = AcsClient(
    'YOUR_ACCESS_KEY_ID', 
    'YOUR_ACCESS_KEY_SECRET', 
    'cn-shanghai'
)

# Build the request.
request = SearchMediaRequest.SearchMediaRequest()
request.set_Match("Title='VOD' AND Status='Normal'")
request.set_Fields("Title,CoverURL,Duration,Size")
request.set_SortBy("CreationTime:Desc")
request.set_PageSize(20)
request.set_PageNo(1)

try:
    response_str = client.do_action_with_exception(request)
    response_data = json.loads(response_str)
    print(f"Total Records: {response_data.get('Total')}")
    for media in response_data.get('MediaList', {}).get('Media', []):
        print(f"VideoId: {media.get('MediaId')}, Title: {media.get('Video', {}).get('Title')}")
except Exception as e:
    print(f"An error occurred: {e}")

Paging and data traversal

To ensure query performance, media search provides two paging modes.

  • Standard paging (for UI display)

    Use the PageNo and PageSize parameters to retrieve data page by page. You can retrieve up to the first 5,000 records from the search results.

  • Scroll-based traversal (for data exporting)

    Use the PageNo and PageSize parameters and the ScrollToken cursor for deep traversal. This method lets you retrieve all search results in segments. Each segment is limited to a maximum of 1,200 records. The following code provides an example:

    // Scroll-based traversal example
    String scrollToken = null;
    // The SessionId must remain the same throughout a complete traversal.
    String sessionId = java.util.UUID.randomUUID().toString(); 
    List<SearchMediaResponse.Media> allMedia = new ArrayList<>();
    
    do {
        SearchMediaRequest request = new SearchMediaRequest();
        request.setPageSize(100); // Pull up to 100 records at a time.
        request.setSessionId(sessionId);
        
        if (scrollToken != null) {
            request.setScrollToken(scrollToken);
        }
        
        SearchMediaResponse response = client.getAcsResponse(request);
        if (response.getMediaList() != null) {
            allMedia.addAll(response.getMediaList());
        }
        
        scrollToken = response.getScrollToken();
        
    // An empty or null scrollToken indicates that all data has been traversed.
    } while (scrollToken != null && !scrollToken.isEmpty());
    

API call examples

The sample code in the following section describes the query statements used for querying video information.

Important
  • Before you send a request, you must perform URL encoding on the request parameters.

  • The equal signs (=), double quotation marks ("), single quotation marks ('), and parentheses used in the statement must be single-byte characters.

classification

Description

Return field

The media search operation returns basic media asset information by default. To obtain additional information, specify the Fields parameter. The following example returns the Title and CoverURL:

Fields=Title,CoverURL

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Fields=Title,CoverURL

Exact match

Query information about the video whose VideoId is 28ba2b26d540446c94cdd2c4c48090e5:

VideoId='28ba2b26d540446c94cdd2c4c48090e5'

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=VideoId='28ba2b26d540446c94cdd2c4c48090e5'

Fuzzy match

To search for a Title that contains Music, you can use:

Title='Music'

Alternatively, you can write it as

Title in ('Music')

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=Title='Music'

Multi-value query

Note: If the fields used for the query only support fuzzy match, the query results are also returned based on fuzzy match.

Query for a Status of Normal or Checking:

Status in ('Normal','Checking')

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=Status in ('Normal','Checking')

Range query

Use a closed or open interval to specify a range. The CreationTime is between 2018-01-01T00:00:00Z and 2018-02-01T00:00:00Z:

CreationTime=('2018-01-01T00:00:00Z','2018-02-01T00:00:00Z')

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=CreationTime=('2018-01-01T00:00:00Z','2018-02-01T00:00:00Z')

If you specify only a start or end time, leave the other value empty. For example, to query for a CreationTime later than 2018-01-01T00:00:00Z:

CreationTime=('2018-01-01T00:00:00Z',)

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&Match=CreationTime=('2018-01-01T00:00:00Z',)

Sort field

Sort media asset information in reverse chronological order based on the creation time:

CreationTime:Desc

Sample request:

http://vod.cn-shanghai.aliyuncs.com?Action=SearchMedia
&SortBy=CreationTime:Desc

References