Skip to main content

Solana ShredStream SDK for Python

Solana ShredStream SDK/Decoder for Python, enabling ultra-low latency Solana transaction streaming via UDP shreds from ShredStream.com

Part of the ShredStream.com ecosystem — ultra-low latency Solana shred streaming via UDP.

License: MIT Python

📋 Prerequisites

  1. Create an account on ShredStream.com
  2. Launch a Shred Stream and pick your region (Frankfurt, Amsterdam, Singapore, Chicago, and more)
  3. Enter your server's IP address and the UDP port where you want to receive shreds
  4. Open your firewall for inbound UDP traffic on that port (e.g. configure your cloud provider's security group)
  5. Install Python 3.10+:
    # Linux (Ubuntu/Debian)
    sudo apt update && sudo apt install -y python3 python3-venv python3-pip
    
    # macOS
    brew install python3
    

🎁 Want to try before you buy? Open a ticket on our Discord to request a free trial.

📦 Installation

# Create a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate

# Install the SDK
pip install shredstream

⚡ Quick Start

Create a file main.py:

from shredstream import ShredListener
from solders.transaction import VersionedTransaction
import os

PORT = int(os.environ.get("SHREDSTREAM_PORT", 8001))
listener = ShredListener.bind(PORT)

# Decoded transactions — ready-to-use Solana transactions
for slot, txs in listener:
    for raw in txs:
        tx = VersionedTransaction.from_bytes(raw)
        print(f"slot {slot}: {tx.signatures[0]}")

Each raw is the bincode wire-format encoding of a VersionedTransaction.

Transactions may be version 1 (leading byte 0x81); decode them with a library that supports it (solders 0.29 or later).

Run it:

python3 main.py

📖 API Reference

ShredListener

  • ShredListener.bind(port: int) -> ShredListener — Bind with defaults (64 MB recv buf, 3 slot window, FEC enabled)
  • ShredListener.bind_with_options(port, options: ListenerOptions) -> ShredListener — Custom configuration
  • ShredListener.offline() -> ShredListener — Bind on ephemeral port; drive via handle_packet
  • ShredListener.from_fd(fd: int, options=None) -> ShredListener — Adopt an existing UDP file descriptor
  • Iterator protocolfor slot, txs in listener: yields (int, list[bytes])
  • listener.shreds() -> ShredIter — Iterator yielding RawShred headers (no decode)
  • listener.handle_packet(data: bytes) -> tuple[int, list[bytes]] | None — Inject an externally-received UDP datagram
  • listener.local_addr() -> str — Bound socket address
  • listener.close() — Release the socket

ListenerOptions

ListenerOptions(
    recv_buf=64*1024*1024,
    max_age=3,
    busy_poll_us=200,
    busy_poll_disabled=False,
    pool_size=4096,
    enable_fec=True,
    disable_salvage_delivery=False,
    accumulator=AccumulatorConfig(),
)
Field Default Description
recv_buf 64 MB SO_RCVBUF size
max_age 3 Slot retention window
busy_poll_us 200 Linux SO_BUSY_POLL µs
busy_poll_disabled False Pass True to disable busy poll explicitly
pool_size 4096 Number of 2 KiB buffers in the zero-copy pool
enable_fec True Reed-Solomon recovery on dropped data shreds
disable_salvage_delivery False Drop salvaged tail txs for lowest p99
accumulator AccumulatorConfig() FEC and stuck-batch tuning

AccumulatorConfig

Field Default Description
max_fec_sets_per_slot 32 Per-slot FEC buffer cap
stuck_batch_timeout_ms 50 Force-finalize a stuck batch after this delay

Metrics

Read-only @property accessors on ShredListener:

Group Methods
Throughput data_shred_count_total, code_shred_count_total, bytes_received, slot_count
Decoder batches_decoded_streaming_total, batches_decoded_fallback_total, batches_skipped_total, decode_errors_total
FEC fec_recoveries_total, fec_recovery_failures_total, fec_sets_discarded_unused_total, fec_sets_evicted_early_total
Unparseable unparseable_packets, unparseable_too_short, unparseable_variant, unparseable_payload, unparseable_slot_range
Slot lifecycle slots_completed_total, slots_evicted_by_age, dropped_known_slots, harvested_batches_total, salvaged_tail_tx_total
Tail control batches_force_finalized_corrupted_total, batches_force_finalized_timeout_total
Pool / I-O pool_exhausted_count, last_io_error_kind, busy_poll_active

Helpers

  • shredstream.classify_variant(byte: int) -> VariantKind | None — Classify a shred variant byte
  • shredstream.pin_current_thread_to_cpu(cpu_id: int) -> None — Best-effort thread pinning. Linux: sched_setaffinity; macOS: hint; other: no-op

🎯 Use Cases

ShredStream.com shred data powers a wide range of latency-sensitive strategies — HFT, MEV extraction, token sniping, copy trading, liquidation bots, on-chain analytics, and more.

💎 PumpFun Token Sniping

ShredStream.com SDK detects PumpFun token creations ~499ms before they appear on PumpFun's live feed — tested across 25 consecutive detections:

ShredStream.com SDK vs PumpFun live feed — ~499ms advantage

Ready-to-run example included: see examples/pumpfun_creates.py. Run with python3 examples/pumpfun_creates.py [port].

⚙️ Configuration

OS Tuning

# Linux -- increase max receive buffer
sudo sysctl -w net.core.rmem_max=67108864
sudo sysctl -w net.core.busy_read=200

# macOS
sudo sysctl -w kern.ipc.maxsockbuf=67108864

Dependencies

  • solders>=0.21 — Required to decode the bincode-encoded transactions yielded by the iterator.

🚀 Launch a Shred Stream

Need a feed? Launch a Solana Shred Stream on ShredStream.com — sub-millisecond delivery, multiple global regions, 5-minute setup.

📄 License

MIT — ShredStream.com

Release files for shredstream 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shredstream 2.0.2
File Size Uploaded
shredstream-2.0.2.tar.gz 36.7 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for shredstream 2.0.2
File
shredstream-2.0.2-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
shredstream-2.0.2-cp38-abi3-manylinux_2_28_x86_64.whl CPython 3.8 abi3 Linux glibc 2.28+ x86-64 Details
shredstream-2.0.2-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details
shredstream-2.0.2-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 38.6 MB

Release files / shredstream-2.0.2.tar.gz

Download URL shredstream-2.0.2.tar.gz
Size 36.7 MB
Tags Source
SHA-256 checksum
How to use checksums
50662a33aea5e18bfe32b46b5d248d9d7cf41188e5fed84e520bd8ef8a4e0a61
BLAKE2b-256 checksum
How to use checksums
eddd8cf612cfaba24b903f655addd03313113c44b02f9499d99dffbacd870ea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / shredstream-2.0.2-cp38-abi3-win_amd64.whl

Download URL shredstream-2.0.2-cp38-abi3-win_amd64.whl
Size 415.1 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
32693248c9ea56935893f5945a1dc62d0610527e527308747d9016328b2d669a
BLAKE2b-256 checksum
How to use checksums
1f1b81bad4ba8cd9f4bbe6cb84d622cd339ad26c04b7b6b5707f72d45cb058ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / shredstream-2.0.2-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL shredstream-2.0.2-cp38-abi3-manylinux_2_28_x86_64.whl
Size 506.6 kB
Tags CPython 3.8 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
e886b59f15aacabe063a903f61eca9d405521fef3a31e908ca1ce9abbecb5fc5
BLAKE2b-256 checksum
How to use checksums
03e74eb9f7cce2cf7bd44adbc422ac637e2ac9d99f5815d9d7116a21c2d24fed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / shredstream-2.0.2-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL shredstream-2.0.2-cp38-abi3-manylinux_2_28_aarch64.whl
Size 482.2 kB
Tags CPython 3.8 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
308fd6060455662549c39ef04a84fc49eb929255c196085dd3266a0a5322eb81
BLAKE2b-256 checksum
How to use checksums
5fbc17706b83403653294f5a92b287e8c21424905c1bbd552b1b90d6fd323ec3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / shredstream-2.0.2-cp38-abi3-macosx_11_0_arm64.whl

Download URL shredstream-2.0.2-cp38-abi3-macosx_11_0_arm64.whl
Size 462.8 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
be2f6fa589f000b29779e6bd0bd3d286672011a3e1a1b919f040965ede83b065
BLAKE2b-256 checksum
How to use checksums
7b3522965ff55a29936bc509d91624b4be54ebedbb21aab5c2abea1a31a1a826
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release history Release notifications | RSS feed

This release

2.0.2 This release

5 release files

2.0.1

5 release files

2.0.0

5 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release 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