{"id":22576617,"url":"https://github.com/ndolestudio/lemonsqueezy-go","last_synced_at":"2025-04-07T08:17:48.940Z","repository":{"id":65149640,"uuid":"583910009","full_name":"NdoleStudio/lemonsqueezy-go","owner":"NdoleStudio","description":"Go library for the Lemon Squeezy API","archived":false,"fork":false,"pushed_at":"2024-11-25T16:48:58.000Z","size":186,"stargazers_count":66,"open_issues_count":0,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T07:08:10.656Z","etag":null,"topics":["lemonsqeezy-api-client","lemonsqeezy-go","lemonsqueezy"],"latest_commit_sha":null,"homepage":"https://docs.lemonsqueezy.com/api","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NdoleStudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-31T12:21:27.000Z","updated_at":"2025-03-28T16:36:15.000Z","dependencies_parsed_at":"2024-01-16T12:27:00.103Z","dependency_job_id":"a3d0de60-ba86-45d2-8f31-6f7908cafe18","html_url":"https://github.com/NdoleStudio/lemonsqueezy-go","commit_stats":{"total_commits":69,"total_committers":11,"mean_commits":"6.2727272727272725","dds":"0.33333333333333337","last_synced_commit":"e8ef769acbc934794dd2412edb7088f7884f1a0b"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":"NdoleStudio/go-http-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Flemonsqueezy-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Flemonsqueezy-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Flemonsqueezy-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Flemonsqueezy-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NdoleStudio","download_url":"https://codeload.github.com/NdoleStudio/lemonsqueezy-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615383,"owners_count":20967184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lemonsqeezy-api-client","lemonsqeezy-go","lemonsqueezy"],"created_at":"2024-12-08T04:07:22.420Z","updated_at":"2025-04-07T08:17:48.903Z","avatar_url":"https://github.com/NdoleStudio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lemonsqueezy-go\n\n[![Build](https://github.com/NdoleStudio/lemonsqueezy-go/actions/workflows/main.yml/badge.svg)](https://github.com/NdoleStudio/lemonsqueezy-go/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/NdoleStudio/lemonsqueezy-go/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/lemonsqueezy-go)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NdoleStudio/lemonsqueezy-go/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/NdoleStudio/lemonsqueezy-go/?branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/NdoleStudio/lemonsqueezy-go)](https://goreportcard.com/report/github.com/NdoleStudio/lemonsqueezy-go)\n[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/lemonsqueezy-go)](https://github.com/NdoleStudio/lemonsqueezy-go/graphs/contributors)\n[![GitHub license](https://img.shields.io/github/license/NdoleStudio/lemonsqueezy-go?color=brightgreen)](https://github.com/NdoleStudio/lemonsqueezy-go/blob/master/LICENSE)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/NdoleStudio/lemonsqueezy-go)](https://pkg.go.dev/github.com/NdoleStudio/lemonsqueezy-go)\n\nThis package provides a go API client for the lemonsqueezy API\n\n## Installation\n\n`lemonsqueezy-go` is compatible with modern Go releases in module mode, with Go installed:\n\n```bash\ngo get github.com/NdoleStudio/lemonsqueezy-go\n```\n\nAlternatively the same can be achieved if you use `import` in a package:\n\n```go\nimport \"github.com/NdoleStudio/lemonsqueezy-go\"\n```\n\n## Implemented\n\n- **Users**\n  - `GET /v1/users/me`: Retrieves the currently authenticated user.\n- **Stores**\n  - `GET /v1/stores/:id`: Retrieve a store\n  - `GET /v1/stores`: List all stores\n- **Customers**\n  - `GET /v1/customers/:id`: Retrieve a customer\n  - `GET /v1/customers`: List all customers\n- **Products**\n  - `GET /v1/products/:id`: Retrieve a product\n  - `GET /v1/products`: List all products\n- **Variants**\n  - `GET /v1/variants/:id`: Retrieve a variant\n  - `GET /v1/variants`: List all variants\n- **Prices**\n  - `GET /v1/prices/:id`: Retrieve a price\n  - `GET /v1/prices`: List all prices\n- **Files**\n  - `GET /v1/files/:id`: Retrieve a file\n  - `GET /v1/files`: List all files\n- **Orders**\n  - `GET /v1/orders/:id`: Retrieve an order\n  - `GET /v1/orders`: List all orders\n- **Order Items**\n  - `GET /v1/order-items/:id`: Retrieve an order item\n  - `GET /v1/order-items`: List all order items\n- **Subscriptions**\n  - `PATCH /v1/subscriptions/:id`: Update a subscription\n  - `GET /v1/subscriptions/:id`: Retrieve a subscription\n  - `GET /v1/subscriptions`: List all subscriptions\n  - `DELETE /v1/subscriptions/{id}`: Cancel an active subscription\n- **Subscription Invoices**\n  - `GET /v1/subscription-invoices/:id`: Retrieve a subscription invoice\n  - `GET /v1/subscription-invoices`: List all subscription invoices\n- **Subscription Items**\n  - `GET /v1/subscription-items/:id`: Retrieve a subscription item\n  - `PATCH /v1/subscription-items/:id`: Update a subscription item\n  - `GET /v1/subscription-items`: List all subscription items\n  - `GET /v1/subscription-items/:id/current-usage`: Retrieve a subscription item's current usage\n- **Discounts**\n  - `POST /v1/discounts`: Create a discount\n  - `GET /v1/discounts/:id`: Retrieve a discount\n  - `DELETE /v1/discounts/:id`: Delete a discount\n  - `GET /v1/discounts`: List all discounts\n- **Discount Redemptions**\n  - `GET /v1/discount-redemptions/:id`: Retrieve a discount redemption\n  - `GET /v1/discount-redemptions`: List all discount redemptions\n- **License Keys**\n  - `GET /v1/license-keys/:id`: Retrieve a license key\n  - `GET /v1/license-keys`: List all license keys\n- **License Key Instances**\n  - `GET /v1/license-key-instances/:id`: Retrieve a license key instance\n  - `GET /v1/license-key-instances`: List all license keys instance\n- **Licenses**\n  - `POST /v1/licenses/validate`: Validate a license\n  - `POST /v1/licenses/activate`: Activate a license\n  - `POST /v1/licenses/deactivate`: Deactivate a license\n- **Checkouts**\n  - `POST /v1/checkouts`: Create a checkout\n  - `GET /v1/checkouts/:id`: Retrieve a checkout\n  - `GET /v1/checkouts`: List all checkouts\n- **Webhooks**\n  - `PATCH /v1/webhooks/:id`: Update a webhook\n  - `GET /v1/webhooks/:id`: Retrieve a webhook\n  - `GET /v1/webhooks`: List all webhooks\n  - `DELETE /v1/webhooks/{id}`: Update a webhook\n  - `Verify`: Verify that webhook requests are coming from Lemon Squeezy\n\n## Usage\n\n### Initializing the Client\n\nAn instance of the client can be created using `New()`.\n\n```go\npackage main\n\nimport (\n    \"github.com/NdoleStudio/lemonsqueezy-go\"\n)\n\nfunc main() {\n    client := lemonsqueezy.New(lemonsqueezy.WithAPIKey(\"\"))\n}\n```\n\n### Error handling\n\nAll API calls return an `error` as the last return object. All successful calls will return a `nil` error.\n\n```go\nsubscription, response, err := client.Subscriptions.Get(context.Background(), \"1\")\nif err != nil {\n    //handle error\n}\n```\n\n### WebHooks\n\nWebhooks allow Lemon Squeezy to send new data to your application when certain events occur inside your store.\nYou can use the sample code below as inspiration for a basic `http.HandlerFunc` which processes webhook events on your server.\n\n```go\nfunc WebhookHandler(_ http.ResponseWriter, req *http.Request) {\n\n\t// 1. Authenticate the webhook request from Lemon Squeezy using the `X-Signature` header\n\n\t// 2. Process the payload if the request is authenticated\n\teventName := req.Header.Get(\"X-Event-Name\")\n\tpayload, err := io.ReadAll(req.Body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tswitch eventName {\n\tcase lemonsqueezy.WebhookEventSubscriptionCreated:\n\t\tvar request lemonsqueezy.WebhookRequestSubscription\n\t\tif err = json.Unmarshal(payload, \u0026request); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\t// handle subscription_created request\n\tcase lemonsqueezy.WebhookEventOrderCreated:\n\t\tvar request lemonsqueezy.WebhookRequestOrder\n\t\tif err = json.Unmarshal(payload, \u0026request); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\t// handle order_created request\n\tdefault:\n\t\tlog.Fatal(fmt.Sprintf(\"invalid event [%s] received with request [%s]\", eventName, string(payload)))\n\t}\n}\n```\n\n\n## Testing\n\nYou can run the unit tests for this client from the root directory using the command below:\n\n```bash\ngo test -v\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndolestudio%2Flemonsqueezy-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndolestudio%2Flemonsqueezy-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndolestudio%2Flemonsqueezy-go/lists"}