user10915: I'm trying to find a way where I can view balance of my ledger nano s wallet without always attaching it to computer all the time.
I found something called xpub address which allows me to generate public addresses without my hardware wallet, I am now trying to figure out if there is a way (api ideally) to use this xpub address to view balance from my previously generated addresses.

user26481: You can use a watch only wallet service like Blockonnomics to see addresses/balance in your xpub. In fact it also allows you to generate new receiving addresses.

user48884: Certainly. If you use the master public key (the xpub that you have), you can enter it into a site like blockchain.info to get the balances of many of the addresses derived from that key. Generally software that do this sort of monitoring (including your wallet software), only search a few addresses (all of the ones that have been used in a transaction and then some number ahead of those) so it may miss some of your transactions.
You can also setup a desktop wallet software like Electrum to work with your Ledger Nano S. This allows you to get new addresses and monitor your balance without having the device connected and still be able to connect your Ledger to spend from it when you want to.

user38324: That's exactly what the Sentinel app does: imports a read-only XPUB key in order to passively watch the balance of an offline wallet, be it paper wallet, trezor or ledger.
For use with Ledger Nano S use the following steps:

From the chrome app: Click My Account.
Click Account Settings in the top right corner.
Click Export next to Extended public key.
In the Sentinel app tap the + button and select


Bitcoin Wallet (BIP44) — if you set up your ledger as legacy.
Segwit Bitcoin Wallet (BIP49) — if you set up your ledger as segwit.


Sentinel can also be used to receive funds to your ledger in the sense that it can derive the next public address from the XPUB and display its QR-code.
If you feel paranoid you can also build the app from source:  https://github.com/Samourai-Wallet/sentinel-android. Maybe it's worth mentioning that while the client code is open-source the server-side code is not, so we don't really know what is going on in the backend.
Direct query via address or xpub
Another (tedious) alternative would be to collect all the public non-empty addresses in the wallet and get their cumulative balance e.g. via https://blockchain.info/q/addressbalance/myadress1|myaddres2|myaddress3... — the result is a plain text number in satoshis; divide by 100000000 (i.e. 1e8) to get BTC.
Or, if you are comfortable sending your xpub over the internet, then you can query blockchain.info with your xpub, e.g.:

Current balance in HTML
https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz
Current balance as JSON
https://blockchain.info/multiaddr?active=xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz (if it shows a zero balance for a non-empty wallet then it means blockchain.info guys have not yet updated this api end-point to work with segwit).


10915: <p>I'm trying to find a way where I can view balance of my ledger nano s wallet without always attaching it to computer all the time.</p>

<p>I found something called <code>xpub</code> address which allows me to generate public addresses without my hardware wallet, I am now trying to figure out if there is a way (api ideally) to use this xpub address to view balance from my previously generated addresses.</p>
 26481: <p>You can use a watch only wallet service like <a href="https://www.blockonomics.co/blockonomics" rel="nofollow noreferrer">Blockonnomics</a> to see addresses/balance in your xpub. In fact it also allows you to generate new receiving addresses.</p>
 48884: <p>Certainly. If you use the master public key (the <code>xpub</code> that you have), you can enter it into a site like blockchain.info to get the balances of many of the addresses derived from that key. Generally software that do this sort of monitoring (including your wallet software), only search a few addresses (all of the ones that have been used in a transaction and then some number ahead of those) so it may miss some of your transactions.</p>

<p>You can also setup a desktop wallet software like Electrum to work with your Ledger Nano S. This allows you to get new addresses and monitor your balance without having the device connected and still be able to connect your Ledger to spend from it when you want to.</p>
 38324: <p>That's exactly what the <a href="https://play.google.com/store/apps/details?id=com.samourai.sentinel" rel="nofollow noreferrer">Sentinel</a> app does: imports a read-only XPUB key in order to passively watch the balance of an offline wallet, be it paper wallet, trezor or ledger.</p>

<p>For use with Ledger Nano S use the following steps:</p>

<ol>
<li>From the <em>chrome app</em>: Click <strong>My Account</strong>.</li>
<li>Click <strong>Account Settings</strong> in the top right corner.</li>
<li>Click <strong>Export</strong> next to <strong>Extended public key</strong>.</li>
<li>In the <em>Sentinel</em> app tap the <kbd>+</kbd> button and select

<ul>
<li>Bitcoin Wallet (BIP44) — if you set up your ledger as legacy.</li>
<li>Segwit Bitcoin Wallet (BIP49) — if you set up your ledger as segwit.</li>
</ul></li>
</ol>

<p>Sentinel can also be used to receive funds to your ledger in the sense that it can derive the next public address from the XPUB and display its QR-code.</p>

<p>If you feel paranoid you can also build the app from source:  <a href="https://github.com/Samourai-Wallet/sentinel-android" rel="nofollow noreferrer">https://github.com/Samourai-Wallet/sentinel-android</a>. Maybe it's worth mentioning that while the client code is open-source the server-side code is not, so we don't really know what is going on in the backend.</p>

<h3>Direct query via address or xpub</h3>

<p>Another (tedious) alternative would be to collect all the public non-empty addresses in the wallet and get their cumulative balance e.g. via <a href="https://blockchain.info/q/addressbalance/myadress1|myaddres2|myaddress3" rel="nofollow noreferrer">https://blockchain.info/q/addressbalance/myadress1|myaddres2|myaddress3</a>... — the result is a plain text number in satoshis; divide by <code>100000000</code> (i.e. <code>1e8</code>) to get BTC.</p>

<p>Or, if you are comfortable sending your xpub over the internet, then you can query blockchain.info with your xpub, e.g.:</p>

<ul>
<li><p><strong>Current balance in HTML</strong>
<a href="https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz" rel="nofollow noreferrer">https://blockchain.info/xpub/xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz</a></p></li>
<li><p><strong>Current balance as JSON</strong>
<a href="https://blockchain.info/multiaddr?active=xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz" rel="nofollow noreferrer">https://blockchain.info/multiaddr?active=xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz</a> <em>(if it shows a zero balance for a non-empty wallet then it means blockchain.info guys have not yet updated this api end-point to work with segwit)</em>.</p></li>
</ul>
