npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

staking-rewards-api

v1.1.0

Published

SDK for staking pools to monitor validator rewards and earnings, and finding top validators on Ethereum and BSC for best returns.

Readme

Staking Rewards API

A powerful SDK for monitoring validator rewards, earnings, and identifying top-performing validators on Ethereum and BSC networks. Built for staking pools, validator operators, and DeFi platforms that need real-time insights into validator performance.

npm version License: MIT

🎯 Overview

The Staking Rewards API provides comprehensive tools for tracking and analyzing validator performance across Ethereum and Binance Smart Chain (BSC) networks. Whether you're running a staking pool, managing multiple validators, or building analytics dashboards, this SDK gives you the data you need to optimize returns and monitor validator earnings.

Key Features

  • 📊 Top Validators Discovery: Identify the highest-earning validators on Ethereum and BSC
  • 💰 Reward Tracking: Monitor validator rewards and earnings in real-time
  • 📈 Historical Analysis: Analyze validator performance over custom time periods
  • 🔄 Real-time Streaming: Get live updates via WebSocket subscriptions
  • 🌐 Multi-Validator Support: Track single validators, multiple validators, or all validators simultaneously
  • ⚡ High Performance: Built on Bitquery's API for fast, reliable data access

🚀 Quick Start

Installation

npm install staking-rewards-api

Basic Usage

import {
    getTopValidatorsETH,
    getValidatorRewardsETH,
    runValidatorRewardsStreamETH
} from 'staking-rewards-api';

const token = 'YOUR_BITQUERY_TOKEN';

// Find top 10 validators on Ethereum (last 24 hours)
const topValidators = await getTopValidatorsETH(token, 24, 10);
console.log('Top Validators:', topValidators);

// Get rewards for a specific validator
const rewards = await getValidatorRewardsETH(
    token,
    '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    24 // hours ago
);
console.log('Validator Rewards:', rewards);

// Stream live validator rewards
const ws = await runValidatorRewardsStreamETH(token, '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', {
    onData: (data) => {
        console.log('New reward:', data);
    },
    onError: (error) => {
        console.error('Stream error:', error);
    }
});

📚 API Reference

Query Functions

getTopValidatorsETH(token, hoursAgo, limit)

Get the top-performing validators on Ethereum network.

Parameters:

  • token (string, required): Your Bitquery OAuth token
  • hoursAgo (number, optional): Hours to look back (default: 24)
  • limit (number, optional): Number of validators to return (default: 10)

Returns: JSON object containing top validators data with total tips, rewards, and performance metrics

Example:

const topValidators = await getTopValidatorsETH(token, 48, 20);

getTopValidatorsBSC(token, hoursAgo, limit)

Get the top-performing validators on BSC network.

Parameters: Same as getTopValidatorsETH

Example:

const topValidators = await getTopValidatorsBSC(token, 24, 15);

getValidatorRewardsETH(token, address, hoursAgo)

Get historical rewards for a specific Ethereum validator.

Parameters:

  • token (string, required): Your Bitquery OAuth token
  • address (string, required): The validator address
  • hoursAgo (number, optional): Hours to look back (default: 24)

Returns: JSON object containing validator rewards, balance changes, and transaction details

Example:

const rewards = await getValidatorRewardsETH(
    token,
    '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    72 // last 3 days
);

getValidatorRewardsBSC(token, address, hoursAgo)

Get historical rewards for a specific BSC validator.

Parameters: Same as getValidatorRewardsETH

Example:

const rewards = await getValidatorRewardsBSC(token, '0x...', 24);

Streaming Functions

All streaming functions return a WebSocket connection and accept an options object with:

  • onData (function): Callback for incoming data
  • onError (function): Callback for errors
  • autoCloseMs (number): Automatically close connection after N milliseconds

runValidatorRewardsStreamETH(token, address, options)

Stream live validator rewards for a single Ethereum validator.

Example:

const ws = await runValidatorRewardsStreamETH(token, '0x...', {
    onData: (data) => console.log('Reward update:', data),
    onError: (err) => console.error('Error:', err),
    autoCloseMs: 60000 // close after 1 minute
});

runMultipleValidatorRewardsStreamETH(token, addresses, options)

Stream rewards for multiple Ethereum validators simultaneously.

Example:

const addresses = [
    '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
    '0x8ba1f109551bD432803012645Hac136c22C92900'
];
const ws = await runMultipleValidatorRewardsStreamETH(token, addresses, {
    onData: (data) => console.log('Multi-validator update:', data)
});

runAllValidatorRewardsStreamETH(token, options)

Stream rewards for all Ethereum validators (use with caution - high volume).

Example:

const ws = await runAllValidatorRewardsStreamETH(token, {
    onData: (data) => console.log('All validators update:', data)
});

BSC Streaming Functions

  • runValidatorRewardsStreamBSC(token, address, options)
  • runMultipleValidatorRewardsStreamBSC(token, addresses, options)
  • runAllValidatorRewardsStreamBSC(token, options)

Usage is identical to Ethereum functions, but for BSC network.

🏗️ Use Cases

For Staking Pools

  • Performance Benchmarking: Compare your validators against top performers
  • Reward Optimization: Identify which validators generate the highest returns
  • Real-time Monitoring: Track validator performance as rewards are distributed
  • Portfolio Management: Monitor multiple validators across different networks

For Validator Operators

  • Earnings Tracking: Monitor your validator's rewards in real-time
  • Performance Analysis: Analyze historical performance to optimize operations
  • Competitive Intelligence: See how you rank against other validators
  • Alert Systems: Set up automated monitoring for reward events

For DeFi Platforms

  • Analytics Dashboards: Build comprehensive validator analytics
  • APY Calculations: Calculate accurate APY based on real validator performance
  • Risk Assessment: Evaluate validator reliability and performance
  • Data Integration: Integrate validator data into your platform

🔑 Getting Your API Token

This SDK uses Bitquery's Transaction Balance API for Ethereum and BSCto fetch blockchain data. To get started:

  1. Visit Bitquery IDE to create an account
  2. Generate your Access Token by following these instructions
  3. Start querying validator data immediately

Bitquery provides comprehensive blockchain data APIs for Ethereum, BSC, and 40+ other networks. Perfect for building analytics, monitoring tools, and data-driven applications.

📊 Data Structure

Top Validators Response

{
  "data": {
    "EVM": {
      "TransactionBalances": [
        {
          "TokenBalance": {
            "Address": "0x...",
            "Currency": {
              "Name": "Ethereum",
              "Symbol": "ETH"
            }
          },
          "Total_tip_native": "1.23456789",
          "Total_tip_usd": "2345.67",
          "number_of_tips": 42
        }
      ]
    }
  }
}

Validator Rewards Response

{
  "data": {
    "EVM": {
      "TransactionBalances": [
        {
          "Post": "100.5",
          "Pre": "99.2",
          "Total_tip_native": "1.3",
          "Total_tip_usd": "2345.67",
          "number_of_tips": 5
        }
      ]
    }
  }
}

⚙️ Configuration

Environment Variables

You can set your Bitquery token as an environment variable:

export BITQUERY_TOKEN=your_token_here

Then use it in your code:

const token = process.env.BITQUERY_TOKEN;

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

📝 License

MIT License - see LICENSE file for details

🔗 Resources

💬 Support

🌟 Why Choose This SDK?

  • Built for Staking: Designed specifically for staking pools and validator operators
  • Real-time Data: Get instant updates on validator performance
  • Multi-Network: Support for both Ethereum and BSC
  • Production Ready: Ready to use for staking pools and DeFi platforms
  • Well Documented: Comprehensive API documentation and examples
  • Active Maintenance: Regularly updated with new features and improvements

Made with ❤️ by the Bitquery Team

Empowering staking pools and validator operators with actionable blockchain insights.