Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

36.6 KB
Raw Blame

title: "Lance REST Service" slug: "/lance-rest-service" keywords: - Lance REST - Lance datasets - REST API license: "This software is licensed under the Apache License version 2."

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Overview

The Lance REST service provides a RESTful interface for managing Lance datasets through HTTP endpoints. It enables seamless interaction with Lance datasets for data operations and metadata management.

The service implements the Lance REST API specification. For detailed specification documentation, see the official Lance REST documentation.

About Lance

Lance is a modern columnar data format designed for AI/ML workloads. It provides:

  • High-performance vector search: Native support for similarity search on high-dimensional embeddings
  • Columnar storage: Optimized for analytical queries and machine learning pipelines
  • Fast random access: Efficient row-level operations unlike traditional columnar formats
  • Version control: Built-in dataset versioning and time-travel capabilities
  • Incremental updates: Append and update data without full rewrites

Architecture

The Lance REST service acts as a bridge between Lance datasets and applications:

┌─────────────────┐
│   Applications   │
│  (Python/Java)   │
└────────┬────────┘
         │ HTTP/REST
         ▼
┌─────────────────┐
│   Lance REST     │
│    Service       │ 
└────────┬────────┘
         │ 
         ▼ Gravitino internal API or HTTP client
┌─────────────────┐
│ Gravitino Server │ 
│(Metadata Backend)│
└────────┬────────┘
         │ File System Operations
         ▼
┌─────────────────┐
│  Lance Datasets  │ 
│ (S3/GCS/Local)   │
└─────────────────┘

Key Features:

  • Support for the Lance REST operations listed below
  • Can run standalone or integrated with Gravitino server
  • Support for namespace and table management
  • Metadata stored in Gravitino for unified governance

Supported Operations

The Lance REST service provides comprehensive support for namespace management and table management. Index operations are not supported yet. The table below lists all supported operations:

Operation Description HTTP Method Endpoint Pattern
CreateNamespace Create a new Lance namespace POST /lance/v1/namespace/{id}/create
ListNamespaces List all namespaces under a parent namespace GET /lance/v1/namespace/{parent}/list
DescribeNamespace Retrieve detailed information about a specific namespace POST /lance/v1/namespace/{id}/describe
DropNamespace Delete a namespace POST /lance/v1/namespace/{id}/drop
NamespaceExists Check whether a namespace exists POST /lance/v1/namespace/{id}/exists
ListTables List all tables in a namespace GET /lance/v1/namespace/{id}/table/list
CreateTable Create a new table in a namespace POST /lance/v1/table/{id}/create
DescribeTable Describe an existing Lance table POST /lance/v1/table/{id}/describe
DropTable Delete a table including both metadata and data POST /lance/v1/table/{id}/drop
TableExists Check whether a table exists POST /lance/v1/table/{id}/exists
RegisterTable Register an existing Lance table to a namespace POST /lance/v1/table/{id}/register
DeregisterTable Unregister a table from a namespace (metadata only, data remains) POST /lance/v1/table/{id}/deregister
DeclareTable Declare a table and store the metadata without touching lance table data. POST /lance/v1/table/{id}/declare

More details, refer to the Lance REST API specification

Operation Details

Some operations have specific behaviors and modes. Below are important details to consider:

Mode values are parsed case-insensitively. The underscore-free PascalCase spelling ExistOk is accepted as exist_ok. The examples below use lowercase snake_case as the REST-style canonical form.

Namespace Operations

CreateNamespace supports three modes:

  • create: Fails if namespace already exists
  • exist_ok: Succeeds even if namespace exists
  • overwrite: Replaces existing namespace

DropNamespace behavior:

  • Defaults to behavior=restrict; non-empty namespaces cannot be dropped in this mode
  • behavior=cascade removes child metadata recursively
  • Cascading a schema drop uses table drop semantics: external Lance datasets are preserved
  • Use DropTable explicitly to delete a table's data; namespace deletion is not a storage purge

Table Operations

RegisterTable vs CreateTable:

  • RegisterTable: Links existing Lance datasets into Gravitino catalog without data movement
  • CreateTable: Creates an empty Lance dataset using the schema from the Arrow IPC stream

Registration requires an existing, readable Lance dataset. A plain directory or missing dataset is rejected before any existing table is removed. Registration with overwrite replaces only an external table's metadata and preserves its dataset; it rejects existing managed tables. Replacing a managed table requires an explicit drop first, which deletes the managed dataset.

:::note The current CreateTable implementation accepts schema-only Arrow streams, including zero-row batches. A stream containing rows returns HTTP 406 before any metadata or dataset changes, including for overwrite. Write records through a Lance client or engine after creation.

The version field of CreateTable reports the stored Lance dataset version when available. DescribeTable currently returns the latest metadata even when a historical version is requested; versioned metadata reads are not implemented. :::

DropTable vs DeregisterTable:

  • DropTable: Permanently deletes metadata and data files when permitted by the catalog policy
  • DeregisterTable: Removes metadata from Gravitino but preserves Lance data files

The generic catalog rejects purging external or registered Lance tables by default, before removing table metadata or deleting files. Lance REST reports this as HTTP 406 (UnsupportedOperation). Tables created, declared or registered through Lance REST are external, so this default also applies to them. Use DeregisterTable to remove their metadata while retaining their data.

A catalog administrator can set lance.allow-external-table-purge=true on the lakehouse-generic catalog to permit physical deletion. This catalog-only setting also applies to create OVERWRITE when it replaces an existing external table. A table property or request header cannot enable it. Existing catalogs must explicitly opt in to retain their previous destructive drop/overwrite behavior. Enabling it permits deletion at caller-supplied locations; it does not verify storage ownership or provide isolation between tables. Enable it only when table owners are trusted to delete data at locations they can register. Underlying storage permissions still apply.

Deployment

Run with Gravitino Server

To enable the Lance REST service within Gravitino server, configure the following properties in your Gravitino configuration file ${GRAVITINO_HOME}/conf/gravitino.conf:

Configuration Property Description Default Value Required
gravitino.auxService.names Auxiliary services to run. Include lance-rest to enable Lance REST service iceberg-rest,lance-rest Yes
gravitino.lance-rest.classpath Classpath for Lance REST service, relative to Gravitino home directory lance-rest-server/libs Yes
gravitino.lance-rest.httpPort Port number for Lance REST service 9101 No
gravitino.lance-rest.host Hostname for Lance REST service 0.0.0.0 No
gravitino.lance-rest.includeErrorStackTrace Whether eligible backend errors include stack traces in detail; request/validation errors always omit them. Set this to false in new deployments true No
gravitino.lance-rest.trustedProxies Comma-separated IP addresses or CIDR blocks of reverse proxies whose X-Forwarded-For is trusted for audit client addresses (none) No
gravitino.lance-rest.namespace-backend Namespace metadata backend (currently only gravitino is supported) gravitino Yes
gravitino.lance-rest.gravitino-uri Gravitino server URI. Not required in auxiliary mode. http://localhost:8090 No
gravitino.lance-rest.gravitino-metalake Gravitino metalake name (required when namespace-backend is gravitino) (none) Yes

Authentication to the Gravitino Server

In standalone mode, the Lance REST service makes HTTP requests to the Gravitino server using its configured service credentials. Configure the auth type to match the Gravitino server. Auxiliary mode uses internal APIs and preserves the authenticated caller instead; the simple user name below is only the fallback for requests accepted as anonymous.

Configuration Property Description Default Value Required
gravitino.lance-rest.gravitino-auth-type Auth type used to reach the Gravitino server. Supported values: simple, oauth2 simple No
gravitino.lance-rest.gravitino-simple.user-name User name presented when the auth type is simple lance-rest-server No
gravitino.lance-rest.gravitino-oauth2.server-uri OAuth2 server URI (none) Yes, for oauth2
gravitino.lance-rest.gravitino-oauth2.credential Credential used to request the OAuth2 token (none) Yes, for oauth2
gravitino.lance-rest.gravitino-oauth2.token-path Path on the OAuth2 server used to request the token (none) Yes, for oauth2
gravitino.lance-rest.gravitino-oauth2.scope Scope of the requested OAuth2 token (none) Yes, for oauth2

These settings control outbound authentication in standalone mode. They do not configure inbound authentication to Lance REST. See Authentication and authorization.

Example Configuration:

gravitino.auxService.names = lance-rest
gravitino.lance-rest.httpPort = 9101
gravitino.lance-rest.host = 0.0.0.0
gravitino.lance-rest.namespace-backend = gravitino
gravitino.lance-rest.gravitino-metalake = my_metalake

In auxiliary mode, gravitino.lance-rest.gravitino-uri is not required because the Lance REST service uses Gravitino's internal API.

Run Standalone

To run Lance REST service independently without Gravitino server (You need to start Gravitino server first):

{GRAVITINO_HOME}/bin/gravitino-lance-rest-server.sh start

Configure the service by editing {GRAVITINO_HOME}/conf/gravitino-lance-rest-server.conf or passing command-line arguments:

Configuration Property Description Default Value Required
gravitino.lance-rest.namespace-backend Namespace metadata backend gravitino Yes
gravitino.lance-rest.gravitino-uri Gravitino server URI http://localhost:8090 Yes
gravitino.lance-rest.gravitino-metalake Gravitino metalake name (none) Yes
gravitino.lance-rest.httpPort Service port number 9101 No
gravitino.lance-rest.host Service hostname 0.0.0.0 No
gravitino.lance-rest.includeErrorStackTrace Whether eligible backend errors include stack traces; request/validation errors always omit them true No
gravitino.lance-rest.metrics.enabled Enable standalone metrics endpoints false No
gravitino.lance-rest.trustedProxies Reverse proxies trusted for X-Forwarded-For (none) No

trustedProxies works as described for gravitino.server.webserver.trustedProxies. When it is empty, X-Forwarded-For is ignored and the audit log records the TCP peer address.

:::tip In standalone deployments, you only need to configure gravitino.lance-rest.gravitino-metalake, gravitino.lance-rest.gravitino-uri, and other properties can use their default values. :::

Run with Docker

Launch Lance REST service using Docker(You need to start Gravitino server first):

docker run -d --name lance-rest-service -p 9101:9101 \
  -e LANCE_REST_GRAVITINO_METALAKE_NAME=your_metalake_name \
  -e LANCE_REST_GRAVITINO_URI=http://gravitino-host:port \
  apache/gravitino-lance-rest:latest

Access the service at http://localhost:9101/lance.

Environment Variables:

Environment Variable Configuration Property Required Default Value
LANCE_REST_NAMESPACE_BACKEND gravitino.lance-rest.namespace-backend Yes gravitino
LANCE_REST_GRAVITINO_METALAKE_NAME gravitino.lance-rest.gravitino-metalake Yes (none)
LANCE_REST_GRAVITINO_URI gravitino.lance-rest.gravitino-uri Yes http://localhost:8090
LANCE_REST_HOST gravitino.lance-rest.host No 0.0.0.0
LANCE_REST_PORT gravitino.lance-rest.httpPort No 9101

:::tip Configuration Tips

  • Required: Set LANCE_REST_GRAVITINO_METALAKE_NAME to your Gravitino metalake name
  • Conditional: Update LANCE_REST_GRAVITINO_URI if Gravitino server is not on localhost in the Docker instance.
  • Optional: Other variables can use default values unless you have specific requirements :::

Health Checks

The Lance REST service exposes /lance/health/live, /lance/health/ready, and /lance/health on its own port. Root aliases /health/live, /health/ready, /health, and /health.html are also available. Readiness checks whether the namespace wrapper is initialized. The top-level status and each checks[].status use lowercase up or down, as on the main Gravitino server.

After an observed OutOfMemoryError, all these endpoints return HTTP 503 with a jvm failure until restart, even if the wrapper remains initialized. See health and readiness for response details and detection scope.

Usage Guidelines

When using Lance REST service with Gravitino backend, keep the following considerations in mind:

Prerequisites

  • A running Gravitino server with a metalake

Namespace Hierarchy

Gravitino follows a three-level hierarchy: catalog → schema → table. When creating namespaces or tables:

  1. Parent must exist: Before creating lance_catalog/schema, ensure lance_catalog catalog exists in Gravitino metalake.
  2. Two-level limit: Create namespace lance_catalog/schema, but not lance_catalog/schema/sub_schema.
  3. Table placement: Tables can only be created under lance_catalog/schema, not at catalog level.

Example Hierarchy:

metalake
└── lance_catalog (catalog - create via REST)
    └── schema (namespace - create via REST)
        └── table01 (table - create via REST)

Delimiter Convention

The Lance REST API uses $ as the default delimiter to separate namespace levels in URIs. When making HTTP requests:

  • URL Encoding Required: $ must be URL-encoded as %24
  • Example: lance_catalog$schema$table01 becomes lance_catalog%24schema%24table01 in URLs

Common Delimiters:

Namespace path:     lance_catalog.schema.table01
URI representation: lance_catalog$schema$table01  
URL encoded:        lance_catalog%24schema%24table01

:::caution Important Limitations

  • Supports only two levels of namespaces before tables
  • Tables cannot be nested deeper than schema level
  • Parent catalog must be created in Gravitino before using Lance REST API
  • Namespace deletion defaults to restrict; use cascade to remove child metadata
  • Lance branches and tags are not implemented; a request setting branch or tag is rejected with HTTP 400 :::

Error responses

Malformed requests and backend validation errors return HTTP 400 without stack traces in detail, regardless of gravitino.lance-rest.includeErrorStackTrace. Details explicitly supplied by a backend Lance exception are preserved. Expected backend client errors are logged at INFO; server failures are logged at ERROR with the original exception for diagnosis.

Unrecognized or unimplemented routes under the Lance REST servlet return HTTP 406 with Lance error code 0 (Unsupported), allowing clients to select a fallback. The error identifies the HTTP method and path. Parameter conversion failures remain HTTP 400 (InvalidInput); missing tables and namespaces reported by operation handlers retain HTTP 404 and their entity-specific codes.

Authentication and authorization

Authentication and deployment modes

Lance REST uses Gravitino's gravitino.authenticators configuration for incoming requests in both auxiliary and standalone mode. See Authentication for configuring the authenticators and their credentials. Health check endpoints bypass authentication. Authentication errors use the Lance JSON error format; unsupported credentials return HTTP 401. In standalone mode, backend authentication and authorization failures retain HTTP 401 and 403 respectively. Authentication/authorization failures do not include internal stack traces in detail. Unexpected failures return HTTP 500 with a generic message; the server logs retain the exception for diagnosis.

Mode Identity used for Gravitino metadata operations Metadata authorization
Auxiliary (running with Gravitino) Authenticated caller, including active roles; anonymous requests fall back to gravitino.lance-rest.gravitino-simple.user-name (default lance-rest-server) Enabled by gravitino.authorization.enable=true with a configured metalake
Standalone Configured service credentials (gravitino.lance-rest.gravitino-auth-type and its simple/OAuth2 settings) No Lance REST per-user metadata authorization; the remote Gravitino server checks the service identity if its authorization is enabled

The auxiliary fallback applies only after authentication accepts an anonymous request. It does not recover a rejected authentication attempt. Authenticated callers keep their own privileges, active roles, ownership and audit identity; they do not inherit the service user's privileges. The fallback service user itself needs the privileges required by the requested operation. Setting gravitino.lance-rest.gravitino-simple.user-name explicitly is optional in auxiliary mode; configure it only to override the default anonymous fallback identity, lance-rest-server.

With simple authentication, a Basic header supplies a user name without validating a password, and a request without credentials is accepted as anonymous. Some malformed Basic credentials also resolve to anonymous. Use an authenticator that validates credentials when caller identity must be verified; simple is not password authentication.

Standalone authenticates incoming requests, but does not forward their identities or active roles to its Gravitino backend. All callers use the configured backend service identity. Standalone per-user authorization and scoped temporary credential vending are outside the supported scope. The backend service identity needs privileges for all underlying Gravitino calls, including existence checks performed before mutations (for example, catalog access before creating a namespace).

Enable auxiliary metadata authorization

Configure ${GRAVITINO_HOME}/conf/gravitino.conf:

gravitino.auxService.names = lance-rest
gravitino.lance-rest.gravitino-metalake = my_metalake
gravitino.authorization.enable = true
gravitino.authorization.serviceAdmins = adminUser
# Development example: simple accepts the supplied user name without password validation.
gravitino.authenticators = simple

Create the metalake, add users, and grant roles through the Gravitino API as described in Access Control. The Lance service exposes this configured metalake: a one-level namespace identifies a catalog, a two-level namespace identifies a schema, and a three-level table identifier identifies a table.

Requests may set X-Gravitino-Active-Roles to ALL (also the default when omitted), NONE, or a comma-separated list of assigned role names; see Role Names Outside ASCII for names with non-ASCII characters. This selection reaches both operation checks and listing filters. Malformed selections return 400; selecting an unassigned role is forbidden. Ownership is independent of role selection, so NONE does not remove ownership privileges.

Required privileges

The following rules use the same Gravitino privileges and ownership rules as Iceberg REST authorization. Privileges can be inherited from ancestor scopes as described in Access Control. Service administrators and metalake owners can operate throughout the metalake; catalog owners can operate within their catalogs. Schema owners additionally need USE_CATALOG, and table owners need USE_CATALOG and USE_SCHEMA. The ownership alternatives below include these ancestor owners.

Namespace operation Required privileges or ownership
ListNamespaces at root Membership in the metalake; returns only accessible catalogs
ListNamespaces under a catalog; DescribeNamespace for a catalog; NamespaceExists for a catalog USE_CATALOG, or ownership
ListNamespaces under a schema; DescribeNamespace for a schema; ListTables USE_CATALOG and USE_SCHEMA, or ownership
NamespaceExists for a schema USE_CATALOG and either USE_SCHEMA or CREATE_SCHEMA, or ownership
CreateNamespace for a catalog (create, exist_ok) CREATE_CATALOG on the metalake, or metalake ownership
CreateNamespace for a schema (create, exist_ok) USE_CATALOG and CREATE_SCHEMA, or catalog/metalake ownership
CreateNamespace (overwrite); DropNamespace Ownership of the namespace or an ancestor
Table operation Required privileges or ownership
DescribeTable USE_CATALOG, USE_SCHEMA, and either SELECT_TABLE or MODIFY_TABLE, or ownership
TableExists Same as DescribeTable, or USE_CATALOG, USE_SCHEMA, and either PROBE_TABLE_LIKE or CREATE_TABLE
CreateTable (create, exist_ok); RegisterTable (create); DeclareTable USE_CATALOG, USE_SCHEMA, and CREATE_TABLE, or schema/ancestor ownership
CreateTable or RegisterTable (overwrite); AlterColumns; DropColumns USE_CATALOG, USE_SCHEMA, and MODIFY_TABLE, or ownership
DropTable; DeregisterTable Ownership of the table or an ancestor

CREATE_TABLE and PROBE_TABLE_LIKE authorize TableExists without authorizing DescribeTable. CREATE_TABLE alone does not authorize overwrite requests. The DropTable and DeregisterTable endpoints require ownership rather than MODIFY_TABLE. Similarly, namespace creation privileges do not authorize overwriting or dropping another owner's namespace. Creating a new table assigns ownership to the effective caller. exist_ok returning an existing table preserves its owner, even if no owner has been assigned. This also applies to direct Gravitino table creation with lance.creation-mode=EXIST_OK.

Listings and concealed objects

Namespace listings omit inaccessible catalogs and schemas. Table listings omit tables for which the caller has neither ownership nor SELECT_TABLE/MODIFY_TABLE. Filtering happens before pagination; hidden entries do not consume page slots. Access to the parent is checked separately.

When a caller lacks an endpoint's required privileges, the request returns 403, whether or not the target exists, without returning its stored metadata or location. An authorized caller can distinguish an existing object from a missing one (404). Concealment therefore does not mean that every inaccessible object returns 404.

Authorization governs metadata requests; engines access Lance data files directly. Responses can include configured storage credentials: namespace descriptions resolve secret properties, and table descriptions, creation and declaration responses return effective storage_options from catalog defaults and table overrides. These are shared configured credentials, not temporary credentials restricted to the caller's table privileges. Access to data files depends on the permissions of those credentials. Per-user, scoped credential vending is not implemented.

Authorization differences between deployment modes

:::warning Lance REST metadata authorization is currently supported only in auxiliary mode. Standalone mode is not recommended: its authorization decisions can differ from auxiliary mode and may produce unexpected results, even for the same user and privileges. Use auxiliary mode for deployments that require Lance REST authorization. :::

Auxiliary mode applies the Lance endpoint authorization rules and listing filters described above. Standalone mode does not apply this authorization pipeline. Instead, the remote Gravitino server checks each underlying REST call using its own rules and the backend identity described above. These checks do not provide equivalent Lance REST authorization: an operation allowed in one mode may be denied in the other, and ownership requirements and metadata visibility can also differ. Forwarding the caller's identity alone does not eliminate these differences.

Alignment of the authorization behavior is tracked in #13089.

Examples

The following examples demonstrate how to interact with Lance REST service using different programming languages and tools.

Prerequisites:

  • Gravitino server is running with Lance REST service enabled.
  • A metalake has been created in Gravitino.
# Create a catalog-level namespace
# mode: "create" | "exist_ok" | "overwrite" for create namespace/table; mode: "create" | "overwrite" for register table
curl -X POST http://localhost:9101/lance/v1/namespace/lance_catalog/create \
  -H 'Content-Type: application/json' \
  -d '{
    "id": ["lance_catalog"],
    "mode": "create"
  }'

# Create a schema namespace
# Note: %24 is URL-encoded '$' character used as delimiter
curl -X POST http://localhost:9101/lance/v1/namespace/lance_catalog%24schema/create \
  -H 'Content-Type: application/json' \
  -d '{
    "id": ["lance_catalog", "schema"],
    "mode": "create"
  }'

# Register an existing table
curl -X POST http://localhost:9101/lance/v1/table/lance_catalog%24schema%24table01/register \
  -H 'Content-Type: application/json' \
  -d '{
    "id": ["lance_catalog", "schema", "table01"],
    "location": "/tmp/lance_catalog/schema/table01",
    "mode": "create"
  }'

# Declare a table
curl -X POST http://localhost:9101/lance/v1/table/lance_catalog%24schema%24table04/declare \
  -H 'Content-Type: application/json' \
  -d '{
    "id": ["lance_catalog", "schema", "table04"],
    "location": "/tmp/lance_catalog/schema/table04"
  }'
  
# Create a table with schema, the schema is inferred from the Arrow IPC file
curl -X POST \
     "http://localhost:9101/lance/v1/table/lance_catalog%24schema%24table03/create" \
     -H 'Content-Type: application/vnd.apache.arrow.stream' \
     -H "x-lance-table-location: /tmp/lance_catalog/schema/table03" \
     -H "x-lance-table-properties: {}" \
     --data-binary "@${ARROW_FILE}"    
// Add dependency: implementation("org.lance:lance-namespace-core:0.11.1")

import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.lance.namespace.client.apache.ApiClient;
import org.lance.namespace.client.apache.api.TableApi;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

// Initialize allocator and namespace connection
private final BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);

Map<String, String> props = new HashMap<>();
props.put("uri", "http://localhost:9101/lance");
props.put("delimiter", "$");

LanceNamespace ns = LanceNamespace.connect("rest", props, allocator);

// Create catalog namespace
CreateNamespaceRequest createCatalogNsRequest = new CreateNamespaceRequest();
createCatalogNsRequest.addIdItem("lance_catalog");
createCatalogNsRequest.setMode("create");
ns.createNamespace(createCatalogNsRequest);

// Create schema namespace
CreateNamespaceRequest createSchemaNsRequest = new CreateNamespaceRequest();
createSchemaNsRequest.addIdItem("lance_catalog");
createSchemaNsRequest.addIdItem("schema");
createSchemaNsRequest.setMode("create");
ns.createNamespace(createSchemaNsRequest);

// Register a table
RegisterTableRequest registerTableRequest = new RegisterTableRequest();
registerTableRequest.setLocation("/tmp/lance_catalog/schema/table01");
registerTableRequest.setId(Arrays.asList("lance_catalog", "schema", "table01"));
registerTableRequest.setMode("create");
ns.registerTable(registerTableRequest);

// Declare a table
DeclareTableRequest declareTableRequest = new DeclareTableRequest();
declareTableRequest.setLocation("/tmp/lance_catalog/schema/table02");
declareTableRequest.setId(Arrays.asList("lance_catalog", "schema", "table02"));
ns.declareTable(declareTableRequest);

// Create a table with schema inferred from Arrow IPC file.
// For REST create API, location/properties are passed via headers.
org.apache.arrow.vector.types.pojo.Schema schema =
        new org.apache.arrow.vector.types.pojo.Schema(
                Arrays.asList(
                        Field.nullable("id", new ArrowType.Int(32, true)),
                        Field.nullable("value", new ArrowType.Utf8())));
byte[] body = ArrowUtils.generateIpcStream(schema);
TableApi tableApi = new TableApi(new ApiClient().setBasePath("http://localhost:9101/lance"));
Map<String, String> createTableHeaders = new HashMap<>();
createTableHeaders.put("x-lance-table-location", "/tmp/lance_catalog/schema/table03");
createTableHeaders.put("x-lance-table-properties", "{}");
tableApi.createTable(
    "lance_catalog$schema$table03", body, "$", "create", createTableHeaders);
# Install: pip install lance-namespace==0.11.1

import lance_namespace as ln
import requests

# Connect to Lance REST service
ns = ln.connect("rest", {"uri": "http://your_lance_rest:9101/lance"})

# Create catalog namespace
create_catalog_ns_request = ln.CreateNamespaceRequest(id=["lance_catalog"])
catalog = ns.create_namespace(create_catalog_ns_request)

# Create schema namespace
create_schema_ns_request = ln.CreateNamespaceRequest(id=["lance_catalog", "schema"])
schema = ns.create_namespace(create_schema_ns_request)

# Register a table
register_table_request = ln.RegisterTableRequest(
    id=['lance_catalog', 'schema', 'table01'],
    location='/tmp/lance_catalog/schema/table01'
)
ns.register_table(register_table_request)

# Declare a table
declare_table_request = ln.DeclareTableRequest(
    id=['lance_catalog', 'schema', 'table02'],
    location='/tmp/lance_catalog/schema/table02'
)
ns.declare_table(declare_table_request)

# Create a table with schema inferred from Arrow IPC file.
# For REST create API, location/properties are passed via headers.
with open('schema.ipc', 'rb') as f:
    body = f.read()

response = requests.post(
    "http://your_lance_rest:9101/lance/v1/table/lance_catalog%24schema%24table03/create",
    params={"delimiter": "$", "mode": "create"},
    headers={
        "Content-Type": "application/vnd.apache.arrow.stream",
        "x-lance-table-location": "/tmp/lance_catalog/schema/table03",
        "x-lance-table-properties": "{}",
    },
    data=body,
    timeout=30,
)
response.raise_for_status()

Integration with Lance REST

To use the Lance REST service with Apache Spark, Ray and other engines, refer to lance-rest-integration for more details.