Skip to main content

Python client for the Hashiverse decentralized social network

Project description

hashiverse-client

Python client for Hashiverse — your open-source decentralized X/Twitter replacement. Wraps the Rust hashiverse-lib via PyO3 for native performance.

test-hashiverse-client-python publish-hashiverse-client-python

Install

pip install hashiverse-client

Requires Python 3.9+. Pre-built wheels are published for Linux, macOS, and Windows.

Quick start

from hashiverse_client import HashiverseClient

client = HashiverseClient.create_from_keyphrase(
    key_phrase="my secret keyphrase",
    data_dir="~/.hashiverse",
    passphrase="my secret passphrase",  # encrypts key files at rest (default: "" = no encryption)
)

print(client.client_id)
client.post("Hello from Python! #hashiverse-python")

timeline = client.get_hashtag_timeline("hashiverse-python")
for post in timeline.posts:
    print(f"{post.client_id[:8]}: {post.post}")

What you can do

  • Create or reload a cryptographic identity from a key phrase, with optional at-rest encryption.
  • Post messages to the network.
  • Read hashtag timelines.
  • Fetch trending hashtags.
  • Persist keys to a local data directory and reconnect to the same identity later.

See examples/hello_hashiverse.py for an end-to-end walkthrough covering identity creation, key reload, timeline reads, and trending hashtags.

Reloading a stored identity

After create_from_keyphrase has run once, the key is persisted in data_dir. Subsequent runs can skip the keyphrase and reconnect via the stored key:

client = HashiverseClient.create_from_stored_key(
    client_id_hex=client_id,
    data_dir="~/.hashiverse",
    passphrase="my secret passphrase",  # must match the passphrase used to create the key
)

Connecting to a local server

By default the client uses the public bootstrap addresses. To point at a local cluster (handy for testing), pass bootstrap_addresses:

client = HashiverseClient.create_from_keyphrase(
    key_phrase="my example keyphrase",
    data_dir=data_dir,
    passphrase="my secret passphrase",
    bootstrap_addresses=["127.0.0.1:443"],
)

A local cluster can be started with the test harness from this repository — see the "Running the example" section below.


Developing this package

The rest of this document describes how to build, test, and release hashiverse-client itself. End-user usage is covered above.

Prerequisites

  • Python 3.9+
  • Rust nightly toolchain (see rust-toolchain.toml in the workspace root)

Development build

cd hashiverse-rust/hashiverse-client-python

# Create and activate a virtual environment
python -m venv .venv

# Windows
.venv\Scripts\activate

# Linux/macOS
source .venv/bin/activate

# Install maturin and build the extension into the venv
pip install maturin
maturin develop

maturin develop compiles the Rust code in debug mode and installs the resulting Python package into the active venv. Re-run it after any Rust code changes.

For a faster extension (recommended if exercising PoW or network operations):

maturin develop --release

Production build

To build a distributable wheel:

maturin build --release

The wheel is written to target/wheels/ and can be installed with:

pip install target/wheels/hashiverse_client-*.whl

Running tests

The test suite exercises offline client operations (no server required): identity creation, key management, and storage operations.

cd hashiverse-rust/hashiverse-client-python
source .venv/bin/activate  # or .venv\Scripts\activate on Windows
pip install pytest
maturin develop --release
python -m pytest tests/ -v

Running the example

The example connects to a local hashiverse server, creates an identity, fetches trending hashtags, and reads the #hashiverse timeline.

  1. Start a local server cluster using the test harness (in a separate terminal from the workspace root):
cd hashiverse-rust
cargo run -p hashiverse-integration-tests --bin test_harness
  1. Run the example:
cd hashiverse-rust/hashiverse-client-python
python examples/hello_hashiverse.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

hashiverse_client-1.0.8rc1-cp39-abi3-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

hashiverse_client-1.0.8rc1-cp39-abi3-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

hashiverse_client-1.0.8rc1-cp39-abi3-macosx_10_12_x86_64.whl (6.8 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file hashiverse_client-1.0.8rc1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for hashiverse_client-1.0.8rc1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4ebeb243d4931ebc13ff8638b206e9109f616e85686bc97c0a2417b03d72e9d4
MD5 bdc6f6aea5b2a3972e96d8b56d7134a4
BLAKE2b-256 3b99adae5e2e57f55ccf7e71d99dd694e1b04b9014624a2dbc28cea825d68261

See more details on using hashes here.

Provenance

The following attestation bundles were made for hashiverse_client-1.0.8rc1-cp39-abi3-win_amd64.whl:

Publisher: publish-hashiverse-client-python.yml on hashiverse/hashiverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2534858fc2e68de1ef0824f0f6a9e42a28d8e3d009520b5c82d409651d52374d
MD5 7b7c451baf4faf848f1aa957e0e4668e
BLAKE2b-256 a42f08f4925693d0d3b870c7fb698457ca6ca60303cdc77c7fc3db89a27149a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-hashiverse-client-python.yml on hashiverse/hashiverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d0a92e7d637371e22de9a911f189f53f18e0c25ff3a6f91c04bc33fcb0560f81
MD5 a43a444f15beb6cb16ada29efcdf92f9
BLAKE2b-256 fe3273737bfbaf47977ea0890899750f63225450a05412a2fa5af39fd4f80c89

See more details on using hashes here.

Provenance

The following attestation bundles were made for hashiverse_client-1.0.8rc1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-hashiverse-client-python.yml on hashiverse/hashiverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hashiverse_client-1.0.8rc1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hashiverse_client-1.0.8rc1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fdf7d1ad43a9a7ce59a07d0553839fa5bb5e254bfd0450116060f9b7fc50aa51
MD5 7b0844da6e6d51f01ffb1f3497eacce6
BLAKE2b-256 890e6106b6cf60859249ad61b0c78063664138ab2f043cf2be236cd82d8693e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for hashiverse_client-1.0.8rc1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish-hashiverse-client-python.yml on hashiverse/hashiverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hashiverse_client-1.0.8rc1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for hashiverse_client-1.0.8rc1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8fa59dc22a6596d729ce93c7036aee15a3b4f13e62819f2de776c840ede632cb
MD5 95f7b0e44705f2aa5c53a3ee3c85bcf4
BLAKE2b-256 b51d6961013a86b6b26e6e09843a4a4c97a4c4c0c0c0ab35f671ead38a7aeda1

See more details on using hashes here.

Provenance

The following attestation bundles were made for hashiverse_client-1.0.8rc1-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-hashiverse-client-python.yml on hashiverse/hashiverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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