import Whop from '@whop/sdk';
const client = new Whop({
apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const membershipListResponse of client.memberships.list()) {
console.log(membershipListResponse.id);
}{
"data": [
{
"id": "mem_xxxxxxxxxxxxxx",
"status": "trialing",
"created_at": "2023-12-01T05:00:00.401Z",
"joined_at": "2023-12-01T05:00:00.401Z",
"updated_at": "2023-12-01T05:00:00.401Z",
"manage_url": "https://whop.com/billing/manage/mem_abc123",
"member": {
"id": "mber_xxxxxxxxxxxxx"
},
"user": {
"id": "user_xxxxxxxxxxxxx",
"username": "johndoe42",
"name": "John Doe",
"email": "john.doe@example.com"
},
"renewal_period_start": "2023-12-01T05:00:00.401Z",
"renewal_period_end": "2023-12-01T05:00:00.401Z",
"cancel_at_period_end": true,
"cancel_option": "too_expensive",
"cancellation_reason": "I found a better alternative.",
"canceled_at": "2023-12-01T05:00:00.401Z",
"currency": "usd",
"company": {
"id": "biz_xxxxxxxxxxxxxx",
"title": "Pickaxe"
},
"plan": {
"id": "plan_xxxxxxxxxxxxx"
},
"promo_code": {
"id": "promo_xxxxxxxxxxxx"
},
"product": {
"id": "prod_xxxxxxxxxxxxx",
"title": "Pickaxe Analytics"
},
"license_key": "A1B2C3-D4E5F6-G7H8I9",
"metadata": {},
"payment_collection_paused": true
}
],
"page_info": {
"end_cursor": "<string>",
"start_cursor": "<string>",
"has_next_page": true,
"has_previous_page": true
}
}Returns a paginated list of memberships, with optional filtering by product, plan, status, and user.
Required permissions:
member:basic:readmember:email:readimport Whop from '@whop/sdk';
const client = new Whop({
apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const membershipListResponse of client.memberships.list()) {
console.log(membershipListResponse.id);
}{
"data": [
{
"id": "mem_xxxxxxxxxxxxxx",
"status": "trialing",
"created_at": "2023-12-01T05:00:00.401Z",
"joined_at": "2023-12-01T05:00:00.401Z",
"updated_at": "2023-12-01T05:00:00.401Z",
"manage_url": "https://whop.com/billing/manage/mem_abc123",
"member": {
"id": "mber_xxxxxxxxxxxxx"
},
"user": {
"id": "user_xxxxxxxxxxxxx",
"username": "johndoe42",
"name": "John Doe",
"email": "john.doe@example.com"
},
"renewal_period_start": "2023-12-01T05:00:00.401Z",
"renewal_period_end": "2023-12-01T05:00:00.401Z",
"cancel_at_period_end": true,
"cancel_option": "too_expensive",
"cancellation_reason": "I found a better alternative.",
"canceled_at": "2023-12-01T05:00:00.401Z",
"currency": "usd",
"company": {
"id": "biz_xxxxxxxxxxxxxx",
"title": "Pickaxe"
},
"plan": {
"id": "plan_xxxxxxxxxxxxx"
},
"promo_code": {
"id": "promo_xxxxxxxxxxxx"
},
"product": {
"id": "prod_xxxxxxxxxxxxx",
"title": "Pickaxe Analytics"
},
"license_key": "A1B2C3-D4E5F6-G7H8I9",
"metadata": {},
"payment_collection_paused": true
}
],
"page_info": {
"end_cursor": "<string>",
"start_cursor": "<string>",
"has_next_page": true,
"has_previous_page": true
}
}A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************
Returns the elements in the list that come after the specified cursor.
Returns the elements in the list that come before the specified cursor.
Returns the first n elements from the list.
42
Returns the last n elements from the list.
42
The unique identifier of the company to list memberships for. Required when using an API key.
"biz_xxxxxxxxxxxxxx"
The sort direction for results. Defaults to descending.
asc, desc The field to sort results by. Null uses the default sort order.
id, created_at, status, canceled_at, date_joined, total_spend Filter to only memberships belonging to these product identifiers.
Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.
Filter to only memberships matching these statuses.
The status of a membership
trialing, active, past_due, completed, canceled, expired, unresolved, drafted, canceling Filter to only memberships matching these cancellation reasons.
The different reasons a user can choose for why they are canceling their membership.
too_expensive, switching, missing_features, technical_issues, bad_experience, other, testing Filter to only memberships belonging to these plan identifiers.
Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.
Filter to only memberships belonging to these user identifiers.
Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.
Filter to only memberships that used these promo code identifiers.
Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "VXNlci0xMA==") or integer (such as 4) input value will be accepted as an ID.
Only return memberships created before this timestamp.
"2023-12-01T05:00:00.401Z"
Only return memberships created after this timestamp.
"2023-12-01T05:00:00.401Z"
Was this page helpful?