If you’re a digital creator or entrepreneur, you’ve probably heard of Gumroad — a platform that makes selling products online seamless. While Gumroad provides an API to integrate its services into custom applications, working directly with APIs can sometimes feel tedious or overly complex.
That’s where this JavaScript client comes in! Designed to simplify your workflow, this client allows you to interact with Gumroad’s API effortlessly, whether you’re fetching product details, managing subscribers, or automating sales data. With clean syntax and practical methods, this client will save you time and make building on Gumroad a breeze.
In this post, I’ll guide you through what this client offers, how to set it up, and examples of how you can use it to supercharge your Gumroad integrations. Let’s dive in! 🔥
Installation
Install the package by running the following command in terminal:
Usage
Put your Gumroad access token token as GUMROAD_ACCESS_TOKEN
in your .env
file.
The module can be imported using import
in ES Modules and require
in Common JS as shown below:
ES Modules:
Common JS:
API Reference
I have listed few of methods, although all the methods in Gumroad API v2 are available in this client. You can explore all of them by installing the package.
gumroad.products.list()
Returns: Promise<Product[]>
See: https://app.gumroad.com/api#get-/products
Retrieve all of the existing products for the authenticated user.
gumroad.products.get(product_id)
Parameters:
product_id
:string
- Id of the product
Returns: Promise<Product>
See: https://app.gumroad.com/api#get-/products/:id
Retrieve the details of a product.
gumroad.products.delete(product_id)
Parameters:
product_id
:string
- The id of the product to delete
Returns: true
See: https://app.gumroad.com/api#delete-/products/:id
Permanently delete a product.
gumroad.products.enable(product_id)
Parameters:
product_id
:string
- The id of the product to enable
Returns: Promise<Product>
See: https://app.gumroad.com/api#put-/products/:id/enable
Enable an existing product.
gumroad.products.disable(product_id)
Parameters:
product_id
:string
- The id of the product to disable
Returns: Promise<Product>
See: https://app.gumroad.com/api#put-/products/:id/disable
Disable an existing product.
gumroad.licenses.verify(product_id, license_key, [increment_uses_count])
Parameters:
product_id
:string
- The unique ID of the product, available on product’s edit pagelicense_key
:string
- The license key provided by your customerincrement_uses_count
:boolean
- Iftrue
, increment the uses count of a license. Default:true
Returns: Promise<Purchase>
See: https://app.gumroad.com/api#post-/licenses/verify
Verify a license
gumroad.licenses.enable(product_id, license_key)
Parameters:
product_id
:string
- The unique ID of the product, available on product’s edit pagelicense_key
:string
- The license key provided by your customer
Returns: Promise<Purchase>
See: https://app.gumroad.com/api#put-/licenses/enable
Enable a license
gumroad.licenses.disable(product_id, license_key)
Parameters:
product_id
:string
- The unique ID of the product, available on product’s edit pagelicense_key
:string
- The license key provided by your customer
Returns: Promise<Purchase>
See: https://app.gumroad.com/api#put-/licenses/disable
Disable a license
gumroad.licenses.decrementUsesCount(product_id, license_key)
Parameters:
product_id
:string
- The unique ID of the product, available on product’s edit pagelicense_key
:string
- The license key provided by your customer
Returns: Promise<Purchase>
See: https://app.gumroad.com/api#put-/licenses/decrement_uses_count
Decrement the uses count of a license
Webhook (Resource Subscriptions)
You can handle webhook requests with ease by using this library. An example is shown below which is written for Cloudflare Workers:
Wrapping Up
This JavaScript client for the Gumroad API is built to make integrations simpler and more efficient. From managing products to automating workflows, it empowers you to create custom solutions without the usual complexities.
Start exploring its features today and unlock new possibilities for your Gumroad projects.
Happy coding! 🚀