Searching and filtering assets
Find and list assets with POST /search: AI search, filters on paths, types, dates, and metadata, sorting, and paging through results.
POST /search is how you find assets in a drive, whether you're running an AI search, listing a folder, or pulling every file with a given metadata value. This guide covers every part of the request.
Prerequisites
A Shade API key, stored in the
SHADE_KEYenvironment variableThe ID of the drive you want to search. See Finding your IDs
Base information
Endpoint:
POST https://api.shade.inc/searchAuthentication: your API key in the
Authorizationheader, with noBearerprefixResponse: a JSON array of assets. Each asset has the same fields as
GET /assets/{asset_id}
1. Your first search
Send a natural-language query. Shade's AI search matches it against what's in the media, not only the file names.
curl -X POST "https://api.shade.inc/search" \
-H "Authorization: $SHADE_KEY" \
-H "Content-Type: application/json" \
-d '{
"drive_id": "YOUR_DRIVE_ID",
"query": "drone shot of a coastline at sunset",
"limit": 25
}'Leave query out to get every asset that matches your filters. Without a query or sort, results are sorted by name.
2. Filters
filters is a list of conditions, and results must match all of them. Every filter has three parts:
id: the field to filter onclause: how to compare, such asis,is under, orafteroptions: the values to compare against, always as a list
Built-in fields
Field
id
Clauses
options
Folder
path
is directly in, is under, is not in, is, is not, contains, starts with
Folder paths starting with the drive ID
File type
type
is, is not
VIDEO, IMAGE, AUDIO, DOCUMENT, and other AssetType values
File name
name
is, is not, contains, does not contain, starts with, does not start with, end with
Text
Extension
extension
is, is not, contains, starts with, end with
Extensions without the dot, such as mov
Date created
created
is, is not, before, after, between
ISO 8601 dates, or epoch milliseconds
Date modified
updated
is, is not, before, after, between
ISO 8601 dates, or epoch milliseconds
File size
size_bytes
is, is not, <, <=, >, >=
Sizes in bytes
Comment count
comment_count
is, is not, <, <=, >, >=
Whole numbers
Collection
collection
is directly in, is not in
Collection IDs
Person
individual
is, is not
Individual IDs, from GET /individuals
Most fields also support is empty and is not empty, which take an empty options list.
Metadata fields
To filter on a custom metadata field, use the attribute's ID as the filter id. Get the IDs from GET /workspaces/drives/{drive_id}/metadata. The clauses depend on the field's type:
Field type
Clauses
options
single_select
is, is not
Option IDs. Several IDs match any of them
multi_select
includes, does not include
Option IDs. Several IDs match assets with any of them
str
is, is not, contains, does not contain, starts with, end with
Text
int, float, rating
is, is not, <, <=, >, >=
Numbers
datetime
is, is not, before, after, between
ISO 8601 dates
bool
is true, is false
Leave empty
relation
includes, does not include, is, is not
Record or asset IDs
Every type also supports is empty and is not empty.
Examples
Videos anywhere under a folder:
Files marked "Needs Review" that were created this year:
Files over 1 GB that nobody has commented on:
Footage of a specific person:
3. Other ways to scope a search
Inside a collection
"collection_id": "COLLECTION_ID"
For assets that look like another asset
"similar_asset_id": "ASSET_ID"
Files in the drive's trash are always left out of results.
4. Sorting
Set sort to a field id, such as name, created, updated, size_bytes, or a metadata attribute ID. Add a - prefix for descending order:
5. Paging through results
limit sets the page size, which defaults to 100. page is zero-based. Keep requesting pages until one comes back with fewer than limit results:
Sort by a stable field such as created while paging, so results don't shift between pages.
6. Downloading search results
POST /search/download-urls returns signed download URLs for up to 1,000 assets at a time, picked by ID or by a search:
Each result has the asset's id, path, and url, or an error if that asset couldn't be signed. Use "origin_type": "PROXY" for the lightweight preview videos instead of the originals.
Tips
Get attribute and option IDs from
GET /workspaces/drives/{drive_id}/metadataonce and reuse them, rather than looking them up for every search.Paths in filters start with the drive ID, the same as the
pathfield on every asset.To look up files, folders, collections, people, and views by name, use
POST /search/simple.
Related
Last updated
Was this helpful?

