Introduction
Welcome to the official documentation for StralixSDK, the professional Python client for interacting with the Stralix Cloud SCNAC API.
StralixSDK provides a robust, type-safe, and easy-to-use interface for developers building applications on top of the Stralix blockchain infrastructure. It handles authentication, connection management, error parsing, and automatic retries, allowing you to focus on building your application.
Key Features
- Type-Safe: Full Python type hinting for better IDE support and fewer bugs.
- Robust: Automatic retries with exponential backoff for network stability.
- Developer Friendly: Context manager support for clean resource management.
- Secure: Built-in authentication handling for SCNAC API keys.
Installation
StralixSDK is available on PyPI and can be installed using pip:
pip install stralixsdk
Requirements: Python 3.6+
Quick Start
Here is a minimal example to get you started fetching blockchain data.
from stralixsdk import StralixClient
# Initialize the client
client = StralixClient(
api_key="YOUR_API_KEY",
base_url="https://sc01.stralix.cloud"
)
# Get info for Litecoin (LTC)
info = client.get_blockchain_info("LTC")
print(info)
Configuration
The StralixClient accepts several parameters for customization:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | Required | Your SCNAC API key. |
base_url |
str | Required | The URL of your SCNAC server (e.g., https://sc01.stralix.cloud). |
timeout |
int | 30 | Request timeout in seconds. |
retries |
int | 3 | Number of automatic retries for failed requests (50x errors). |
Error Handling
StralixSDK provides custom exceptions to help you handle errors gracefully. All exceptions inherit
from StralixSDKError.
from stralixsdk.exceptions import (
StralixAuthError,
StralixNotFoundError,
StralixConnectionError
)
try:
client.get_info("INVALID")
except StralixNotFoundError:
print("Ticker not found!")
except StralixAuthError:
print("Check your API key!")
except StralixConnectionError:
print("Network issue!")
Advanced Usage
Context Manager
Use the with statement to ensure the underlying session is closed automatically.
with StralixClient(api_key="...", base_url="...") as client:
client.get_info("LTC")
# Session is closed here
Blockchain Methods
Methods for querying blockchain state.
get_blockchain_info(ticker)
Returns an object containing various state info regarding blockchain processing.
get_info(ticker)
Returns an object containing various state info.
get_block_count(ticker)
Returns the number of blocks in the longest blockchain.
Block Methods
get_block(ticker, hash_or_height)
If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.
If verbosity is 1, returns an Object with information about block 'hash'.
get_block_hash(ticker, height)
Returns hash of block in best-block-chain at height provided.
Mining Methods
get_mining_info(ticker)
Returns a json object containing mining-related information.
get_network_hashps(ticker)
Returns the estimated network hashes per second based on the last n blocks.
Network Methods
get_peer_info(ticker)
Returns data about each connected network node as a json array of objects.
get_connection_count(ticker)
Returns the number of connections to other nodes.
Changelog
v1.1.5 Latest
- Removed debug prints from client.
- Restored standard retry logic.
v1.1.4
- Added debug prints for URL troubleshooting.
- Temporarily reduced retries for debugging.
v1.1.3
- Internal release for testing.
v1.1.0
- Major Upgrade: Added type hinting and docstrings.
- Added
StralixClientcontext manager support. - Added automatic retry logic with exponential backoff.
- Introduced custom exception classes in
stralixsdk.exceptions.
v1.0.0
- Initial release.
- Basic support for SCNAC v1 endpoints.