npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

unofficial-gojek-api

v1.0.3

Published

This is an unofficial Gojek API for Node.js

Readme

Getting Started

Install package

  • yarn
yarn add unofficial-gojek-api
  • npm
npm install unofficial-gojek-api

Example

import fs from "fs";
import readline from "readline";
import GojekAPI from "unofficial-gojek-api";
require("dotenv").config();

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const prompt = (query: any) =>
  new Promise((resolve) => rl.question(query, resolve));

// You need to store your phone number and pin (this example, i store on .env)
const phone = process.env.PHONE;
const pin = process.env.PIN;

if (!phone || !pin) {
  throw new Error("Phone number or pin is required on environment variable");
}

// Create storage to save access token and refresh token
if (!fs.existsSync("./account.json")) {
  fs.writeFileSync(
    "./account.json",
    JSON.stringify({
      accessToken: null,
      refreshToken: null,
    })
  );
}

const account = JSON.parse(fs.readFileSync("./account.json").toString()) as {
  accessToken: string | null;
  refreshToken: string | null;
};

(async () => {
  try {
    const gojek = new GojekAPI();
    if (!account.accessToken) {
      const login = await gojek.login(phone);
      if (!login.success) {
        throw login;
      }

      const otpInput = (await prompt("OTP code: ")) as string;

      const accessToken = await gojek
        .verifyOTP(otpInput, login.data.otp_token)
        .catch(async (err: any) => {
          if (
            err.errors[0].code ===
            "mfa:customer_send_challenge:challenge_required"
          ) {
            const challengeId =
              err.errors[0].details.challenges[0].gopay_challenge_id;
            const challengeToken = err.errors[0].details.challenge_token;

            const challenge = await gojek.verifyMFA(challengeId, pin);

            if (challenge.success) {
              const accessToken = await gojek.verifyMFAToken(
                challengeToken,
                challenge.data.token
              );
              return accessToken;
            } else {
              throw challenge;
            }
          } else {
            throw err;
          }
        });

      fs.writeFileSync(
        "./account.json",
        JSON.stringify({
          ...account,
          accessToken: accessToken.access_token,
          refreshToken: accessToken.refresh_token,
        })
      );

      gojek.setToken(accessToken.access_token);
    } else {
      gojek.setToken(account.accessToken);
      const token = await gojek.relogin(phone, pin);
      const { access_token, refresh_token } = token;
      fs.writeFileSync(
        "./account.json",
        JSON.stringify({
          ...account,
          accessToken: access_token,
          refreshToken: refresh_token,
        })
      );
      gojek.setToken(access_token);
    }

    const balance = await gojek.getBalance();

    if (!balance.success) {
      throw balance;
    }
    balance.data.map((item: any) =>
      console.log(
        `[${item.type}] ${item.balance.currency === "IDR" ? "Rp" : ""}${
          item.balance.value
        }`
      )
    );

    process.exit(0);
  } catch (error) {
    console.log("Error", error);
    process.exit(1);
  }
})();