Best Practices

Use Parquet for Large Queries

For queries spanning more than 10K blocks, always use Parquet format:

  • 10x smaller file size than JSON
  • Faster to parse with pandas/polars
  • No block range limit

Start Small, Scale Up

Begin with small block ranges (100-1000 blocks) to:

  • Verify your query returns expected data
  • Estimate costs for larger queries
  • Iterate on filters quickly

Handle Rate Limits Gracefully

import time
from requests import Session

session = Session()
session.headers['X-API-Key'] = 'dsk_your_key'

def fetch(url):
    while True:
        resp = session.get(url)
        if resp.status_code == 429:
            wait = int(resp.headers.get('Retry-After', 60))
            print(f"Rate limited, waiting {wait}s")
            time.sleep(wait)
            continue
        resp.raise_for_status()
        return resp.json()

Use Default (Non-Verbose) Mode

Keep verbose=false (the default) unless you specifically need:

  • Transaction hashes
  • Log indices
  • Event type names

This reduces response size significantly.

Monitor Your Quota

Check response headers to track usage:

  • X-RateLimit-Remaining: Your remaining quota
  • X-Request-Cost: Cost of the current request