How to get staking info by core api?

is there any way to get staking info, find any tx flow of staking

It’s no longer possible in the core, but you can retrieve validator stakes from the Gateway using the validator/stakes end point, or for an individual staker using the account/stakes end point:

Gateway API Specs

I want to calculate the APY, use this formula

APY = 100* ((ValueNow - ValueOld)/ValueOld * 365.25 * 24 * 3600) / (TimestampNow - TimestampOld)

but there may be some questions, if I unStaking or staked some XRD, the APY will not correct when I change the staked amount some time, is there any way to ensure the APY accurate