Skip to main content

GraphQL interface for Sia network components

Project description

SiaQL

A GraphQL interface for Sia network components: walletd, renterd, hostd.

Python Poetry License Documentation

Overview

SiaQL provides a unified GraphQL API layer for interacting with various Sia network components. It simplifies the process of querying and managing Sia nodes by providing:

📚 See GraphQL documentation: siaql-docs.netlify.app

Features

  • Unified API: Access walletd, renterd, and hostd through a single GraphQL endpoint
  • Type Safety: Fully typed schema with TypeScript/Python type definitions
  • Flexible Queries: Built-in support for filtering, sorting, and pagination
  • Interactive Documentation and Playground: GraphiQL interface with schema exploration
  • CLI Tool: Easy setup and management through command-line interface

Installation

Install SiaQL using pip:

pip install siaql

Quick Start

  1. Start the SiaQL server:
siaql
  1. Access the GraphiQL interface at http://localhost:9090/graphql by default.

  2. Start querying your Sia components!

Configuration

SiaQL can be configured through environment variables (.env file), command-line arguments:

Environment Variables

Variable Default Description
HOST 127.0.0.1 Server host address
PORT 9090 Server port
ENABLE_RENTERD true Enable/disable renterd integration
RENTERD_URL http://localhost:9981 Renterd API URL
RENTERD_PASSWORD None Renterd API password
ENABLE_WALLETD true Enable/disable walletd integration
WALLETD_URL http://localhost:9982 Walletd API URL
WALLETD_PASSWORD None Walletd API password
ENABLE_HOSTD true Enable/disable hostd integration
HOSTD_URL http://localhost:9983 Hostd API URL
HOSTD_PASSWORD None Hostd API password

Command Line Arguments

The same configuration options are available as command-line arguments:

siaql --host 127.0.0.1 --port 9090

Note: SiaQL can be started without any configuration, in which case it will ask for the API URLs and passwords interactively.

Compatibility

SiaQL is compatible with following versions of Sia components:

Component Version
Walletd v0.8.0
Renterd v1.1.1
Hostd v2.0.2

Example Queries

All queries are written as its respective Sia component. For example renterd_Contracts for Renterd contracts endpoint.

  1. Get Sorted Contracts
query GetSortedContracts {
  renterdContracts(
    sort: {
      field: "size"
      direction: DESC
    }
  ) {
    id
    size
    hostKey
    state
    totalCost
    spending {
      uploads
      downloads
      fundAccount
      deletions
      sectorRoots
    }
  }
}
  1. Get Reliable Hosts
query GetReliableHosts {
  renterdGetHosts(
    filter: {
      field: "interactions.successfulInteractions"
      operator: GT
      value: "100"
    }
    sort: {
      field: "interactions.uptime"
      direction: DESC
    }
    pagination: {
      offset: 0
      limit: 20
    }
  ) {
    publicKey
    netAddress
    interactions {
      successfulInteractions
      uptime
      lastScan
    }
  }
}

Development

Setup Development Environment

# Create a virtual environment if needed
# python3.9 -m venv venv

# Clone the repository
git clone https://github.com/justmert/siaql.git && cd siaql

# Tested with poetry 2.0.1
# pip install --upgrade poetry==2.0.1

# Install dependencies
poetry install

# Run tests
poetry run pytest

Acknowledgments

Disclaimer

This repository is a community effort and is not officially supported by the Sia Network.

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

siaql-0.1.1.tar.gz (59.3 kB view details)

Uploaded Source

Built Distribution

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

siaql-0.1.1-py3-none-any.whl (79.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: siaql-0.1.1.tar.gz
  • Upload date:
  • Size: 59.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.9.21 Darwin/24.1.0

File hashes

Hashes for siaql-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2caca3341457ad1cb64fca476ecfbd674212401905e1fe9f566491f03e058f52
MD5 32f6a80d5d0cb2e087cb4d445d448a72
BLAKE2b-256 a54912defd31e5c31d69709b2c10174fb813cf6695d0a63b6cbd5d6bea0668a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: siaql-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 79.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.9.21 Darwin/24.1.0

File hashes

Hashes for siaql-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17d0f82a25b3b04ce7364c5e9f742f7f76e6e8e996847332e593ad2c1ea49ec9
MD5 ee7b3ab5001326f30bc7c029b26a5fed
BLAKE2b-256 830f16cc1bbb4a92f64ada57fdfe0807bc9379f596f939f5c8979c90607d36ca

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