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
timefield percoin— seeexamples/hyperliquid_candles.py.
Supported Datasets
| Chain | Dataset |
|---|---|
| Ethereum | Dataset.ETHEREUM or "ethereum-mainnet" |
| Binance Smart Chain | Dataset.BINANCE or "binance-mainnet" |
| Solana | Dataset.SOLANA or "solana-mainnet" |
| Hyperliquid (HyperCore fills) | Dataset.HYPERLIQUID_FILLS or "hyperliquid-fills" |
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 iterationquery.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
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 sqd_py-0.2.0.tar.gz.
File metadata
- Download URL: sqd_py-0.2.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
816ac6111eb6393527c4fe0ccd07317770c34bd66a71e967ce535b3db2968b41
|
|
| MD5 |
9985e846acc5c358c040ae889f4c12a4
|
|
| BLAKE2b-256 |
043e761a9281c3d3e99044391469120cd61ee3070b63b794099efe0be9734673
|
File details
Details for the file sqd_py-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sqd_py-0.2.0-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c568e85d118129e574dd4ddacf58c657144e178056303bfbb9c21cbdd81835b3
|
|
| MD5 |
1e569154e74b4d8f95e0d042ce6dcaac
|
|
| BLAKE2b-256 |
c3529c64db91bb0b47bc7c8c66b8beaaf8098ece0c85fe9c6ab248f1fb4d6bb0
|