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
Metadata
Release files for numbersprotocol-capture-sdk 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| numbersprotocol_capture_sdk-0.2.1.tar.gz | 11.8 kB | Without provenance | Details for numbersprotocol_capture_sdk-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| numbersprotocol_capture_sdk-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for numbersprotocol_capture_sdk-0.2.1-py3-none-any.whl |
Total release size: 26.2 kB
Release files / numbersprotocol_capture_sdk-0.2.1.tar.gz
| Download URL | numbersprotocol_capture_sdk-0.2.1.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a7e8b64d168640cea8d01d288e2cb700c44c1b74e39f90659000bc87adfc66d
|
|
BLAKE2b-256 checksum How to use checksums |
12258c70f695b3b8b03de212c3f481f0c23940092c2c81b244161727315cc0b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / numbersprotocol_capture_sdk-0.2.1-py3-none-any.whl
| Download URL | numbersprotocol_capture_sdk-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b29a93a0ce0cdc39cb6e3241b9e682340a402af737e0b850c347560c32d28db3
|
|
BLAKE2b-256 checksum How to use checksums |
e5aecb1245bd5f2a6cf7039fd1905df89721a13a7d1c110e287b2f066e4d7e20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for numbersprotocol-capture-sdk 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.