Decode Invoice

This API is used for further decyphering the details of a lightning invoice. The idea is to use this API endpoint if you have to validate any of the specific properties of any Payment Request.

Method


GET https://api.ninjapay.me/lapi/v1/decode

Parameters

payreq: string // Pass the invoice address which starts with "lnbc..."

Response

{
 "status": true,
   "data":{
    "amount": "0.00021350", // amount in BTC, not SAT
    "payreq": "lnbc2123250n1pjpr2qmpp526234tljpx5756pa2fyj2zrdmn2tnz9rhj54km2s7dv0pap3vtkqhp5extcuyp2x0ydfwnfhrc5cwx8azxeen2g7hxr29464ezvn3k6w2fqcqzpgxqzjcsp5xzelh2w3twt4ysvva2ugu2klurmrl7nk8h46x2hcthf9cvee24jq9qyyssq6an9tjftjymjeklerjmw8cv4ccpsvd2vzuzxn5upt9s37hnw2r0z0n5cd8cqq8jq5ems00tugt5jnw5jn03tr84945nd6j4hsfsu7kqp9hptk2",
    "expires_at": "2023-03-15T11:22:27.000Z",
    "network": "lightning",
    "description": "Paying for Master Sword #5546",
    "descriptionHash": "c9978e102a33c8d4ba69b8f14c38c7e88d9ccd48f5cc3516baae44c9c6da7292",
    "paymentHash": "56951aaff209a9ea683d524925086ddcd4b988a3bca95b6d50f358f0f43162ec",
    "paymentSecret": "30b3fba9d15b9752418ceab88e2adfe0f63ffa763deba32af85dd25c33395564",
    "payee": "036ff83834666d3ebfe61c2a7d1f8fc5d6b339a26559a61819e2b0d1b5f540fdfc",
    "signature": "d76655c92b91372cdbf91cb6e3e195c60306354c170469d38159611f5e6e50de27ce9869f0001e40a67707bd7c42e929ba929be2b19ea5ad26dd4ab78261cf58"
  },
 "message": ""
}

Example


const options = {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'API_KEY'
  },
  body: '{"payreq":"lnbc2123250n1pjpr2qmpp526234tljpx5756pa2fyj2zrdmn2tnz9rhj54km2s7dv0pap3vtkqhp5extcuyp2x0ydfwnfhrc5cwx8azxeen2g7hxr29464ezvn3k6w2fqcqzpgxqzjcsp5xzelh2w3twt4ysvva2ugu2klurmrl7nk8h46x2hcthf9cvee24jq9qyyssq6an9tjftjymjeklerjmw8cv4ccpsvd2vzuzxn5upt9s37hnw2r0z0n5cd8cqq8jq5ems00tugt5jnw5jn03tr84945nd6j4hsfsu7kqp9hptk2"}'
};

fetch('https://api.ninjapay.me/lapi/v1/decode', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  

Last updated