Neptune API Client
neptune-api is a low-level client library for accessing the Neptune API directly. It provides the underlying OpenAPI-generated client and protobuf models used by the higher-level `neptune` client library. As of version 0.26.0, it primarily serves as an internal dependency, receiving frequent updates, often monthly or bi-monthly, reflecting changes in the core Neptune API.
Warnings
- gotcha This library (`neptune-api`) is primarily an internal dependency for the main `neptune` client library. For most users, it is recommended to install and use the `neptune` library (`pip install neptune`) for a higher-level, more user-friendly experience.
- breaking Version 0.25.0 removed support for `protobuf` versions older than 4.0.0. If you are using an older `protobuf` version, this will cause dependency resolution issues or runtime errors.
- gotcha The `ApiClient` methods are often low-level, directly mapping to HTTP verbs and API endpoints (e.g., `post_create_run`, `get_project_details`). Interacting with them often requires detailed knowledge of the Neptune API's request/response structure and protobuf models.
- deprecated The `neptune-api` library is under continuous development, and internal API structures (like storage, ingestion APIs) are frequently updated. This can lead to breaking changes in specific service methods or models between minor versions, even without explicit 'breaking change' notes if used directly.
Install
-
pip install neptune-api
Imports
- ApiClient
from neptune_api.api.client import Client as ApiClient
- models
from neptune_api import models
- UnauthorizedException
from neptune_api.exceptions import UnauthorizedException
Quickstart
import os
from neptune_api.api.client import Client as ApiClient
from neptune_api.exceptions import UnauthorizedException
NEPTUNE_API_TOKEN = os.environ.get("NEPTUNE_API_TOKEN", "YOUR_API_TOKEN")
if NEPTUNE_API_TOKEN == "YOUR_API_TOKEN":
print("Please set the NEPTUNE_API_TOKEN environment variable or replace 'YOUR_API_TOKEN' directly.")
exit(1)
try:
# Initialize the low-level API client
api_client = ApiClient(api_token=NEPTUNE_API_TOKEN)
# Example: Get the current user's identity
# This is a basic authenticated call to verify setup.
user_identity = api_client.post_get_user_identity()
print(f"Successfully authenticated as user ID: {user_identity.id}")
# To interact with specific resources (e.g., runs, projects), you would use
# methods like `api_client.post_create_run` or `api_client.post_get_project_member_v2`
# along with corresponding models from `neptune_api.models`.
except UnauthorizedException:
print("Authentication failed. Please check your NEPTUNE_API_TOKEN.")
except Exception as e:
print(f"An error occurred: {e}")