Neptune API Client

0.26.0 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the low-level Neptune API client and perform a basic authenticated call to retrieve the current user's identity. This library is generally used internally by the `neptune` client, so direct interaction often requires a deeper understanding of the specific API endpoints and their corresponding request/response models. Ensure `NEPTUNE_API_TOKEN` is set as an environment variable or replaced directly.

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}")

view raw JSON →