Requests
Lemon Squeezy API requests need to be made over HTTPS and follow the JSON:API spec.
Requirements
All API requests must be made over HTTPS to https://api.lemonsqueezy.com
. Calls made over plain HTTP will fail. See API Errors for more information on error responses.
For endpoints that require authentication, API requests must be authenticated.
As per the JSON:API spec, the following headers must be included with all requests to the API:
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
If you’re attempting to make a request with a null Origin
header (e.g. from a sandboxed iframe in a Figma plugin) then you can use the https://api-cors-anywhere.lemonsqueezy.com
API proxy URL instead.
Authentication
The Lemon Squeezy API uses API keys to authenticate requests. You can view and manage your API keys in your Lemon Squeezy account settings.
Keep your API keys secure
Do not share your API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
API keys can be created in both live and test modes:
- Live mode - Use this API key in your production application.
- Test mode - Use this API key in your development and testing environments. Read more about test mode →
Generated API keys are valid for a year.
Authenticated request example
Pagination
The Lemon Squeezy API uses page-based pagination for all “list” endpoints. The responses will contain valid JSON:API pagination objects in the response. This includes a top-level links
object with (URL-encoded) first
, last
, next
and prev
links, like this:
You can use links.next
to continue through the pages of your query. If next
is not in the links object, you have reached the last page and similarly, prev
is not present on the first page of results.
The request also contains a pagination object in meta.page
, which contains helpful pagination information for your current query:
Using this data, you can surface information like how many total results there are (meta.page.total
) or how many pages there are (meta.page.lastPage
).
To make custom paginated queries, use the page[size]
parameter to determine how many results to return per page (default is 10
, minimum is 1
and maximum is 100
) and page[number]
to determine which page to retrieve.
Filtering
Lemon Squeezy “list” endpoints can be filtered by related objects or object values using query parameters. As per the JSON:API spec, filters should be applied as follows: ?filter[{parameter}]={value}
Filtering subscriptions by product_id
:
Filtering subscription invoices by subscription_id
:
Multiple filters:
Related resources
To help cut down on multiple requests, the Lemon Squeezy API supports the JSON:API spec for including related resources. Related resources can be included in the same response by using the include
query parameter.
For example, this request will include all Variants that belong to the Product with the id
of 100
:
The response will contain a new top-level included
array which will contain the related resources.
Nested queries
It’s also possible to use nested queries to retrieve related objects without the parent object. You can find nested query request URLs in each object’s relationships
object.
This example queries all Variants for a specific Product.