Skip to main content
GET
/
files
JavaScript
import Moonbase from '@moonbaseai/sdk';

const client = new Moonbase({
  apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const moonbaseFile of client.files.list()) {
  console.log(moonbaseFile.id);
}
{
  "type": "list",
  "data": [
    {
      "id": "1CLJt2v17V1yuCdrUwA4PW",
      "type": "file",
      "name": "Example",
      "filename": "test.txt",
      "size": 3,
      "download_url": "https://api.moonbase.ai/asset_redirects/1CLJt2v1cFRDidcZsXKEd4?token=eyJfcmFpbHMiOnsiZGF0YSI6eyJpZCI6IjFDTEp0MnYxY0ZSRGlkY1pzWEtFZDQiLCJuYW1lIjoiZmlsZSIsInJlY29yZF90eXBlIjoiTGlicmFyeUFzc2V0IiwicmVjb3JkX2lkIjoiMUNMSnQydjE3VjF5dUNkclV3QTRQVyIsImJsb2JfaWQiOiIxQ0xKdDJ2MU1zRGJvdjhEQkVFZVdIIiwiY3JlYXRlZF9hdCI6IjIwMjUtMDItMTdUMTY6MDA6MDAuMDAwWiJ9LCJleHAiOiIyMDI1LTAyLTE3VDE3OjAwOjAwLjAwMFoiLCJwdXIiOiJyZWRpcmVjdCJ9fQ--44cffd59d4a0320b941925fafa70a33ee21ef3c0",
      "associations": [],
      "created_at": "2025-02-17T16:00:00.000Z",
      "updated_at": "2025-02-17T16:00:00.000Z"
    }
  ],
  "meta": {
    "cursors": {}
  }
}

Authorizations

Authorization
string
header
required

Your Moonbase API key.

Query Parameters

before
string

When specified, returns results starting immediately before the item identified by this cursor. Use the cursor value from the response's metadata to fetch the previous page of results.

after
string

When specified, returns results starting immediately after the item identified by this cursor. Use the cursor value from the previous response's metadata to fetch the next page of results.

limit
integer
default:20

Maximum number of items to return per page. Must be between 1 and 100. Defaults to 20 if not specified.

Required range: 1 <= x <= 100

Response

Successful response.

A set of results using cursor-based pagination.

type
string
required
Allowed value: "list"
data
File · object[]
required

An array of File items.

meta
object
required

Metadata about the pagination, including the cursors pointing to the previous and next pages.