Media

List and query media

Query media in the Bucket. This is also how you fetch a single media item by name: pass query={"name":"7f9403a32f29-toucan.jpg"}.

The name of a media item is the value you assign to a File or Image Metafield when creating or updating an Object. Upload is not part of this host: POST /v3/buckets/{slug}/media is served by https://workers.cosmicjs.com.

get/buckets/{slug}/media

Query parameters

read_keystring

The Bucket read key. Required unless the Bucket has no read key configured.

querystring

A URL-encoded JSON object used to filter results. Follows MongoDB comparison ($eq, $gt, $gte, $lt, $lte, $in, $all, $ne, $nin), evaluation ($regex with $options), and logical ($and, $or, $not, $nor) operators. Query Object Relationship Metafields by the related Object's id, not its slug.

propsstring

Comma-separated list of properties to return, including nested metadata paths. Omit to return everything. Narrowing props is the main way to keep responses under the 6 MB response cap and to reduce latency.

sort'created_at' | '-created_at' | 'modified_at' | '-modified_at' | 'random'

Sort order. Prefix with - for descending.

limitinteger

Maximum number of results to return.

skipinteger

Offset pagination: number of results to skip. Use after instead for large collections. Only one of skip and after may be used.

useCacheboolean

Set to false to bypass the cache and read through to the database. Guarantees you see writes you just made, at the cost of higher latency.

prettyboolean

Set to true to indent the JSON response for human reading. Increases response size.

Response

The matching media.

totalinteger
limitinteger

Example response

{
  "media": [
    {
      "type": "image/png"
    }
  ]
}

Changes

No recorded changes to this endpoint across all 1 revision of this API.