sqd_py
Python client for querying blockchain data from SQD Network.
Installation
pip install sqd_py
Install the fast extra to also pull in uvloop
(auto-enabled on import, not available on Windows):
pip install sqd_py[fast]
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
Prefetch is enabled by default (2 concurrent workers) whenever the end of the range
is known, and falls back to a single serial worker otherwise. Use prefetch_workers
to change the worker count, or pass prefetch_workers=1 to force the serial path:
async for block in query.with_progress(prefetch_workers=4):
pass
shards is still accepted as a deprecated alias for prefetch_workers.
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
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 iterationquery.with_progress(prefetch_workers=N)— with progress bar; prefetching on by default
Requirements
- Python 3.10+
- aiohttp >= 3.9.0
- tqdm >= 4.67.1
- orjson >= 3.10.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.4.0.tar.gz.
File metadata
- Download URL: sqd_py-0.4.0.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8183559c8c64d79909824810fe55aaae70cfb16e6ba4eb9b08cab1050ee71949
|
|
| MD5 |
9e3aa6a8912fb2d18a88513987c982b2
|
|
| BLAKE2b-256 |
8bb755e749c1775eb410e5cec59cdb66543b77286ba6fc3096b401f0db7a1f95
|
Provenance
The following attestation bundles were made for sqd_py-0.4.0.tar.gz:
Publisher:
publish.yml on shestakoven/sqd_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqd_py-0.4.0.tar.gz -
Subject digest:
8183559c8c64d79909824810fe55aaae70cfb16e6ba4eb9b08cab1050ee71949 - Sigstore transparency entry: 2436650326
- Sigstore integration time:
-
Permalink:
shestakoven/sqd_py@1a7f8275625dc26cf0666657c2ae986065f22d0a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shestakoven
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1a7f8275625dc26cf0666657c2ae986065f22d0a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sqd_py-0.4.0-py3-none-any.whl.
File metadata
- Download URL: sqd_py-0.4.0-py3-none-any.whl
- Upload date:
- Size: 39.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08bcd46e75a51a49b5f75244cac7a6a6290711143f82a078c5038009a956bf23
|
|
| MD5 |
c562fe53a8458cef26f3bde6c69878e8
|
|
| BLAKE2b-256 |
7ae8892b20bca6f871f41fc4f3a651e017cd780a1cdb7185915677d4db4de346
|
Provenance
The following attestation bundles were made for sqd_py-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on shestakoven/sqd_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqd_py-0.4.0-py3-none-any.whl -
Subject digest:
08bcd46e75a51a49b5f75244cac7a6a6290711143f82a078c5038009a956bf23 - Sigstore transparency entry: 2436650593
- Sigstore integration time:
-
Permalink:
shestakoven/sqd_py@1a7f8275625dc26cf0666657c2ae986065f22d0a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shestakoven
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1a7f8275625dc26cf0666657c2ae986065f22d0a -
Trigger Event:
workflow_dispatch
-
Statement type: