Skip to main content

Python SDK for Zarban

Project description

Zarban SDK

Logo

PyPI version License Python Versions

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:

  1. Mainnet: The production environment for the Zarban DeFi protocol.

    • Wallet API: https://wapi.zarban.io
    • Service API: https://api.zarban.io
  2. Testnet: A separate testing environment for the Zarban protocol.

    • Wallet API: https://testwapi.zarban.io
    • Service API: https://testapi.zarban.io

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.

from zarban.wallet.openapi_client import DefaultApi, ApiClient, Configuration

# Initialize the client
configuration = Configuration()
api_client = ApiClient(configuration)
api_instance = DefaultApi(api_client)

# Make a simple API call
response = api_instance.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:

from zarban.wallet.openapi_client.configuration import Configuration
from zarban.wallet.openapi_client.api_client import ApiClient
from zarban.wallet.openapi_client.api import DefaultApi
from zarban.wallet.openapi_client.models import SignUpRequest
from zarban.wallet.openapi_client.exceptions import ApiException

def signup_example():
    # Create and configure the Configuration object
    configuration = Configuration(
        host="https://wapi.zarban.io"
    )

    # Create an instance of the ApiClient with the configuration
    api_client = ApiClient(configuration)

    # Create an instance of the DefaultApi using the ApiClient
    api_instance = DefaultApi(api_client)

    # Prepare the signup request data
    signup_request = SignUpRequest(
        email="user@example.com",
        password="yourSecuredPassword",
    )

    try:
        # Call the signup API
        api_response = api_instance.auth_signup_post(signup_request)
        print("Confirmation link sent successful!")
        print(f"Message: {api_response.messages}")

    except ApiException as e:
        print(f"Exception when calling DefaultApi->auth_signup_post: {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

from zarban.wallet.openapi_client import Configuration

# Basic configuration with just the host URL
config = Configuration(host="https://wapi.zarban.io")

Authentication Options

The SDK supports multiple authentication methods:

  1. API Key Authentication:
config = 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"}
)
  1. Basic Authentication:
config = Configuration(
    host="https://wapi.zarban.io",
    username="your-username",
    password="your-password"
)

Advanced Configuration

config = 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

from zarban.service.openapi_client import StableCoinSystemApi, ApiClient, Configuration
from zarban.service.openapi_client.exceptions import ApiException

try:
    configuration = Configuration(host="https://api.zarban.io")
    api_client = ApiClient(configuration)
    stable_coin_system_api = StableCoinSystemApi(api_client)
    response = StableCoinSystemApi.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.

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

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

zarban-0.5.3.tar.gz (162.1 kB view details)

Uploaded Source

Built Distribution

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

zarban-0.5.3-py3-none-any.whl (549.1 kB view details)

Uploaded Python 3

File details

Details for the file zarban-0.5.3.tar.gz.

File metadata

  • Download URL: zarban-0.5.3.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

Hashes for zarban-0.5.3.tar.gz
Algorithm Hash digest
SHA256 0ddf61aa5087eb08f1e61032aa0c2d374f9aba0f3fdb02e04d3aa52dc1922f59
MD5 9e747e346261eeae82f2a7815148bdf2
BLAKE2b-256 22273ce6bbbfde101cc859e404c3b1b8871c5936567f97f583c4ed777e6d5353

See more details on using hashes here.

File details

Details for the file zarban-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: zarban-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 549.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for zarban-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b56f229037b0114ef8ec9487d1f7a604fa2e079bf58a8ee91c304c77520331f
MD5 617ace0679478039ea9ead8bc8437a8d
BLAKE2b-256 127f9ace443143b1c5bf761c10de8eed6f5fb9b0763f37f006df115b8d7a137e

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