Skip to main content

sqd_py

Python client for querying blockchain data from SQD Network.

Installation

pip install sqd_py

Quick Start

import asyncio
from sqd import SQD, Dataset, EvmFields

async def main():
    sqd = SQD(dataset=Dataset.ETHEREUM)
    
    query = sqd.get_transactions(
        from_block=17_000_000,
        to_block=17_000_010,
        address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    )
    
    async for block in query:
        for tx in block.get("transactions", []):
            print(tx["hash"])

asyncio.run(main())

Usage

Querying Logs

query = sqd.get_logs(
    from_block=17_000_000,
    to_block=17_000_100,
    address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    topic0="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
)

async for block in query:
    for log in block.get("logs", []):
        print(log)

ERC-20 Transfers

query = sqd.get_transfers(
    from_block=17_000_000,
    to_block=17_100_000,
    contract_address="0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
)

async for block in query.with_progress():
    for log in block.get("logs", []):
        print(log)

Selecting Fields

query = sqd.get_transactions(
    from_block=17_000_000,
    to_block=17_000_010,
    include_fields=[
        EvmFields.TransactionField.hash,
        EvmFields.TransactionField.from_,
        EvmFields.TransactionField.gasUsed,
    ],
)

Chaining Queries

query = sqd.get_transactions(
    from_block=17_000_000,
    to_block=17_000_010,
    address="0x...",
).get_logs(
    address="0x...",
    topic0="0x...",
)

async for block in query:
    # block contains both transactions and logs
    pass

Progress Bar

async for block in query.with_progress():
    pass

The shards parameter enables an experimental prefetch window for historical data (values > 1 use a two-range prefetch; higher values are clamped and may be slower).

Hyperliquid (HyperCore fills)

The hyperliquid-fills dataset exposes individual perpetual-futures trade executions (fills). Every filter accepts a single value or a list (OR-match); different filters combine with AND.

from sqd import SQD, HyperliquidFields

sqd = SQD(dataset="hyperliquid-fills", stream_type="finalized")

query = sqd.get_fills(
    from_block=905_000_000,
    to_block=905_001_000,
    coin=["BTC", "ETH"],          # OR; or a single string for one coin
    include_fields=list(HyperliquidFields.FillField),
)

async for block in query:
    for fill in block.get("fills", []):
        print(fill["coin"], fill["px"], fill["sz"], fill["side"])

Available filters: coin, user, builder, dir, fee_token, cloid.

SQD does not serve OHLCV candles directly. Build them by bucketing fills by the time field per coin — see examples/hyperliquid_candles.py.

Supported Datasets

72 EVM chains (Ethereum, Arbitrum, Base, Optimism, Polygon, zkSync, and more — see Dataset for the full list), plus Solana and Hyperliquid:

Chain Dataset
Ethereum Dataset.ETHEREUM or "ethereum-mainnet"
Arbitrum One Dataset.ARBITRUM_ONE or "arbitrum-one"
Base Dataset.BASE or "base-mainnet"
Optimism Dataset.OPTIMISM or "optimism-mainnet"
Polygon Dataset.POLYGON or "polygon-mainnet"
Binance Smart Chain Dataset.BINANCE or "binance-mainnet"
Solana Dataset.SOLANA or "solana-mainnet"
Hyperliquid (HyperCore fills) Dataset.HYPERLIQUID_FILLS or "hyperliquid-fills"

Any other EVM dataset slug served by the SQD portal also works — pass it as a plain string (e.g. SQD(dataset="scroll-mainnet")) even without a matching Dataset member.

API

SQD

SQD(
    dataset: Dataset | str,
    portal_url: str = "https://portal.sqd.dev",
    stream_type: Literal["finalized", "realtime"] = "realtime",
)

Query Methods

EVM:

  • get_blocks(from_block, to_block, ...)
  • get_transactions(from_block, address, to_block, ...)
  • get_logs(from_block, address, topic0, to_block, ...)
  • get_transfers(from_block, contract_address, ...)
  • get_traces(from_block, to_block, ...)
  • get_state_diffs(from_block, to_block, ...)

Hyperliquid:

  • get_fills(from_block, to_block, coin, user, builder, dir, fee_token, cloid, ...)

Iteration

  • async for block in query — default iteration
  • query.with_progress(shards=N) — with progress bar and experimental prefetching

Requirements

  • Python 3.10+
  • aiohttp >= 3.9.0
  • tqdm >= 4.67.1
  • ujson >= 5.11.0

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqd_py-0.3.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

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

sqd_py-0.3.0-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file sqd_py-0.3.0.tar.gz.

File metadata

  • Download URL: sqd_py-0.3.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sqd_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f450d5d803a04d62e838cf3dd5b87e694e6ae1db150973fa6d0279ec48ef5a53
MD5 c895dbb9336cd02a38f702f8cd0163bd
BLAKE2b-256 b08e286bfa7451233d9f2199f5762654bdb42a8c18ff6cec08fddf8be1effc4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqd_py-0.3.0.tar.gz:

Publisher: publish.yml on shestakoven/sqd_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqd_py-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sqd_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sqd_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 178cfd4360465014e0c51639558b3677e759b2460f63d659044b17c5009d87c3
MD5 88a33eb55ccb4415da399851beee1bbd
BLAKE2b-256 0354aeb3d3abadf3705eb18ad22e4da5607e05858e2afdf03c7979304a2b5608

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqd_py-0.3.0-py3-none-any.whl:

Publisher: publish.yml on shestakoven/sqd_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.0

2 files

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page