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.3.tar.gz
(4.9 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.3.tar.gz.
File metadata
- Download URL: albatross_sdk-0.1.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ddc78867bed8a9b336a9211561f13e9fe81b62ddc6b1bf504801592bd0d3294
|
|
| MD5 |
5575ef16ce229ee98209b1b9e80c366d
|
|
| BLAKE2b-256 |
fbf78af1ccb48086b19e4224341e2b47ef08ea9c8ffc6e9f50b39ea9b386f8b7
|
File details
Details for the file albatross_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: albatross_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.0 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 |
b2062d2983c7808d0de944a025c10d2d29bee24b6bbe0e6e7710e473c2b54123
|
|
| MD5 |
bfbe7209bf9302cd38ef87abaa582b9d
|
|
| BLAKE2b-256 |
a1b64e73e291e95e41297ccb7a23c69c457ae2f98a2b0053ca38291dd1f4584a
|