The Files API gives you the ability to query uploaded files based on different filters and attributes such as name, key-values, date, and more. This is different from retrieving the actual contents of a file, which you can learn more about here.

Basic Usage

You can either use the Files SDK or the Files API as see in the examples below.

This will return an array of file objects

Filters

When listing files there a few ways you can filter the results

name

  • Type: string

Filter results based on name

group

  • Type: string

Filter results based on group ID

cid

  • Type: string

Filter results based on CID

mimeType

  • Type: string

Filter results based on mime type

order

  • Type: "ASC" | "DESC"

Order results either ascending or descending by created date

limit

  • Type: number

Limit the number of results

cidPending

  • Type: boolean

Filters results and only returns files where cid is still pending

Auto Paginate (SDK)

The list method has an auto pagination feature that is triggered when used inside a for await iterator

for await (const item of pinata.files.list() {
  console.log(item.id);
}

Works like magic ✨