API to get stake rewards for a given address

Hello everybody,

I am developing a website to allow people enter their ADA address then they can see rewards history.

I cannot find it here https://input-output-hk.github.io/.

Could you please help to give me some advices.

I don’t want to use a third party I would like to build it by myself or can get it directly from Cardano’s team.

Thank you so much!

Well, to get the information directly from the blockchain, you need to run a cardano-node: https://github.com/input-output-hk/cardano-node
Obs: A cardano-node needs a lot of resources (rapidly approaching 100 GiB disk space, 16 GiB RAM) and probably needs days for first synchronisation (can be shortcut a bit by https://csnapshots.io/) and if you do not run it regularly still hours to resync after a longer pause.

Such a node provides a local socket over which some things can be queried with, e.g., cardano-cli. If you want to use the information programmatically, I’d recommend Ogmios: https://ogmios.dev/ It provides everything that can be queried from a cardano-node through a WebSockets API.

Unfortunately, the history of rewards is not readily available there, just the total of the currently withdrawable rewards. (Since a node does not strictly need the information about the history. It just needs to know the total to determine if a withdraw transaction is valid.)

If you really don’t want to use third-party services, the history (and a lot of other information) is available in cardano-db-sync: https://github.com/input-output-hk/cardano-db-sync
More specifically in the table reward: https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md#reward
Obs: cardano-db-sync more or less doubles the disk space needed compared to a pure cardano-node.

If you maybe can live with a third-party service, Koios – which provides a quite thin API around cardano-db-sync instances provided by other users – has the reward history on the API end point https://api.koios.rest/#post-/account_rewards and Blockfrost – another widely used API with free and paid tiers – at https://docs.blockfrost.io/#tag/Cardano-Accounts/paths/~1accounts~1%7Bstake_address%7D~1rewards/get.