Skip to main content

A Python client for interacting with the SentiChain API

Project description

SentiChain Python Client

A lightweight Python client to interact with the SentiChain REST API.

This library provides convenience methods for:

  • API Management: Retrieve user information (e.g., remaining points).
  • Block Explorer: Get chain length, last block time, total transactions, etc.
  • Event Map: Retrieve event map data for specified block ranges.
  • Observation: Retrieve reasoning for specified ticker, summary type and block chunk end.

Table of Contents

Features

  • API Management
    • Fetch detailed user information, including points usage.
  • Block Explorer
    • Get chain length and last block time.
    • Retrieve total number of transactions.
    • Fetch the latest block or a specific block by number.
  • Event Map
    • Fetch maximum block number processed in the event map.
    • Retrieve “points” snapshots for a specific block or for a range of blocks.
  • Observation
    • Retrieve reasoning for specified ticker, summary type and block chunk end.

Requirements

  • Python 3.8+ (recommend)
  • requests library

Installation

Since this is a standalone Python file, you can simply:

  1. Clone or download this repository.
  2. Ensure you have requests installed:
    pip install requests
    
  3. Place client.py in your project, or install it as a local module.

Usage

Initializing the Client

from sentichain.client import Client

# If you have an API key:
api_key = "YOUR_SENTICHAIN_API_KEY"

# Initialize the client with the default SentiChain API URL
client = Client(api_key=api_key)

# Or override the base URL if needed:
# client = Client(base_url="https://some-other-domain.com", api_key=api_key)

Examples

This is an example of how you might use this client:

from sentichain.client import Client

def main():
    api_key = "YOUR_API_KEY"  # Replace with your real key
    client = Client(api_key=api_key)

    # Get user info
    user_info = client.get_user_info(user_id="12345", api_key=api_key)
    print("User info:", user_info)

    # Check chain length on testnet
    length = client.get_chain_length("testnet")
    print("Chain length:", length)

    # Fetch data for a specific block
    block_data = client.get_block_by_number(network="testnet", block_number=50)
    print("Block #50 data:", block_data)

    # Fetch reasoning for a specific ticker, summary type and block chunk end
    reasoning = client.get_reasoning_match_chunk_end(ticker="DOGE", summary_type="observation_public", user_chunk_end=200)
    print("Observation:", reasoning)

if __name__ == "__main__":
    main()

Supports

Contributions, bug reports, and feature requests are welcome! Feel free to email us at info@sentichain.com

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

sentichain-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

sentichain-0.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file sentichain-0.1.1.tar.gz.

File metadata

  • Download URL: sentichain-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for sentichain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d46f5619a1f2e45a0a477c74c341718e4a7d72187a6b74032eebe609961fe812
MD5 98c0ff560618930af242d3146330aded
BLAKE2b-256 cb3bd617691572783bfe7650c88f28e4bc1636064b21640aafa6ab309c3142e5

See more details on using hashes here.

File details

Details for the file sentichain-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sentichain-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for sentichain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3389915be7579ce2087120c7d53dc3b135f72a7c9dcf56c2b146000cdb8ee75
MD5 89fb4483cd77012027abaa96cc1ffb3f
BLAKE2b-256 4469f6baf29b3e2b0f784437877a9bbe4c4755cefd365bdec10ec658cee8e7b8

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