Swan SDK

Overview

The Swan SDK is a Python toolkit designed to simplify interactions with the SwanChain API. It provides a streamlined interface for creating and managing computational tasks, retrieving hardware information, processing payments, and monitoring task statuses.

Installation

To install the Swan SDK, use the following command:

pip install swan-sdk

Alternatively, you can clone the repository from GitHub:

git clone https://github.com/swanchain/python-swan-sdk.git

Key Features

  • API Client Integration: Easily connect to the SwanChain API.

  • Data Models: Utilize pre-defined models for seamless data handling.

  • Task Management: Create, monitor, and manage computational tasks.

  • Payment Processing: Handle payments for computational resources.

  • Status Monitoring: Track the status of your tasks in real-time.

Getting Started

Here’s a basic example to help you get started with the Swan SDK:

import os
import swan

orchestrator = swan.resource(api_key='<SWAN_API_KEY>', service_name='Orchestrator')

result = orchestrator.create_task(
    app_repo_image='hello-world',
    wallet_address='<WALLET_ADDRESS>',
    private_key='<PRIVATE_KEY>',
)
task_uuid = result['id']
# Get task info
task_info = orchestrator.get_deployment_info(task_uuid=task_uuid)
print(task_info)

A sample output:

['https://krfswstf2g.anlu.loveismoney.fun', 'https://l2s5o476wf.cp162.bmysec.xyz', 'https://e2uw19k9uq.cp5.node.study']

The "hello-world" task is deployed to 3 computing providers, open any link in the browser

Hello World

For more detailed information and advanced usage, refer to the official documentation.

Documentation and Support

For comprehensive guides and support, visit the Swan SDK GitHub page. The repository includes detailed documentation, usage examples, and community support resources.


Last updated

Change request #234: update CP