Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/capture_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CaptureOptions,
Commit,
FileInput,
License,
NftRecord,
NftSearchResult,
RegisterOptions,
Expand All @@ -39,7 +40,7 @@
UpdateOptions,
)

__version__ = "0.1.0"
__version__ = "0.2.0"

__all__ = [
# Main client
Expand All @@ -53,6 +54,7 @@
"Asset",
"Commit",
"AssetTree",
"License",
"AssetSearchOptions",
"AssetSearchResult",
"SimilarMatch",
Expand Down
27 changes: 26 additions & 1 deletion python/capture_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CaptureOptions,
Commit,
FileInput,
License,
NftRecord,
NftSearchResult,
RegisterOptions,
Expand Down Expand Up @@ -544,10 +545,28 @@ def get_asset_tree(self, nid: str) -> AssetTree:
"headline",
"license",
"mimeType",
"nftRecord",
"usedBy",
"integrityCid",
"digitalSourceType",
"miningPreference",
"generatedBy",
}

extra = {k: v for k, v in merged.items() if k not in known_fields}

# Parse license field - can be object or string
license_data = merged.get("license")
license_obj = None
if isinstance(license_data, dict):
license_obj = License(
name=license_data.get("name"),
document=license_data.get("document"),
)
elif isinstance(license_data, str):
# Backwards compatibility: treat string as license name
license_obj = License(name=license_data)

return AssetTree(
asset_cid=merged.get("assetCid"),
asset_sha256=merged.get("assetSha256"),
Expand All @@ -557,8 +576,14 @@ def get_asset_tree(self, nid: str) -> AssetTree:
location_created=merged.get("locationCreated"),
caption=merged.get("caption"),
headline=merged.get("headline"),
license=merged.get("license"),
license=license_obj,
mime_type=merged.get("mimeType"),
nft_record=merged.get("nftRecord"),
used_by=merged.get("usedBy"),
integrity_cid=merged.get("integrityCid"),
digital_source_type=merged.get("digitalSourceType"),
mining_preference=merged.get("miningPreference"),
generated_by=merged.get("generatedBy"),
extra=extra,
)

Expand Down
48 changes: 41 additions & 7 deletions python/capture_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,31 @@ class Commit:
"""Description of the action."""


@dataclass
class License:
"""License information for an asset."""

name: str | None = None
"""License name (e.g., 'CC BY 4.0')."""

document: str | None = None
"""URL to the license document."""


@dataclass
class AssetTree:
"""Merged asset tree containing full provenance data."""
"""
Merged asset tree containing full provenance data.

Follows the Numbers Protocol AssetTree specification.
See: https://docs.numbersprotocol.io/introduction/numbers-protocol/defining-web3-assets/assettree
"""

asset_cid: str | None = None
"""Asset content identifier."""
"""Asset content identifier (IPFS CID)."""

asset_sha256: str | None = None
"""SHA-256 hash of the asset."""
"""SHA-256 hash of the asset file."""

creator_name: str | None = None
"""Creator's name."""
Expand All @@ -136,22 +152,40 @@ class AssetTree:
"""Creator's wallet address."""

created_at: int | None = None
"""Creation timestamp."""
"""Unix timestamp when asset was created."""

location_created: str | None = None
"""Location where asset was created."""

caption: str | None = None
"""Asset description."""
"""Asset description/abstract."""

headline: str | None = None
"""Asset title."""

license: str | None = None
license: License | None = None
"""License information."""

mime_type: str | None = None
"""MIME type."""
"""MIME type (encodingFormat)."""

nft_record: str | None = None
"""NFT record CID (if asset has been minted as NFT)."""

used_by: str | None = None
"""URL of website that uses the asset."""

integrity_cid: str | None = None
"""IPFS CID of the integrity proof."""

digital_source_type: str | None = None
"""Digital source type (e.g., digitalCapture, trainedAlgorithmicMedia)."""

mining_preference: str | None = None
"""Mining/indexing preference."""

generated_by: str | None = None
"""AI/algorithm information for generated content."""

extra: dict[str, Any] = field(default_factory=dict)
"""Additional fields from commits."""
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "capture-sdk"
version = "0.1.0"
version = "0.2.0"
description = "Python SDK for Numbers Protocol Capture API"
readme = "README.md"
license = "MIT"
Expand Down
Loading