{"id":13499290,"url":"https://github.com/ElementsProject/lightning-charge-client-js","last_synced_at":"2025-03-29T04:30:58.294Z","repository":{"id":27534885,"uuid":"110874332","full_name":"ElementsProject/lightning-charge-client-js","owner":"ElementsProject","description":"JavaScript client for lightning-charge","archived":false,"fork":false,"pushed_at":"2022-12-30T18:30:55.000Z","size":249,"stargazers_count":64,"open_issues_count":6,"forks_count":17,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-03-23T08:22:11.046Z","etag":null,"topics":["bitcoin","javascript","lightning","lightning-charge","lightning-charge-client","lightning-network","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ElementsProject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-15T19:03:09.000Z","updated_at":"2023-07-30T22:16:32.000Z","dependencies_parsed_at":"2023-01-14T06:57:47.170Z","dependency_job_id":null,"html_url":"https://github.com/ElementsProject/lightning-charge-client-js","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementsProject%2Flightning-charge-client-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementsProject%2Flightning-charge-client-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementsProject%2Flightning-charge-client-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElementsProject%2Flightning-charge-client-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ElementsProject","download_url":"https://codeload.github.com/ElementsProject/lightning-charge-client-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245458552,"owners_count":20618694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","javascript","lightning","lightning-charge","lightning-charge-client","lightning-network","nodejs"],"created_at":"2024-07-31T22:00:31.920Z","updated_at":"2025-03-29T04:30:58.001Z","avatar_url":"https://github.com/ElementsProject.png","language":"JavaScript","readme":"# lightning-charge-client-js\n\nJavaScript client for the Lightning Charge REST API.\n\n## Install\n\n```bash\n$ npm install lightning-charge-client\n```\n\n## Use\n\n```js\n// Initialize the client\nimport ChargeClient from 'lightning-charge-client'\nconst charge = new ChargeClient('http://localhost:9112', '[API-TOKEN]')\n\n// new is optional\nconst charge = require('lightning-charge-client')('http://localhost:9112', '[API-TOKEN]')\n\n// Create invoice\nconst inv = await charge.invoice({ msatoshi: 50, metadata: { customer_id: 123, product_id: 456 } })\n\nconsole.log(`invoice ${ inv.id } created with rhash=${ inv.rhash }, payreq=${ inv.payreq }`)\n\n// Create invoice denominated in USD\nconst inv = await charge.invoice({ currency: 'USD', amount: 0.15 })\n\n// Fetch invoice\nconst invoice = await charge.fetch('m51vlVWuIKGumTLbJ1RPb')\n\n// Fetch all invoices\nconst invoices = await charge.fetchAll()\n\n// Long poll payment updates for a specific invoice\ndo {\n  const paid = await charge.wait(inv.id, /* timeout: */ 600 /* seconds */)\n\n  if (paid) console.log(`invoice ${ paid.id } of ${ paid.msatoshi } paid, updated invoice:`, paid)\n  else if (paid === false) console.log('invoice expired and can no longer be paid')\n  else if (paid === null) console.log('timeout reached without payment, invoice is still payable')\n} while (paid === null)\n\n// Stream all incoming payments\nconst stream = charge.stream()\nstream.on('payment', inv =\u003e console.log(`invoice ${ inv.id } of ${ inv.msatoshi } paid`))\n\n```\n\nSee [Lightning Charge's documentation](https://github.com/ElementsProject/lightning-charge)\nfor more information and a full list of invoice fields.\n\n## Test\n\n```bash\n$ CHARGE_URL=http://api-token:ACCESS-TOKEN@localhost:8009 npm test\n```\n\n## License\nMIT\n","funding_links":[],"categories":["Developer Resources"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FElementsProject%2Flightning-charge-client-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FElementsProject%2Flightning-charge-client-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FElementsProject%2Flightning-charge-client-js/lists"}