3

I have been trying to pull the validator-level data for Polkadot for a project I am working on. I am using this API and have been unable to find a command I need. Ideally, the request URL would either return the number of validators for each day/era/epoch (any of those work), or even better, would return validator-level information for each validator staking during each day/era/epoch. I see requests for current validator information, but I can't see how to access historical data.

Does anyone know of a request URL that would work for this, or another API which would have this information? Thanks in advance!

2 Answers 2

1

Take a look into this tool substrate-api-sidecar, it makes easy to interact with blockchain nodes via API queries.

Connect the tool into your local network or into Polkadot creating a .env file with:

SAS_SUBSTRATE_URL=wss://rpc.polkadot.io

Take a look here in all the queries available with the tool: https://paritytech.github.io/substrate-api-sidecar/dist/

You can query the staking data in a certain block with /pallets/staking/progress or payouts and info of certain accounts with the queries /accounts/{accountId}/staking-payouts and /accounts/{accountId}/staking-info

1
  • Just to add to what Alex said; you can use the ?at=<blocknumber or hash> query parameter with the /pallets/staking/progress endpoint to get the list of addresses in the validatorSet at a historic block. NOTE: you will need to be querying an archive node if you wish to get all historic data. Nov 15, 2022 at 22:39
0

From looking at the subscan API, I also couldn't find a way to pull validator-level data from a historic session.

However, you can find the session info for a given sessionIndex by using this call from the polkadot.js API. As sessions on polkadot are the same length as epochs, you can get the current session index, and then just decrement the index to query backwards and get a list of validators for each past epoch.

There may be an undocumented way to do this in subscan, but based only on API documentation, this is probably the best way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.