Python SDK for Numbers Protocol Capture API
Project description
Capture SDK (Python)
Python SDK for the Numbers Protocol Capture API. Register and manage digital assets with blockchain-backed provenance.
Installation
pip install numbersprotocol-capture-sdk
Quick Start
from numbersprotocol_capture import Capture
# Initialize client
capture = Capture(token="your-api-token")
# Register an asset
asset = capture.register("./photo.jpg", caption="My photo")
print(f"Registered: {asset.nid}")
# Retrieve asset
asset = capture.get(asset.nid)
print(f"Filename: {asset.filename}")
# Update metadata
updated = capture.update(
asset.nid,
caption="Updated caption",
commit_message="Fixed typo"
)
# Get commit history
history = capture.get_history(asset.nid)
for commit in history:
print(f"Action: {commit.action}, Author: {commit.author}")
# Get merged provenance data
tree = capture.get_asset_tree(asset.nid)
print(f"Creator: {tree.creator_name}")
File Input Types
The SDK accepts multiple file input formats:
# File path (string)
asset = capture.register("./photo.jpg")
# pathlib.Path
from pathlib import Path
asset = capture.register(Path("./photo.jpg"))
# Binary data (requires filename)
with open("photo.jpg", "rb") as f:
data = f.read()
asset = capture.register(data, filename="photo.jpg")
Optional Signing
For cryptographic signing of assets using EIP-191:
asset = capture.register(
"./photo.jpg",
sign={"private_key": "0x...your-private-key"}
)
Context Manager
Use as a context manager for automatic resource cleanup:
with Capture(token="your-token") as capture:
asset = capture.register("./photo.jpg")
API Reference
Capture(token, testnet=False, base_url=None)
Initialize the client.
| Parameter | Type | Description |
|---|---|---|
token |
str |
API authentication token |
testnet |
bool |
Use testnet (default: False) |
base_url |
str |
Custom API URL |
capture.register(file, **options)
Register a new asset.
| Parameter | Type | Description |
|---|---|---|
file |
FileInput |
File path, Path, or bytes |
filename |
str |
Required for binary input |
caption |
str |
Asset description |
headline |
str |
Title (max 25 chars) |
public_access |
bool |
IPFS pinning (default: True) |
sign |
dict |
{"private_key": "0x..."} |
capture.update(nid, **options)
Update asset metadata.
| Parameter | Type | Description |
|---|---|---|
nid |
str |
Numbers ID |
caption |
str |
Updated description |
headline |
str |
Updated title |
commit_message |
str |
Change description |
custom_metadata |
dict |
Custom fields |
capture.get(nid)
Retrieve a single asset by NID.
capture.get_history(nid)
Get commit history of an asset.
capture.get_asset_tree(nid)
Get merged provenance data.
Error Handling
from numbersprotocol_capture import (
CaptureError,
AuthenticationError,
NotFoundError,
ValidationError,
)
try:
asset = capture.get("invalid-nid")
except NotFoundError as e:
print(f"Asset not found: {e}")
except AuthenticationError as e:
print(f"Auth failed: {e}")
except CaptureError as e:
print(f"Error: {e.code} - {e.message}")
Requirements
- Python 3.10+
License
MIT
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 numbersprotocol_capture_sdk-0.2.1.tar.gz.
File metadata
- Download URL: numbersprotocol_capture_sdk-0.2.1.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a7e8b64d168640cea8d01d288e2cb700c44c1b74e39f90659000bc87adfc66d
|
|
| MD5 |
82e96382ab250e59f80faa59fc2bed96
|
|
| BLAKE2b-256 |
12258c70f695b3b8b03de212c3f481f0c23940092c2c81b244161727315cc0b5
|
File details
Details for the file numbersprotocol_capture_sdk-0.2.1-py3-none-any.whl.
File metadata
- Download URL: numbersprotocol_capture_sdk-0.2.1-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b29a93a0ce0cdc39cb6e3241b9e682340a402af737e0b850c347560c32d28db3
|
|
| MD5 |
6e95bb510c8deb0256f2c17b91bd42fe
|
|
| BLAKE2b-256 |
e5aecb1245bd5f2a6cf7039fd1905df89721a13a7d1c110e287b2f066e4d7e20
|