Python SDK for interacting with the Albatross API
Project description
Albatross Python 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 # Replace with actual package name once published
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.0.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.0.tar.gz.
File metadata
- Download URL: albatross_sdk-0.1.0.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 |
25663ab3b2419c48fc6758dc05ea6c10005faab2735fbfe3cdb877c27b8f984d
|
|
| MD5 |
5994697755646f1ff7be0f70249d653c
|
|
| BLAKE2b-256 |
9c3139fc0402b1132b4a019271bcc4bd715a2d966ee1f8f54e4cd38851d1139b
|
File details
Details for the file albatross_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: albatross_sdk-0.1.0-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 |
d500187bc2059038d0639b20a8986dd1f78b142f30e5953d8288e2681ab62131
|
|
| MD5 |
87b0b8444e61a9b36c536e39b3cebc73
|
|
| BLAKE2b-256 |
40eecd8c80d330155e4e11135159597493492c54eff83f4d011b279ace9881f0
|