Python SDK for interacting with the Albatross API
Project description
Albatross Python SDK
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.2.tar.gz
(4.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file albatross_sdk-0.1.2.tar.gz.
File metadata
- Download URL: albatross_sdk-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c045fd0620e293b85a3df8c9cf800038c65c8cf8ba434929ca47df98bd5898
|
|
| MD5 |
14b35ef0ddaa709bb7adfde1aff9f4cf
|
|
| BLAKE2b-256 |
4444d9275c976f7178416e51b446d2c11bfce49828e136ff0e179dfa5411f8de
|
File details
Details for the file albatross_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: albatross_sdk-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
713e2038e72edaf2b372a993e960f4b3bd4c211ed742ca212e2272aac7680a66
|
|
| MD5 |
cc68dc9dff937cce171d54146de199ed
|
|
| BLAKE2b-256 |
e932e5833a7ec16d7f015da38fce43b6e7580442857dce6fa1daea3e025f2fb8
|