assets.list
Puck Assets is in early access. Request access.
Find and list assets.
await puck.assets.list();Returns an AssetList containing the assets, and pagination metadata.
Args
| Param | Example | Type | Status |
|---|---|---|---|
params | { query: "bike" } | Object | - |
options | { auth: {} } | Object | - |
params
Pagination and filtering options for listing assets. Defaults to the first 50, newest first.
| Param | Example | Type | Status |
|---|---|---|---|
query | query: "bike" | String | - |
folderId | folderId: "folder_123" | String | null | - |
tags | tags: { all: ["Brand"] } | Object | - |
types | types: { any: ["image/"] } | Object | - |
sort | sort: { by: "name" } | Object | - |
offset | offset: 50 | Number | - |
limit | limit: 20 | Number | - |
Optional filter params
query
Find assets that contain the specified text in their filenames, titles, or tags.
folderId
List assets from the specified folder. Use null to list the assets in no folder or undefined to list all assets. Defaults to all assets.
tags
List assets that have the specified tags.
const { results } = await puck.assets.list({
tags: { all: ["Brand", "Summer"] },
});| Param | Example | Type | Status |
|---|---|---|---|
tags.all | all: ["Brand"] | String[] | - |
tags.all
List assets that have all of the specified tags.
types
List assets that match the specified media types. Use media type prefixes or full media types.
const { results } = await puck.assets.list({
types: { any: ["image/"] },
});| Param | Example | Type | Status |
|---|---|---|---|
types.any | any: ["image/"] | String[] | - |
types.any
List assets that match any of the specified media types.
Optional paging params
sort
Sort the resulting asset list after filtering.
const { results } = await puck.assets.list({
sort: { by: "name", dir: "asc" },
});| Param | Example | Type | Status |
|---|---|---|---|
sort.by | by: "name" | "createdAt" | "sizeBytes" | "name" | "type" | - |
sort.dir | dir: "asc" | "asc" | "desc" | - |
sort.by
Sort the assets by one of its fields. Defaults to "createdAt".
"createdAt": when the asset was created"sizeBytes": the file’s size"name": the filename"type": the media type
sort.dir
Set the sort direction in the selected field. Use "asc" for ascending order or "desc" for descending order. Defaults to "desc".
offset
Skip a number of assets in the resulting list after filtering and sorting, from the start. Defaults to 0.
limit
Limit the number of assets returned in the resulting list after filtering, sorting, and skipping the offset, up to 100. Defaults to 50.
options
Set the request options for this call.