Skip to main content

Unofficial Python SDK for Ethos Network API

Project description

ethos-py

The unofficial Python SDK for Ethos Network API

First Python client for interacting with Ethos Network's on-chain reputation protocol.

PyPI version Python 3.9+ License: MIT


Installation

pip install ethos-py

Quick Start

from ethos import Ethos

# Initialize client
client = Ethos()

# Get a profile by Twitter handle
profile = client.profiles.get_by_twitter("vitalikbuterin")
print(f"{profile.twitter_handle}: {profile.credibility_score}")

# List all vouches
for vouch in client.vouches.list():
    print(f"{vouch.author_profile_id} vouched for {vouch.target_profile_id}")

# Get vouches for a specific profile
vouches = client.vouches.list(target_profile_id=123)

# Search users
users = client.profiles.search("ethereum")

Features

  • Simple, Pythonic API - Resource-based design (client.vouches.list())
  • Type hints everywhere - Full autocomplete and mypy support
  • Pydantic models - Validated, typed response objects
  • Auto-pagination - Iterate through all results seamlessly
  • Built-in rate limiting - Respects API limits automatically
  • Retry with backoff - Handles transient failures gracefully
  • Async support - async/await ready for high-performance apps

Usage

Profiles

from ethos import Ethos

client = Ethos()

# Get profile by ID
profile = client.profiles.get(123)

# Get profile by Ethereum address
profile = client.profiles.get_by_address("0x123...")

# Get profile by Twitter handle
profile = client.profiles.get_by_twitter("username")

# Search profiles
profiles = client.profiles.search("query", limit=20)

# List all profiles (auto-paginated)
for profile in client.profiles.list():
    print(profile.credibility_score)

Vouches

# List all vouches
vouches = client.vouches.list()

# Filter vouches
vouches = client.vouches.list(
    target_profile_id=123,      # Vouches received by profile
    author_profile_id=456,      # Vouches given by profile
)

# Iterate through all vouches (auto-pagination)
for vouch in client.vouches.list():
    print(f"Amount: {vouch.amount_wei} wei")

Reviews

# List all reviews
reviews = client.reviews.list()

# Filter by target
reviews = client.reviews.list(target_profile_id=123)

# Filter by sentiment
positive_reviews = client.reviews.list(score="positive")
negative_reviews = client.reviews.list(score="negative")

Markets (Reputation Trading)

# List reputation markets
markets = client.markets.list()

# Get specific market
market = client.markets.get(market_id=1)

print(f"Trust price: {market.trust_price}")
print(f"Distrust price: {market.distrust_price}")

Activities

# List all activities
activities = client.activities.list()

# Filter by type
vouch_activities = client.activities.list(activity_type="vouch")
review_activities = client.activities.list(activity_type="review")

Credibility Scores

# Get score for an address
score = client.scores.get("0x123...")
print(f"Score: {score.value}")
print(f"Level: {score.level}")  # "untrusted", "neutral", "trusted", etc.

Async Support

import asyncio
from ethos import AsyncEthos

async def main():
    async with AsyncEthos() as client:
        profile = await client.profiles.get(123)
        vouches = await client.vouches.list(target_profile_id=123)
        
asyncio.run(main())

Configuration

Environment Variables

# Optional: Custom client name (for rate limit tracking)
export ETHOS_CLIENT_NAME="my-app"

# Optional: Custom base URL
export ETHOS_API_BASE_URL="https://api.ethos.network/api/v2"

Client Options

from ethos import Ethos

client = Ethos(
    client_name="my-app",           # Identifies your app to Ethos
    rate_limit=0.5,                 # Seconds between requests
    timeout=30,                     # Request timeout
    max_retries=3,                  # Retry failed requests
)

Response Models

All responses are Pydantic models with full type hints:

from ethos.types import Profile, Vouch, Review

profile: Profile = client.profiles.get(123)

# Access typed attributes
profile.id                    # int
profile.address               # str
profile.twitter_handle        # Optional[str]
profile.credibility_score     # int
profile.score_level           # str
profile.created_at            # datetime

# Convert to dict
profile.model_dump()

# Convert to JSON
profile.model_dump_json()

Error Handling

from ethos import Ethos
from ethos.exceptions import (
    EthosAPIError,
    EthosNotFoundError,
    EthosRateLimitError,
    EthosValidationError,
)

client = Ethos()

try:
    profile = client.profiles.get(999999)
except EthosNotFoundError:
    print("Profile not found")
except EthosRateLimitError:
    print("Rate limited - slow down")
except EthosAPIError as e:
    print(f"API error: {e.status_code} - {e.message}")

Pagination

The SDK handles pagination automatically:

# This iterates through ALL vouches, fetching pages as needed
for vouch in client.vouches.list():
    process(vouch)

# Or get a specific page
page = client.vouches.list(limit=100, offset=200)

Development

# Clone the repo
git clone https://github.com/kluless13/ethos-python-sdk.git
cd ethos-python-sdk

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Type checking
mypy src/ethos

# Formatting
black src tests
ruff check src tests

Why This Exists

Ethos Network provides a REST API but no official Python SDK. This library fills that gap for:

  • Researchers analyzing on-chain reputation data
  • Data scientists building trust metrics
  • Developers integrating Ethos into Python applications
  • Analysts studying Web3 social dynamics

Related Projects


License

MIT License - see LICENSE for details.


Contributing

Contributions welcome! Please read CONTRIBUTING.md first.


Disclaimer

This is an unofficial SDK and is not affiliated with or endorsed by Ethos Network.

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

ethos_py-0.2.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

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

ethos_py-0.2.0-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file ethos_py-0.2.0.tar.gz.

File metadata

  • Download URL: ethos_py-0.2.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for ethos_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8f7522b7a44c31151838fcdc1f6855082e99792a36e35b095b6abbdd6d10c72f
MD5 134978c4e13a185f1318753ce6ebf139
BLAKE2b-256 e820cfa6f4a984362025a26feda67d321354bf83f692b5a2c0f69bbb7cc2d487

See more details on using hashes here.

File details

Details for the file ethos_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ethos_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for ethos_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b10443862e59de36b5c3e77dcf1abbf079a01b2a1e88c3c2142b675c1f85ed3
MD5 eeefb7befe9663d75ac6d80e5f32399c
BLAKE2b-256 64926fa4ad1d9665569c99847ddc20bbdfadacac4f07a47e615fc870f8b2f005

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