So, what can you do with the Whop API? Here are some common use cases you will find helpful with Whop's API.

Login

On the frontend, whop.login() will open a login widget for your users to easily login through Whop, Discord, or Twitter. See what the login page looks like here

<script src="https://whop.com/static/api.js?v=1"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>

let whop = new Whop("<YOUR CLIENT ID>")

$(".login").click(async function(e) {
  let user = await whop.login()
  let name = user["name"]
  console.log(user)
})

License Management

On the backend, you can use Whop to do license management. This includes issuing a license to a user using your product, validating it, and revoking it.

Validate License

The first time a user enters your application, ask them to input their license key and use Whop to verify it is valid.

// Ask your user to input their license key in your UI.
var licenseKey = "test";

var resp = await whop.validateLicenseByKey(licenseKey, {});

Updating License with Metadata

Store metadata along with the license instance, including hardware ID (so you can verify a user isn't using the same license key from multiple devices) and any other user information you'd like.

var resp = await whop.updateLicenseByKey(licenseKey, {
  "hwid": hwid,
  "userHash": userHash
})

Continual License Validation

In the background of your application, periodically ensure that the user still has a valid license and that the generated metadata (ex. current device they are using) matches the stored metadata.

var resp = await whop.validateLicenseByKey(licenseKey, {
  "hwid": hwid,
  "userHash": userHash
});

Ban License

At the end of a user's license term or in case of delinquent payments or violation of terms of service, use Whop to revoke a user's license.

var resp = await whop.banLicenseByKey(licenseKey);