Box Developer Documentation

List all metadata on an item

List all metadata on an item

Metadata instances can be listed for either a file or a folder.

List metadata on a file

To list all metadata instances on a file, call the GET /files/:file_id/metadata API endpoint.

cURL
curl -i -X GET "https://api.box.com/2.0/files/12345/metadata" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
Node/TypeScript v10
await client.fileMetadata.getFileMetadata(file.id);
Python v10
client.file_metadata.get_file_metadata(file.id)
.NET v10
await client.FileMetadata.GetFileMetadataAsync(fileId: file.Id);
Swift v10
try await client.fileMetadata.getFileMetadata(fileId: file.id)
Java v10
client.getFileMetadata().getFileMetadata(file.getId())
Java v4
BoxFile file = new BoxFile(api, "id");
Iterable<Metadata> metadataList = file.getAllMetadata();
for (Metadata metadata : metadataList) {
    // Do something with the metadata.
}
Python v3
file_metadata = client.file(file_id='11111').get_all_metadata()
for instance in file_metadata:
    if 'foo' in instance:
        print(f'Metadata instance {instance["id"]} has value "{instance["foo"]}" for foo')
.NET v5
BoxMetadataTemplateCollection<Dictionary<string, object>> metadataInstances = await client.MetadataManager
    .GetAllFileMetadataTemplatesAsync(fileId: "11111");
Node v3
client.files.getAllMetadata('11111')
	.then(metadata => {
		/* metadata -> {
			entries: 
			[ { currentDocumentStage: 'Init',
				'$type': 'documentFlow-452b4c9d-c3ad-4ac7-b1ad-9d5192f2fc5f',
				'$parent': 'file_11111',
				'$id': '50ba0dba-0f89-4395-b867-3e057c1f6ed9',
				'$version': 4,
				'$typeVersion': 2,
				needsApprovalFrom: 'Smith',
				'$template': 'documentFlow',
				'$scope': 'enterprise_12345' },
				{ '$type': 'productInfo-9d7b6993-b09e-4e52-b197-e42f0ea995b9',
				'$parent': 'file_11111',
				'$id': '15d1014a-06c2-47ad-9916-014eab456194',
				'$version': 2,
				'$typeVersion': 1,
				skuNumber: 45334223,
				description: 'Watch',
				'$template': 'productInfo',
				'$scope': 'enterprise_12345' },
				{ Popularity: '25',
				'$type': 'properties',
				'$parent': 'file_11111',
				'$id': 'b6f36cbc-fc7a-4eda-8889-130f350cc057',
				'$version': 0,
				'$typeVersion': 2,
				'$template': 'properties',
				'$scope': 'global' } ],
			limit: 100 }
		*/
	});

This API does not support paging and it will always return all of the metadata instances for this file.

List metadata on a folder

To list all metadata instances on any folder (except for the root folder), call the GET /folders/:file_id/metadata API endpoint.

cURL
curl -i -X GET "https://api.box.com/2.0/folders/4353455/metadata" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
Node/TypeScript v10
await client.folderMetadata.getFolderMetadata(folder.id);
Python v10
client.folder_metadata.get_folder_metadata(folder.id)
.NET v10
await client.FolderMetadata.GetFolderMetadataAsync(folderId: folder.Id);
Swift v10
try await client.folderMetadata.getFolderMetadata(folderId: folder.id)
Java v10
client.getFolderMetadata().getFolderMetadata(folder.getId())
Java v4
BoxFolder file = new BoxFolder(api, "id");
Iterable<Metadata> metadataList = folder.getAllMetadata();
for (Metadata metadata : metadataList) {
    // Do something with the metadata.
}
Python v3
folder_metadata = client.folder(folder_id='22222').get_all_metadata()
for instance in folder_metadata:
    if 'foo' in instance:
        print(f'Metadata instance {instance["id"]} has value "{instance["foo"]}" for foo')
.NET v5
BoxMetadataTemplateCollection<Dictionary<string, object>> metadataInstances = await client.MetadataManager
    .GetAllFolderMetadataTemplatesAsync(folderId: "11111");
Node v3
client.folders.getAllMetadata('11111')
	.then(metadata => {
		/* metadata -> {
			entries: 
			[ { currentDocumentStage: 'Init',
				'$type': 'documentFlow-452b4c9d-c3ad-4ac7-b1ad-9d5192f2fc5f',
				'$parent': 'folder_11111',
				'$id': '50ba0dba-0f89-4395-b867-3e057c1f6ed9',
				'$version': 4,
				'$typeVersion': 2,
				needsApprovalFrom: 'Smith',
				'$template': 'documentFlow',
				'$scope': 'enterprise_12345' },
				{ '$type': 'productInfo-9d7b6993-b09e-4e52-b197-e42f0ea995b9',
				'$parent': 'folder_11111',
				'$id': '15d1014a-06c2-47ad-9916-014eab456194',
				'$version': 2,
				'$typeVersion': 1,
				skuNumber: 45334223,
				description: 'Watch',
				'$template': 'productInfo',
				'$scope': 'enterprise_12345' },
				{ Popularity: '25',
				'$type': 'properties',
				'$parent': 'folder_11111',
				'$id': 'b6f36cbc-fc7a-4eda-8889-130f350cc057',
				'$version': 0,
				'$typeVersion': 2,
				'$template': 'properties',
				'$scope': 'global' } ],
			limit: 100 }
		*/
	});

This API does not support paging and it will always return all of the metadata instances for this file. This API can not be used on the root folder with ID 0.