<p>I just found the answer : <a href="https://api.lightning.community/rest/index.html?javascript#v1-payreq" rel="nofollow noreferrer">https://api.lightning.community/rest/index.html?javascript#v1-payreq</a></p>

<p>Use the endpoint <code>v1/payreq</code> to decode the payment request.</p>

<p>Exemple :</p>



<pre><code>var fs = require('fs');
var request = require('request');
var macaroon = fs.readFileSync('LND_DIR/data/chain/bitcoin/simnet/admin.macaroon').toString('hex');
var options = {
  url: 'https://localhost:8080/v1/payreq/{pay_req}',
  // Work-around for self-signed certificates.
  rejectUnauthorized: false,
  json: true, 
  headers: {
    'Grpc-Metadata-macaroon': macaroon,
  },
};
request.get(options, function(error, response, body) {
  console.log(body);
});
</code></pre>

<p>And the response :</p>

<pre><code>{ 
    "route_hints": &lt;array RouteHint&gt;, 
    "num_satoshis": &lt;string&gt;, 
    "expiry": &lt;string&gt;, 
    "description_hash": &lt;string&gt;, 
    "timestamp": &lt;string&gt;, 
    "features": &lt;object&gt;, 
    "destination": &lt;string&gt;, 
    "num_msat": &lt;string&gt;, 
    "payment_hash": &lt;string&gt;, 
    "payment_addr": &lt;byte&gt;, 
    "description": &lt;string&gt;, 
    "cltv_expiry": &lt;string&gt;, 
    "fallback_addr": &lt;string&gt;, 
}
</code></pre>

CC BY-SA 4.0
2020-03-16T15:56:25.857Z
Thanks for posting an answer when you found it.
Claris
CC BY-SA 4.0
2020-03-16T15:45:50.270Z
2020-03-16T15:45:50.270Z
Lounès KSOURI
<p>I'm using the REST API of my LN node to generate and pay invoices. I would like to know how to get the invoice amount/value in sats from the payment request I receive.</p>

<p>I found this : <a href="https://api.lightning.community/rest/index.html?javascript#v1-invoice" rel="noreferrer">https://api.lightning.community/rest/index.html?javascript#v1-invoice</a>, but I don't know how to get the payment hash.</p>

<p>Thanks in advance</p>

<api><lightning-network><hash><lightning-network-daemon><invoices>
Get invoice amount from payment request - LND REST API
Lounès KSOURI
# Get invoice amount from payment request - LND REST API

(Asked by: username_0 on 2020-03-16)

I'm using the REST API of my LN node to generate and pay invoices. I would like to know how to get the invoice amount/value in sats from the payment request I receive.

I found this : <https://api.lightning.community/rest/index.html?javascript#v1-invoice>, but I don't know how to get the payment hash.

Thanks in advance

**Tags:** api, lightning-network, hash, lightning-network-daemon, invoices


---

## 1 answers

### Answer by username_0 on 2020-03-16. Score: 4

I just found the answer : https://api.lightning.community/rest/index.html?javascript#v1-payreq
Use the endpoint v1/payreq to decode the payment request.
Exemple :
var fs = require('fs');
var request = require('request');
var macaroon = fs.readFileSync('LND_DIR/data/chain/bitcoin/simnet/admin.macaroon').toString('hex');
var options = {
  url: 'https://localhost:8080/v1/payreq/{pay_req}',
  // Work-around for self-signed certificates.
  rejectUnauthorized: false,
  json: true, 
  headers: {
    'Grpc-Metadata-macaroon': macaroon,
  },
};
request.get(options, function(error, response, body) {
  console.log(body);
});

And the response :
{ 
    "route_hints": , 
    "num_satoshis": , 
    "expiry": , 
    "description_hash": , 
    "timestamp": , 
    "features": , 
    "destination": , 
    "num_msat": , 
    "payment_hash": , 
    "payment_addr": , 
    "description": , 
    "cltv_expiry": , 
    "fallback_addr": , 
}

> **Comments:**
> **username_1**: Thanks for posting an answer when you found it.  

---

