title: How to get basic info of near wallet from near api?
body: <p>I am trying to get the basic info shown in the near wallet using near API.
  I want to fetch the info regarding stake and staking reward, basically all the info like:-
  <a href="https://i.stack.imgur.com/9AwOX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9AwOX.png" alt="enter image description here" /></a></p>
  <p>I am able to get the stacked near amount but not getting <code>Reward earned</code>, <code>Pending release</code>, and <code>Available for withdrawal</code></p>
  <p>I tried these APIs</p>
  <p><a href="https://docs.near.org/api/rpc/contracts" rel="nofollow noreferrer">https://docs.near.org/api/rpc/contracts</a></p>
  <p><a href="https://docs.near.org/tools/near-api-js/contract" rel="nofollow noreferrer">https://docs.near.org/tools/near-api-js/contract</a></p>
  <pre><code>async function getAccountBalance(accountId) {
      const near = await connect(config);
      const protocolConfig = await near.connection.provider.experimental_protocolConfig({ finality: 'final' });
      let state = await near.connection.provider.query({
          request_type: 'view_account',
          account_id: accountId,
          finality: 'optimistic'
      });
      const costPerByte = new bn_js_1.default(protocolConfig.runtime_config.storage_amount_per_byte);
       console.log(formatNearAmount(costPerByte));
       
      const stateStaked = new bn_js_1.default(state.storage_usage).mul(costPerByte);
      console.log(formatNearAmount(stateStaked));
      const staked = new bn_js_1.default(state.locked);
      console.log(formatNearAmount(staked));
      const totalBalance =await new bn_js_1.default(state.amount).add(staked);
      console.log(formatNearAmount(totalBalance));
      const availableBalance = totalBalance.sub(bn_js_1.default.max(staked, stateStaked));
      console.log(formatNearAmount(availableBalance));
  
      console.log(&quot;Storage cost - total balance ---? &quot;, formatNearAmount(availableBalance));
  }
  </code></pre>