Python SDK for Zarban
Project description
Zarban SDK
Zarban SDK is a Python interface for interacting with the Zarban DeFi protocol, enabling developers to seamlessly integrate lending and borrowing functionalities into their applications. This SDK simplifies complex DeFi operations by providing easy-to-use methods for lending assets, managing collateral, borrowing funds, and monitoring positions in the Zarban protocol.
Features
- Automated API Client Generation: Built using OpenAPI specification, ensuring type safety and up-to-date API compatibility
- Lending Operations: Easily deposit assets, view lending rates, and manage lending positions
- Borrowing Management: Streamlined methods for borrowing assets, managing collateral, and monitoring loan health
- Position Tracking: Real-time access to user positions, including borrowed amounts, collateral ratios, and liquidation thresholds
- Market Data: Simple methods to fetch current interest rates, available liquidity, and market statistics
- Type Safety: Full type hints support for Python static type checking
- Error Handling: Comprehensive error handling with detailed exceptions for DeFi operations
- Async Support: Asynchronous methods for improved performance in high-throughput applications
Environments
Zarban SDK supports two distinct environments:
-
Mainnet: The production environment for the Zarban DeFi protocol.
- Wallet API:
https://wapi.zarban.io - Service API:
https://api.zarban.io
- Wallet API:
-
Testnet: A separate testing environment for the Zarban protocol.
- Wallet API:
https://testwapi.zarban.io - Service API:
https://testapi.zarban.io
- Wallet API:
Be sure to use the appropriate environment configuration when interacting with the Zarban SDK.
Installation
pip install zarban
For development installation:
git https://github.com/zarbanio/zarban-py.git
cd zarban-py
pip install -e ".[dev]"
Quick Start
Zarban SDK provides access to two distinct APIs:
1. Wallet API (zarban.wallet)
The Wallet API handles user authentication and wallet management operations.
2. Service API(zarban.service)
The Zarban Service API provides access to core DeFi protocol operations.
import zarban.wallet.openapi_client as wallet
# Initialize the client
cfg = wallet.Configuration()
api_client = wallet.ApiClient(cfg)
auth_api = wallet.AuthApi(api_client)
# Make a simple API call
response = auth_api.some_method()
print(response)
Usage Examples
For detailed usage examples, see our Examples Documentation.
Advanced Usage
Here's a simple example to sign up and get started with Zarban:
import zarban.wallet.openapi_client as wallet
def signup_example():
# Create and configure the Configuration object
cfg = wallet.Configuration(
host="https://testwapi.zarban.io"
)
# Create an instance of the ApiClient with the configuration
api_client = wallet.ApiClient(configuration=cfg)
# Create an instance of the AuthApi using the api_client
auth_api = wallet.AuthApi(api_client)
# Prepare the signup request data
signup_request = wallet.SignUpRequest(
email="user@example.com",
password="yourSecuredPassword",
)
try:
# Call the signup API
api_response = auth_api.signup_with_email_and_password(signup_request)
print("Confirmation link sent successfully!")
print(f"Message: {api_response.messages}")
except wallet.ApiException as e:
print(f"Exception when calling auth_api->signup_with_email_and_password: {e}")
print(f"Error message: {e.body}")
if __name__ == "__main__":
signup_example()
Configuration
The SDK can be configured with various options to customize its behavior and authentication methods.
Basic Configuration
import zarban.wallet.openapi_client as wallet
# Basic configuration with just the host URL
cfg = wallet.Configuration(host="https://wapi.zarban.io")
Authentication Options
The SDK supports multiple authentication methods:
- API Key Authentication:
cfg = Configuration(
host="https://wapi.zarban.io",
api_key={"APIKeyAuth": "your-api-key-here"},
# Optional: Add prefix like 'Bearer' for the API key
api_key_prefix={"APIKeyAuth": "Bearer"}
)
- Basic Authentication:
cfg = Configuration(
host="https://wapi.zarban.io",
username="your-username",
password="your-password"
)
Advanced Configuration
cfg = Configuration(
host="https://wapi.zarban.io",
api_key={"APIKeyAuth": "your-api-key-here"},
# Discard unknown properties from server responses
discard_unknown_keys=True
)
Configuration Parameters
| Parameter | Type | Description |
|---|---|---|
host |
str | Base URL for the API endpoints |
api_key |
dict | Dictionary of API keys where key is the security scheme name and value is the API key |
api_key_prefix |
dict | Dictionary of API key prefixes (e.g., "Bearer") |
username |
str | Username for HTTP basic authentication |
password |
str | Password for HTTP basic authentication |
discard_unknown_keys |
bool | Whether to discard unknown properties from server responses |
Error Handling
import zarban.service.openapi_client as service
try:
cfg = service.Configuration(host="https://api.zarban.io")
api_client = service.ApiClient(cfg)
stable_coin_system_api = service.StableCoinSystemApi(api_client)
response = stable_coin_system_api.some_method()
except ApiException as e:
print(f"An error occurred: {e}")
Development
Setting Up Development Environment
# Clone the repository
git clone https://github.com/zarbanio/zarban-py.git
cd zarban-py
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a new branch
- Make your changes
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Create an issue on GitHub
- Email: info@zarban.io
- Documentation: https://docs.zarban.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zarban-0.5.7.tar.gz.
File metadata
- Download URL: zarban-0.5.7.tar.gz
- Upload date:
- Size: 162.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5928f757d98fc9b3dbeb520e8024c9d4849c339a2fcafc47cca1f5a45f34e44c
|
|
| MD5 |
bcb1cdf5c4d760cbfbb9ff2e06a53a70
|
|
| BLAKE2b-256 |
bac1f780f99489a7632f6ac0dcd388f0cc28b8314f3920f4bda4b182148cc415
|
File details
Details for the file zarban-0.5.7-py3-none-any.whl.
File metadata
- Download URL: zarban-0.5.7-py3-none-any.whl
- Upload date:
- Size: 548.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c7859221d7fe8e7655ff3114a2c9bc7a3441062e0a3c8c057b30233acef98e2
|
|
| MD5 |
14f83d235ffa59d48bf2f3a53f15b8f0
|
|
| BLAKE2b-256 |
0f86fcbb12af37e6f1ae442ebb937655cfa9189ca80d22800873732ce4646330
|