iceberg-js
    Preparing search index...

    Class IcebergRestCatalog

    Client for interacting with an Apache Iceberg REST Catalog.

    This class provides methods for managing namespaces and tables in an Iceberg catalog. It handles authentication, request formatting, and error handling automatically.

    const catalog = new IcebergRestCatalog({
    baseUrl: 'https://my-catalog.example.com/iceberg/v1',
    auth: { type: 'bearer', token: process.env.ICEBERG_TOKEN }
    });

    // Create a namespace
    await catalog.createNamespace({ namespace: ['analytics'] });

    // Create a table
    await catalog.createTable(
    { namespace: ['analytics'] },
    {
    name: 'events',
    schema: { type: 'struct', fields: [...] }
    }
    );
    Index

    Constructors

    Methods

    • Creates a new table in the catalog.

      Parameters

      Returns Promise<TableMetadata>

      Table metadata for the created table

      const metadata = await catalog.createTable(
      { namespace: ['analytics'] },
      {
      name: 'events',
      schema: {
      type: 'struct',
      fields: [
      { id: 1, name: 'id', type: 'long', required: true },
      { id: 2, name: 'timestamp', type: 'timestamp', required: true }
      ],
      'schema-id': 0
      },
      'partition-spec': {
      'spec-id': 0,
      fields: [
      { source_id: 2, field_id: 1000, name: 'ts_day', transform: 'day' }
      ]
      }
      }
      );
    • Creates a table if it does not exist.

      If the table already exists, returns its metadata instead.

      Parameters

      Returns Promise<TableMetadata>

      Table metadata for the created or existing table

      const metadata = await catalog.createTableIfNotExists(
      { namespace: ['analytics'] },
      {
      name: 'events',
      schema: {
      type: 'struct',
      fields: [
      { id: 1, name: 'id', type: 'long', required: true },
      { id: 2, name: 'timestamp', type: 'timestamp', required: true }
      ],
      'schema-id': 0
      }
      }
      );
    • Checks if a namespace exists in the catalog.

      Parameters

      Returns Promise<boolean>

      True if the namespace exists, false otherwise

      const exists = await catalog.namespaceExists({ namespace: ['analytics'] });
      console.log(exists); // true or false
    • Checks if a table exists in the catalog.

      Parameters

      Returns Promise<boolean>

      True if the table exists, false otherwise

      const exists = await catalog.tableExists({ namespace: ['analytics'], name: 'events' });
      console.log(exists); // true or false