A Python client library for interacting with the Hub01 Shop API
Project description
Hub01 Shop Python Client
A Python client library for interacting with the Hub01 Shop API. This library provides an easy-to-use interface for managing projects, versions, tags, and users.
Features
- 🔍 Browse and search projects
- 📦 Manage project versions (create, update, delete)
- 🏷️ Work with project and version tags
- 👤 User profile and project management
- 🔐 API token authentication
- ✅ Full CRUD operations for project versions
Installation
pip install hub01-client
Quick Start
Basic Usage (Read-Only)
from hub01_client import HubClient
# Initialize client (no auth needed for read-only operations)
client = HubClient(base_url="https://hub01-shop.srgnis.com/api")
# List project types
types = client.project_types.list()
for t in types:
print(f"{t.name}: {t.description}")
# Search for projects
projects = client.projects.list(
search="minecraft",
project_type="mod",
per_page=10
)
for project in projects['data']:
print(f"{project.name} - {project.downloads} downloads")
# Get project details
project = client.projects.get("my-project-slug")
print(f"{project.name}: {project.description}")
# List project versions
versions = client.versions.list("my-project-slug")
for version in versions['data']:
print(f"Version {version.version} - {version.release_type}")
Authenticated Operations
To create, update, or delete project versions, you need an API token.
Getting Your API Token
- Log in to Hub01 Shop
- Go to your user profile
- Navigate to API Tokens
- Click Create API Token
- Provide a name and optional expiration date
- Copy the generated token
Using Authentication
from hub01_client import HubClient
from datetime import date
# Initialize with your API token
client = HubClient(
base_url="https://hub01-shop.srgnis.com/api",
token="your-api-token-here"
)
# Verify your token works
token_info = client.test_token()
print(f"Authenticated as: {token_info['user']['username']}")
Complete Workflow Example
Here's a complete example showing how to create, update, and manage a project version:
from hub01_client import HubClient
from datetime import date
import io
# Initialize authenticated client
client = HubClient(
base_url="https://hub01-shop.srgnis.com/api",
token="your-api-token-here"
)
# 1. Get your user's projects
user_projects = client.users.get_projects("your-username")
my_project = user_projects['data'][0]
print(f"Working with project: {my_project.name}")
# 2. Create a file to upload
with open("my-mod-v1.0.0.jar", "rb") as mod_file:
# 3. Create a new version
new_version = client.versions.create(
slug=my_project.slug,
name="Version 1.0.0 - Initial Release",
version="1.0.0",
release_type="release", # release, rc, beta, or alpha
release_date=date.today().isoformat(),
changelog="- Initial release\n- Added cool features\n- Fixed bugs",
files=[mod_file],
tags=["forge", "fabric"], # Optional version tags
dependencies=[ # Optional dependencies
{
"project": "dependency-slug",
"version": "2.0.0",
"type": "required", # required, optional, or embedded
"external": False
}
]
)
print(f"Created version: {new_version.version}")
print(f"Downloads URL: {new_version.files[0].url}")
# 4. Update the version
updated = client.versions.update(
slug=my_project.slug,
version="1.0.0",
name="Version 1.0.0 - Initial Release (Updated)",
release_type="release",
release_date=date.today().isoformat(),
changelog="- Initial release\n- Added cool features\n- Fixed bugs\n- Updated description"
)
print(f"Updated version: {updated.version}")
# 5. List all versions of the project
versions = client.versions.list(my_project.slug, order_by="release_date")
for v in versions['data']:
print(f"- {v.version} ({v.release_type}): {v.downloads} downloads")
# 6. Delete a version (if needed)
client.versions.delete(my_project.slug, "1.0.0")
Advanced Usage
Filtering and Pagination
# Advanced project search
projects = client.projects.list(
project_type="mod",
search="magic",
tags=["adventure", "magic"],
version_tags=["forge"],
order_by="downloads", # name, created_at, latest_version, downloads
order_direction="desc", # asc or desc
per_page=25, # 10, 25, 50, or 100
page=1
)
print(f"Total results: {projects['meta']['total']}")
print(f"Current page: {projects['meta']['current_page']}")
# Filter versions by tags
versions = client.versions.list(
"my-project",
tags=["forge", "1.20"],
order_by="release_date",
order_direction="desc"
)
Working with Tags
# List all project tags
tags = client.tags.list_project_tags(plain=True)
for tag in tags:
print(f"{tag.name} ({tag.slug})")
# Get specific tag details
tag = client.tags.get_project_tag("technology")
print(f"{tag.name}: {tag.icon}")
# List version tags
version_tags = client.tags.list_version_tags(plain=True)
Error Handling
from hub01_client import (
HubClient,
HubAPIException,
AuthenticationException,
NotFoundException,
ValidationException
)
try:
client = HubClient(base_url="...", token="invalid-token")
client.test_token()
except AuthenticationException as e:
print(f"Authentication failed: {e}")
except ValidationException as e:
print(f"Validation error: {e.message}")
print(f"Errors: {e.errors}")
except NotFoundException as e:
print(f"Resource not found: {e}")
except HubAPIException as e:
print(f"API error: {e}")
Running Tests
The integration test suite validates all client functionality:
# Run all tests (including authenticated tests)
python test_integration.py --username your-username --token your-token
# Or use credential files
echo "your-username" > username
echo "your-token" > api_key
python test_integration.py
# Run read-only tests without authentication
python test_integration.py --base-url https://hub01-shop.srgnis.com/api
The test suite covers:
- Project types listing
- Project tags listing
- Version tags listing
- Project listing and filtering
- Project search
- Version listing and filtering
- Version details
- Token validation (requires auth)
- User profile retrieval (requires auth)
- User projects listing (requires auth)
- Version creation (requires auth)
- Version update (requires auth)
- Version deletion (requires auth)
API Reference
For detailed API documentation, see the OpenAPI specification or visit the API documentation.
Project Structure
hub01_shop_clients/
├── hub01_client/ # Main client library
│ ├── __init__.py # Package exports
│ ├── client.py # Client classes
│ ├── models.py # Data models
│ └── exceptions.py # Custom exceptions
├── test_integration.py # Integration test suite
├── usage_example.py # Usage examples
├── api.json # OpenAPI specification
└── README.md # This file
Important Notes
Version Updates
When updating a project version, the API requires all of these fields even if you're only changing one:
nameversion(can be the same as current version)release_typerelease_date
Dependencies Format
Dependencies must be provided as a list of dictionaries with the following structure:
{
"project": "project-slug", # Required
"version": "1.0.0", # Optional
"type": "required", # Required: required, optional, or embedded
"external": False # Required: True for external, False for platform projects
}
Pagination
The per_page parameter only accepts: 10, 25, 50, or 100. Other values will result in a validation error.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 hub01_client-0.1.2.tar.gz.
File metadata
- Download URL: hub01_client-0.1.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d79a1ba098ecd969ca852653368f5e483fe472c13ffd3d4da2f11f2e8b79b2b
|
|
| MD5 |
c831986b369fb56a8cea39854754e593
|
|
| BLAKE2b-256 |
2a5f35dffd978a1a5fb63bc266d9d3ce970bb2abb3f032193bf5187de3da683c
|
Provenance
The following attestation bundles were made for hub01_client-0.1.2.tar.gz:
Publisher:
pypi_publish.yml on SrGnis/Hub01-Shop-API-libs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hub01_client-0.1.2.tar.gz -
Subject digest:
1d79a1ba098ecd969ca852653368f5e483fe472c13ffd3d4da2f11f2e8b79b2b - Sigstore transparency entry: 949499578
- Sigstore integration time:
-
Permalink:
SrGnis/Hub01-Shop-API-libs@547093ceb6048c3c82a7cecac9bf6c78d385432e -
Branch / Tag:
refs/tags/python_0.1.2 - Owner: https://github.com/SrGnis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@547093ceb6048c3c82a7cecac9bf6c78d385432e -
Trigger Event:
release
-
Statement type:
File details
Details for the file hub01_client-0.1.2-py3-none-any.whl.
File metadata
- Download URL: hub01_client-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a114c969f8ebc6ac2ac63f76dd568c7ff11efef30d8a4ff0fed9dc51dd76ba95
|
|
| MD5 |
a0b64abe2ffccffa5054435bd3566bcd
|
|
| BLAKE2b-256 |
e45cf1220f7688f809cf1a6de60abe59b60f87bf3f3e86e1a23c556bb05197b7
|
Provenance
The following attestation bundles were made for hub01_client-0.1.2-py3-none-any.whl:
Publisher:
pypi_publish.yml on SrGnis/Hub01-Shop-API-libs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hub01_client-0.1.2-py3-none-any.whl -
Subject digest:
a114c969f8ebc6ac2ac63f76dd568c7ff11efef30d8a4ff0fed9dc51dd76ba95 - Sigstore transparency entry: 949499658
- Sigstore integration time:
-
Permalink:
SrGnis/Hub01-Shop-API-libs@547093ceb6048c3c82a7cecac9bf6c78d385432e -
Branch / Tag:
refs/tags/python_0.1.2 - Owner: https://github.com/SrGnis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_publish.yml@547093ceb6048c3c82a7cecac9bf6c78d385432e -
Trigger Event:
release
-
Statement type: