Enviroment Setup

Congratulations! You have successfully understood how the Whop API works and how to do basic functions, let's start now with our Advanced Guide.

Advanced Guide

In this Tutorial we will be using NodeJS as our primary language.

We will be using the following modules.

  • dotenv
    Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.
  • express
    Express is a Fast, unopinionated, minimalist web framework for Node.js.
  • express-session
    The session cookie is a server-specific cookie that cannot be passed to any machine other than the one that generated the cookie. The server creates a “session ID” which is a randomly generated number that temporarily stores the session cookie. This cookie stores information such as the user’s id and tracks the movements of the user within the website. There is no other information stored in the session cookie. express-session is our middleware for the cookie session.
  • mongoose
    Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks.
  • connect-mongo
    MongoDB session store for express-session
  • passport
    Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more.
  • passport-discord
    Passport strategy for authentication with Discord through the OAuth 2.0 API.
  • ejs
    What is the "E" for? "Embedded?" Could be. How about "Effective," "Elegant," or just "Easy"? EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. No religiousness about how to organize things. No reinvention of iteration and control-flow. It's just plain JavaScript.
  • path
    The node:path module provides utilities for working with file and directory paths.
  • [email protected]
    A light-weight module that brings Fetch API to Node.js.

Create a folder and cd into it:

mkdir our-awesome-project
cd our-awesome-project

Or simply right click and create a new folder if you are using Windows/MacOS.

Now we will need to initialize our project by using the following command:

npm init -y

Then we will install our modules using this command:

npm install dotenv express express-session mongoose connect-mongo passport passport-discord ejs path [email protected]

Version 2 supports CommonJs require('node-fetch') method, higher versions only supports ES6 import fetch from 'node-fetch'.


We will be using MongoDB as our database, so we will need to create a MongoDB database.

Let's download MongoDB from here.


After you have downloaded MongoDB, let's install it and make sure to install MongoDB Compass as well.

495495 495495 495495

Discord Developer Portal

We will be using the Discord Developer Portal to create our Discord Application.

Let's create a new application by clicking here.

Click on the New Application button and give your application a name.

13361336 440440

After you have created your application, let's copy your Client ID and Client Secret.

Go to the OAuth2 tab and click on the General button.


Now let's create our callback URL, we will be using http://localhost/auth/callback as our callback URL.


Make sure to save your changes.



Awesome! now that you have initialized your project and installed the required modules let's head to the next tutorial.