This is the official JavaScript SDK for Lemon Squeezy, helping make it easy to incorporate billing into your JavaScript application.
-
Read API Reference to understand how the Lemon Squeezy API works.
-
Visit Wiki page for function usage.
- Type-safe: Written in TypeScript and documented with TSDoc.
- Tree-shakeable: Use only functions that you need. See bundle size.
# bun
bun install @lemonsqueezy/lemonsqueezy.js
# pnpm
pnpm install @lemonsqueezy/lemonsqueezy.js
# npm
npm install @lemonsqueezy/lemonsqueezy.js
Create a new API key from Settings > API in your Lemon Squeezy dashboard.
Add this API key into your project, for example as LEMONSQUEEZY_API_KEY
in your .env
file.
You can build and test a full API integration with Lemon Squeezy using test mode.
Any API keys created in test mode will interact with your test mode store data.
When you are ready to go live with your integration, make sure to create an API key in live mode and use that in your production application.
lemonSqueezySetup({ apiKey });
const { data, error, statusCode } = await getAuthenticatedUser();
console.log({ data, error, statusCode });
For more functions usage, see Wiki.
Click to view
export | min+brotli |
---|---|
createDiscount | 995 B |
createCheckout | 900 B |
updateSubscriptionItem | 849 B |
updateSubscription | 841 B |
listSubscriptionItems | 833 B |
listSubscriptions | 831 B |
listWebhooks | 831 B |
listLicenseKeyInstances | 830 B |
updateLicenseKey | 827 B |
listUsageRecords | 824 B |
listDiscountRedemptions | 822 B |
listCustomers | 820 B |
listDiscounts | 820 B |
listProducts | 819 B |
listSubscriptionInvoices | 819 B |
listVariants | 819 B |
listOrderItems | 818 B |
listFiles | 817 B |
listLicenseKeys | 817 B |
listOrders | 817 B |
listStores | 817 B |
listCheckouts | 816 B |
listPrices | 816 B |
createWebhook | 808 B |
updateWebhook | 793 B |
deactivateLicense | 764 B |
validateLicense | 763 B |
activateLicense | 762 B |
createUsageRecord | 728 B |
getLicenseKeyInstance | 706 B |
getSubscriptionInvoice | 702 B |
getDiscountRedemption | 701 B |
getSubscriptionItem | 700 B |
getOrderItem | 699 B |
getWebhook | 699 B |
getCheckout | 697 B |
getFile | 697 B |
getLicenseKey | 697 B |
getUsageRecord | 697 B |
getCustomer | 695 B |
getStore | 695 B |
getSubscription | 695 B |
getOrder | 693 B |
getPrice | 693 B |
getProduct | 693 B |
getDiscount | 692 B |
getVariant | 692 B |
archiveCustomer | 683 B |
updateCustomer | 683 B |
createCustomer | 680 B |
deleteWebhook | 663 B |
cancelSubscription | 658 B |
deleteDiscount | 655 B |
getSubscriptionItemCurrentUsage | 651 B |
getAuthenticatedUser | 598 B |
lemonSqueezySetup | 106 B |
Do not use this package directly in the browser, as this will expose your API key. This would give anyone full API access to your Lemon Squeezy account and store(s). For more information see more.
See the Contributing Guide.