lakeFS SDK

1.80.0 · active · verified Sat Apr 11

The `lakefs-sdk` is the low-level Python client for interacting with the lakeFS API. It provides direct access based on the OpenAPI specification, offering full control over API interactions. It is distinct from the higher-level `lakefs` SDK, which provides a more Pythonic interface for common operations. The library is actively maintained with frequent releases, currently at version 1.80.0.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure the `lakefs-sdk` client using environment variables and then list all available repositories. Ensure `LAKEFS_SERVER_ENDPOINT_URL`, `LAKEFS_ACCESS_KEY_ID`, and `LAKEFS_SECRET_ACCESS_KEY` are set in your environment.

import os
import lakefs_sdk
from lakefs_sdk.apis import RepositoriesApi
from lakefs_sdk.rest import ApiException

# Configure API client with credentials from environment variables
configuration = lakefs_sdk.Configuration(
    host=os.environ.get('LAKEFS_SERVER_ENDPOINT_URL', 'https://example.lakefs.io/api/v1'),
    username=os.environ.get('LAKEFS_ACCESS_KEY_ID', ''),
    password=os.environ.get('LAKEFS_SECRET_ACCESS_KEY', '')
)

# Create an API client instance
with lakefs_sdk.ApiClient(configuration) as api_client:
    # Create an instance of the Repositories API
    repositories_api = RepositoriesApi(api_client)

    try:
        # List repositories
        repos = repositories_api.list_repositories()
        print("Successfully connected to lakeFS!")
        print("Repositories:")
        for repo in repos.results:
            print(f"- {repo.id}")
    except ApiException as e:
        print(f"Error connecting to lakeFS or listing repositories: {e}")
        print("Ensure LAKEFS_SERVER_ENDPOINT_URL, LAKEFS_ACCESS_KEY_ID, and LAKEFS_SECRET_ACCESS_KEY are set.")

view raw JSON →