Skip to main content

Python SDK for interacting with the Albatross API

Project description

Albatross Python SDK

Pyright Type Checking

published: https://pypi.org/project/albatross-sdk/

A Python SDK for interacting with the Albatross API. This SDK provides a simple and intuitive way to manage categories and units in your Albatross instance.

Features

  • Easy authentication using ECDSA keypairs
  • Category management (create, update, list)
  • Unit operations
  • CSV data import support

Installation

pip install albatross-sdk

Prerequisites

  • Python 3.12 or higher
  • An Albatross instance and credentials
  • ECDSA keypair for authentication

Authentication

Generating a Keypair

Generate an ECDSA keypair using OpenSSL:

openssl ecparam -genkey -name prime256v1 -noout -out ecdsa_private_key.pem
openssl ec -in ecdsa_private_key.pem -pubout -out ecdsa_public_key.pem

Quick Start

from albatross_sdk.lib import AlbatrossSDK, CategoryData

# Initialize the client
private_key = AlbatrossSDK.load_private_key("path/to/your/private_key.pem")
instance_id = "your-instance-id"
client = AlbatrossSDK(
    instance=instance_id,
    private_key=private_key,
    base_url="https://your-albatross-instance.com"  # Optional
)

# Check API version
version = client.get_api_version()
print(f"Connected to Albatross API version: {version}")

# Create a category
category_data: CategoryData = {
    "unit": "user",
    "values": {
        "country_code": "US",
        "grade_level": 3,
        "user": "user-uuid"
    }
}

response = client.put_categories([category_data])
print(f"Category created: {response}")

Working with Categories

Single Category Operations

# Define a category
user_category: CategoryData = {
    "unit": "user",
    "values": {
        "country_code": "AT",
        "grade_level": 2,
        "user": "39e23058-b7da-4a79-b464-5b67b579a433"
    }
}

# Create or update the category
result = client.put_categories([user_category])

Bulk Import from CSV

# Import categories from a CSV file
client.put_categories_csv("path/to/categories.csv", "user")

Configuration Examples

# Multiple instance configuration
instances = {
    "prod": "c094dea1-8b01-11ef-9882-068cf85ff8bb",
    "staging": "22a06113-8b04-11ef-ade1-42010aac0020",
    "dev": "96757573-827b-11ef-9882-068cf85ff8bb",
}

# Initialize client with specific instance
client = AlbatrossSDK(
    instance=instances["prod"],
    private_key=private_key,
    base_url="https://api.albatross.com"
)

Development

Running Tests

python -m pytest

Type Checking

pyright .

Related Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

albatross_sdk-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

albatross_sdk-0.1.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file albatross_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: albatross_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for albatross_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0c4b3207aa2a725a3a52d6913d29326c4c41ee5385d10ae63b9c9dcc09919297
MD5 a8972e7d0e085676e7d9de038892ff49
BLAKE2b-256 31ce123fe51b4c1f338a9e9719456b08ee58f0c107d1f9e90df168fb59c26c6e

See more details on using hashes here.

File details

Details for the file albatross_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: albatross_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for albatross_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b0df35d0f2bc97c8737e6fbbda5a088423e1351c8879f759d46cb251ec2885d
MD5 8d784a54f6194f7a8dbdf46f2971a72c
BLAKE2b-256 f5bffedd0e31f104c5074d05d8423f29542e5ab70ab1581eb0deb13bd8ef8f6d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page