Skip to main content

Python client for HJS API - A Protocol for Structural Traceability

Project description

中文 | English

HJS Python Client

License: MIT Python Version

Python client for HJS API — a responsibility tracing service.

📦 Installation

From PyPI (when published)

pip install hjs-client

From GitHub (current)

pip install git+https://github.com/schchit/hjs-api.git#subdirectory=client-py

From local source

cd /workspaces/hjs-api/client-py
pip install -e .

🚀 Quick Start

Basic Example

from hjs_client import HJSClient

# Create client
client = HJSClient()

# Record a judgment
result = client.record_judgment(
    entity="alice@bank.com",
    action="loan_approved",
    scope={"amount": 100000}
)
print("✅ Recorded:", result)

# Retrieve it
judgment = client.get_judgment(result['id'])
print("✅ Retrieved:", judgment)

Using Context Manager

from hjs_client import HJSClient

with HJSClient() as client:
    result = client.record_judgment("alice@bank.com", "test_action")
    print("✅ Recorded:", result)

Error Handling

from hjs_client import HJSClient
import requests

client = HJSClient()

try:
    result = client.record_judgment("alice@bank.com", "test_action")
    print("✅ Success:", result)
except ValueError as e:
    print("❌ Validation error:", e)
except requests.RequestException as e:
    print("❌ API error:", e)

📚 API Reference

HJSClient(base_url, timeout)

Create a new client instance.

Parameter Type Default Description
base_url str "https://hjs-api.onrender.com" API base URL
timeout int 30 Request timeout in seconds

record_judgment(entity, action, scope)

Record a judgment.

Parameter Type Required Description
entity str Who made the judgment
action str What action was judged
scope dict Optional additional context

Returns: { id, status, timestamp }

Raises:

  • ValueError: If required parameters are missing
  • requests.RequestException: If API request fails

get_judgment(id)

Retrieve a judgment by ID.

Parameter Type Required Description
id str Judgment ID from record_judgment

Returns: Complete judgment record

Raises:

  • ValueError: If ID is missing or not found
  • requests.RequestException: If API request fails

🧪 Testing

cd /workspaces/hjs-api/client-py
python -c "
from hjs_client import HJSClient
client = HJSClient()
result = client.record_judgment('test@example.com', 'test_action')
print('✅ Recorded:', result)
judgment = client.get_judgment(result['id'])
print('✅ Retrieved:', judgment)
"

Expected output:

✅ Recorded: {'id': 'jgd_...', 'status': 'recorded', 'timestamp': '...'}
✅ Retrieved: {'id': 'jgd_...', 'entity': 'test@example.com', 'action': 'test_action', ...}

📄 License

MIT © HJS Contributors

🤝 Contributing

Contributions are welcome! Please:

  • Open an Issue for bugs or suggestions
  • Submit Pull Requests for improvements

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

hjs_client-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hjs_client-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file hjs_client-0.1.0.tar.gz.

File metadata

  • Download URL: hjs_client-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hjs_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 430a05d169fa0f1d01335050996efd02aa69fe8a1a16c04f2ba9d60403de0798
MD5 ef6376fc992abbc6d1156c062ce760e1
BLAKE2b-256 068fa4844503dc9b14f9f3c1ee4c0b64fac4b4d89bdf666b958fc15aad6c41ae

See more details on using hashes here.

File details

Details for the file hjs_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hjs_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hjs_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ae0482f00e551452f2e3ee7d8aebeaa2e7ca9b2aaa9991163d59ebb55e1e5da
MD5 ae22450a38d2b6c6648571adcffb153a
BLAKE2b-256 cd2e92be7252ff0864acbbcc8072e560ad40843b9ea3a7e1210e722cb208e7b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page