Getting Started with the API
Learn how to set up and use the Lemon Squeezy API, from creating API keys to making authenticated requests and understanding the API’s structure and capabilities.
Before diving into this guide, ensure that you have a Lemon Squeezy account. New to Lemon Squeezy? Check out our Getting Started guide to set up your account.
Create an API key
To access our API endpoints, you’ll need to create an API key. You can create one by navigating to Settings » API in your Lemon Squeezy dashboard. This key will authenticate your requests and allow you to interact with our API securely.
Create a new API key and give it a clear name. If you think you’ll need more than one key, pick names that you and your team can easily understand. Keep in mind that you can’t change these names later, so choose them carefully.
After you submit the form, you’ll see your new API key. Make sure to copy it and save it somewhere safe. Remember, you’ll only see this key once in the Lemon Squeezy dashboard, so don’t lose it!
Make sure you keep your API keys private. Never save API keys in your code or in Github. Instead use environment files and, for an extra level of security, rotate API keys regularly.
If you lose an API key, you can always make new ones or remove old ones from the Settings » API page in your Lemon Squeezy dashboard.
Making requests
The Lemon Squeezy API can be accessed from https://api.lemonsqueezy.com/v1/
. All requests should be made over HTTPS and every request requires authentication.
The API is based on the JSON:API spec and as such you are required to add the following headers in each request.
Authentication
The API uses Bearer authentication for all requests. This would be the API key that you previously created in step 1.
To authenticate, add an Authorization
header to all requests containing a valid API key:
In total, you need three headers when making requests to our API:
Accept
Content-Type
Authorization
For more information about authentication and rate limiting, please visit the API reference.
API overview
The Lemon Squeezy API covers all data types used in your store such as Products, Customers, Discounts and Files.
You can use the API to manage your store as well as set up payments for customers, access prior orders and manage ongoing subscriptions and software license keys.
Some examples of what’s possible with the API:
- Show what you’re selling inside your app
- Create checkout links to sign up new subscribers
- Create custom-priced checkouts for certain customers
- Access customer details and a list of their previous orders
- Create discount codes on-the-fly
- Activate and validate license keys
- Upgrade, downgrade, cancel, resume, pause and un-pause subscriptions
As per the JSON:API spec, responses will contain object data along with references to all relationships and optional “included” data.
For example:
Webhooks allow you to keep your app data up-to-date with Lemon Squeezy by sending real-time notifications when important events happen in Lemon Squeezy.
Looking for SDKs?
Lemon Squeezy offers official SDKs for several programming languages to make API integration even easier. Check out our available SDKs to find one that suits your development needs.