This package provides a go API client for the lemonsqueezy API
lemonsqueezy-go is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/lemonsqueezy-go
Alternatively the same can be achieved if you use import in a package:
import "github.com/NdoleStudio/lemonsqueezy-go"
GET /v1/users/me: Retrieves the currently authenticated user.GET /v1/stores/:id: Retrieve a storeGET /v1/stores: List all storesGET /v1/customers/:id: Retrieve a customerGET /v1/customers: List all customersGET /v1/products/:id: Retrieve a productGET /v1/products: List all productsGET /v1/variants/:id: Retrieve a variantGET /v1/variants: List all variantsGET /v1/prices/:id: Retrieve a priceGET /v1/prices: List all pricesGET /v1/files/:id: Retrieve a fileGET /v1/files: List all filesGET /v1/orders/:id: Retrieve an orderGET /v1/orders: List all ordersGET /v1/order-items/:id: Retrieve an order itemGET /v1/order-items: List all order itemsPATCH /v1/subscriptions/:id: Update a subscriptionGET /v1/subscriptions/:id: Retrieve a subscriptionGET /v1/subscriptions: List all subscriptionsDELETE /v1/subscriptions/{id}: Cancel an active subscriptionGET /v1/subscription-invoices/:id: Retrieve a subscription invoiceGET /v1/subscription-invoices: List all subscription invoicesPOST /v1/subscription-invoices/:id/generate-invoice: Generate a subscription invoiceGET /v1/subscription-items/:id: Retrieve a subscription itemPATCH /v1/subscription-items/:id: Update a subscription itemGET /v1/subscription-items: List all subscription itemsGET /v1/subscription-items/:id/current-usage: Retrieve a subscription item's current usagePOST /v1/discounts: Create a discountGET /v1/discounts/:id: Retrieve a discountDELETE /v1/discounts/:id: Delete a discountGET /v1/discounts: List all discountsGET /v1/discount-redemptions/:id: Retrieve a discount redemptionGET /v1/discount-redemptions: List all discount redemptionsGET /v1/license-keys/:id: Retrieve a license keyGET /v1/license-keys: List all license keysGET /v1/license-key-instances/:id: Retrieve a license key instanceGET /v1/license-key-instances: List all license keys instancePOST /v1/licenses/validate: Validate a licensePOST /v1/licenses/activate: Activate a licensePOST /v1/licenses/deactivate: Deactivate a licensePOST /v1/checkouts: Create a checkoutGET /v1/checkouts/:id: Retrieve a checkoutGET /v1/checkouts: List all checkoutsPATCH /v1/webhooks/:id: Update a webhookGET /v1/webhooks/:id: Retrieve a webhookGET /v1/webhooks: List all webhooksDELETE /v1/webhooks/{id}: Update a webhookVerify: Verify that webhook requests are coming from Lemon SqueezyAn instance of the client can be created using New().
package main
import (
"github.com/NdoleStudio/lemonsqueezy-go"
)
func main() {
client := lemonsqueezy.New(lemonsqueezy.WithAPIKey(""))
}
All API calls return an error as the last return object. All successful calls will return a nil error.
subscription, response, err := client.Subscriptions.Get(context.Background(), "1")
if err != nil {
//handle error
}
Webhooks allow Lemon Squeezy to send new data to your application when certain events occur inside your store.
You can use the sample code below as inspiration for a basic http.HandlerFunc which processes webhook events on your server.
func WebhookHandler(_ http.ResponseWriter, req *http.Request) {
// 1. Authenticate the webhook request from Lemon Squeezy using the `X-Signature` header
// 2. Process the payload if the request is authenticated
eventName := req.Header.Get("X-Event-Name")
payload, err := io.ReadAll(req.Body)
if err != nil {
log.Fatal(err)
}
switch eventName {
case lemonsqueezy.WebhookEventSubscriptionCreated:
var request lemonsqueezy.WebhookRequestSubscription
if err = json.Unmarshal(payload, &request); err != nil {
log.Fatal(err)
}
// handle subscription_created request
case lemonsqueezy.WebhookEventOrderCreated:
var request lemonsqueezy.WebhookRequestOrder
if err = json.Unmarshal(payload, &request); err != nil {
log.Fatal(err)
}
// handle order_created request
default:
log.Fatal(fmt.Sprintf("invalid event [%s] received with request [%s]", eventName, string(payload)))
}
}
You can run the unit tests for this client from the root directory using the command below:
go test -v
This project is licensed under the MIT License - see the LICENSE file for details
$ claude mcp add lemonsqueezy-go \
-- python -m otcore.mcp_server <graph>