Skip to main content

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

Project description

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
import os

# Bind to the UDP port configured on ShredStream.com
PORT = int(os.environ.get("SHREDSTREAM_PORT", 8001))
listener = ShredListener(port=PORT)

# Decoded transactions — ready-to-use Solana transactions
for slot, transactions in listener:
    for tx in transactions:
        print(f"slot {slot}: {tx.signature}")

# OR raw shreds — lowest latency, arrives before block assembly
# for shred in listener.shreds():
#     print(f"slot={shred.slot} index={shred.index} len={len(shred.payload)}")

Run it:

python3 main.py

📖 API Reference

ShredListener

ShredListener(port=8001, recv_buf=25*1024*1024, max_age=10)
Parameter Type Default Description
port int 8001 UDP port to bind
recv_buf int 25 MB Socket receive buffer size
max_age int 10 Maximum slot age before eviction

Methods

  • Iterator protocol -- for slot, transactions in listener: yields decoded transactions as they arrive.
  • listener.shreds() -- Generator yielding individual ParsedShred objects.
  • listener.active_slots() -- Number of slots currently being accumulated.
  • listener.stop() -- Closes the UDP socket.

ParsedShred

Field Type Description
slot int Slot number
index int Shred index within the slot
payload bytes Raw shred payload (after header)
batch_complete bool True if this shred ends an entry batch
last_in_slot bool True if this is the last shred in slot

Transaction

Field Type Description
signatures list[bytes] Raw 64-byte signatures
raw bytes Full wire-format transaction bytes
signature str (property) First signature as base58 (lazy, via solders)

🎯 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

ShredStream.com provides a complete, optimized PumpFun token creation detection code exclusively to Pro plan subscribers and above. Battle-tested, high-performance, ready to plug into your sniping pipeline. To get access, open a ticket on Discord or reach out on Telegram @shredstream.

⚙️ Configuration

OS Tuning

# Linux -- increase max receive buffer
sudo sysctl -w net.core.rmem_max=33554432

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

Dependencies

  • solders>=0.21 -- Required for base58 signature encoding (tx.signature property). Imported lazily on first access.

💡 Examples

Filter by program

from shredstream import ShredListener
from solders.pubkey import Pubkey

PUMP_FUN = bytes(Pubkey.from_string("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"))

for slot, txs in ShredListener(port=8001):
    for tx in txs:
        if PUMP_FUN in tx.raw:
            print(f"slot {slot}: {tx.signature}")

Raw shred access

from shredstream import ShredListener

listener = ShredListener(port=8001)
for shred in listener.shreds():
    print(f"slot={shred.slot} index={shred.index} len={len(shred.payload)}")

🚀 Launch a Shred Stream

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

🔗 Links

📄 License

MIT — ShredStream.com

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

shredstream-1.0.3.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

shredstream-1.0.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file shredstream-1.0.3.tar.gz.

File metadata

  • Download URL: shredstream-1.0.3.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for shredstream-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f48a9f1cfb826c9b9f2b7bcc930d5932b83ea50f72e3be0e57b9506357bfda47
MD5 092600661cff016061c091c449df1354
BLAKE2b-256 b672f069c706e6eee63a14185834849371379551fb99db8e9548dba19a2085e3

See more details on using hashes here.

File details

Details for the file shredstream-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: shredstream-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for shredstream-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7c3c00aed8f73957b5a8d5fcf319ff63f5c571f0149e34c33a6e1207bb931985
MD5 3a818815a64fe12c24eea5762dcbd301
BLAKE2b-256 f8da029f86b0c87f9a9987c3a8861c0d965b5f298df26e97a7bcfa853a0bbbb3

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