Whop Business API
Search…
Javascript SDK (Frontend)
This page features the client-side features for Whop
Whop also provides a frontend SDK for common client-side functions.
​
Below you can find a demo for some of the functions so you can get a feel for how they would work on your site.

Getting Started

To start, include our CDN in the <head> tag of your HTML as well as JQuery:
<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>
And now where you want to use it, instantiate an instance of our Whop class using the clientId from the settings page on your dashboard. For obtaining your clientId, see Get Your API Keys for details.
let whop = new Whop("<YOUR CLIENT ID>")
console.log("User logged in: ", whop.isLoggedIn())

Login

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.
$(".login").click(async function(e) {
let user = await whop.login()
let name = user["name"]
console.log(user)
})

Logout

whop.logout() logs out the currently logged in user.
$(".logout").click(async function(e) {
alert(whop.logout())
})

Get User Info

Fetch the currently logged in user's info with whop.getUser()
$(".getUser").click(async function(e) {
try {
let user = await whop.getUser()
let name = user["name"]
console.log(user)
} catch (error) {
alert(error["message"])
}
})

Check for Logged In User

Call whop.isLoggedIn() to check if a user is logged in.
$(".isLoggedIn").click(async function(e) {
alert(whop.isLoggedIn())
})

Get Plans

$(".getPlans").click(async function(e) {
try {
let plans = await whop.getPlans()
console.log(plans)
} catch (error) {
alert(error["message"])
}
})
Copy link
Outline
Getting Started
Login
Logout
Get User Info
Check for Logged In User
Get Plans