Files
list
List and filter files pinned to your Pinata account
Usage
import { PinataSDK } from "pinata";
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT!,
pinataGateway: "example-gateway.mypinata.cloud",
});
const files = await pinata.files.list()
Returns
type FileListResponse = {
files: FileListItem[];
next_page_token: string;
};
type FileListItem = {
id: string;
name: string | null;
cid: "pending" | string;
size: number;
numberOfFiles: number;
mimeType: string;
groupId: string;
updatedAt: string;
createdAt: string;
};
Parameters
Filter response with the following additional methods. All filters are optional.
limit
- Type:
number
Limit the number of results
const files = await pinata.files
.list()
.limit(10)
cidPending
- Type:
boolean
Filters results and only returns files where cid
is still pending
const files = await pinata.files
.list()
.cid(true)
pageToken
- Type:
string
Paginates through files based on a provided page token
const files = await pinata.files
.list()
.pageToken("MDE5MWIzZWYtM2U0Zi03YTY5LWE3OTQtOTRhZDE5NjQxMTk0")
Auto Paginate
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 ✨