0

List files

by
Published Oct 17, 2025

Get a paginated list of all files created by the user or organization associated with the provided API token. Example cURL request: ```console curl -s \ -H "Authorization: Token $REPLICATE_API_TOKEN" \ https://api.replicate.com/v1/files ``` The response will be a paginated JSON array of file objects, sorted with the most recent file first.

Script replicate Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Replicate = {
3
  token: string;
4
};
5
/**
6
 * List files
7
 * Get a paginated list of all files created by the user or organization associated with the provided API token.
8

9
Example cURL request:
10

11
```console
12
curl -s \
13
  -H "Authorization: Token $REPLICATE_API_TOKEN" \
14
  https://api.replicate.com/v1/files
15
```
16

17
The response will be a paginated JSON array of file objects, sorted with the most recent file first.
18

19
 */
20
export async function main(auth: Replicate) {
21
  const url = new URL(`https://api.replicate.com/v1/files`);
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36