Developer guide

Getting started

First, you’ll need a Lemon Squeezy account. If you haven’t already, please

  1. Register an account
  2. Add some products
  3. Activate your store

Note: You can build your Lemon Squeezy integration while you're waiting for store approval. You have full access to our Dashboard and APIs in test mode.

Read our Getting Started guide to get your Lemon Squeezy account set up.

Create an API key

To get started with the API, you will need an API key, which you can create from Settings > API.

Create a new API key with a custom name. If you plan to use multiple API keys, make sure you use names that make sense to you and your team (you can't edit names later on).

The API key is shown to you after you submit the form. Copy it somewhere secure, as each key is only ever shown to you once in the Lemon Squeezy dashboard.

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 ever have issues with losing an API key, you can always create and delete keys from Settings > API 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.

Accept: application/vnd.api+json Content-Type: application/vnd.api+json

Authentication

The API uses Bearer authentication for all requests. You will need an API key from Settings > API.

To authenticate, add an Authorization header to all requests containing a valid API key:

Authorization: Bearer {api_key}

In total, you need three headers (Accept, Content-Type and Authorization) when making requests to our API.

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.

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/orders/1" }, "data": { "type": "orders", "id": "1", "attributes": { "store_id": 1, "customer_id": 1, "identifier": "104e18a2-d755-4d4b-80c4-a6c1dcbe1c10", "order_number": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "currency": "USD", "currency_rate": "1.0000", "subtotal": 999, "discount_total": 0, "tax": 200, "total": 1199, "subtotal_usd": 999, "discount_total_usd": 0, "tax_usd": 200, "total_usd": 1199, "tax_name": "VAT", "tax_rate": "20.00", "status": "paid", "status_formatted": "Paid", "refunded": false, "refunded_at": null, "subtotal_formatted": "$9.99", "discount_total_formatted": "$0.00", "tax_formatted": "$2.00", "total_formatted": "$11.99", "first_order_item": { "id": 1, "order_id": 1, "product_id": 1, "variant_id": 1, "product_name": "Test Limited License for 2 years", "variant_name": "Default", "price": 1199, "created_at": "2021-08-17T09:45:53.000000Z", "updated_at": "2021-08-17T09:45:53.000000Z", "deleted_at": null, "test_mode": false }, "urls": { "receipt": "https://app.lemonsqueezy.com/my-orders/104e18a2-d755-4d4b-80c4-a6c1dcbe1c10?signature=8847fff02e1bfb0c7c43ff1cdf1b1657a8eed2029413692663b86859208c9f42" }, "created_at": "2021-08-17T09:45:53.000000Z", "updated_at": "2021-08-17T09:45:53.000000Z" }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/orders/1/store", "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/store" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/subscriptions/1/customer", "self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/customer" } }, "order-items": { "links": { "related": "https://api.lemonsqueezy.com/v1/orders/1/order-items", "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/order-items" } }, "subscriptions": { "links": { "related": "https://api.lemonsqueezy.com/v1/orders/1/subscriptions", "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/subscriptions" } }, "license-keys": { "links": { "related": "https://api.lemonsqueezy.com/v1/orders/1/license-keys", "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/license-keys" } }, "discount-redemptions": { "links": { "related": "https://api.lemonsqueezy.com/v1/orders/1/discount-redemptions", "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/discount-redemptions" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/orders/1" } } }

Webhooks allow your application to stay in sync with your billing system as events happen in Lemon Squeezy.

SDKs

Download packages for your app that make it easy to interface with the Lemon Squeezy API.

Official SDKs

Unofficial SDKs

Previous
Getting started