JavaScript SDK — gjrequest.js

The gjrequest.js library is the official Node.js SDK for interacting with SkunkPlatform via GDPlatform services. It allows you to send messages, read inbox, fetch level scores, and call other GDPlatform endpoints safely.

Installation

Install via npm in your Node.js project:

npm install gjrequest.js

Example Usage

Below is a basic example showing login, reading messages, sending a message, and fetching level scores.

require("dotenv").config();
const { Client } = require("gjrequest.js");

(async () => {
    const client = new Client();

    // Login with environment variables
    await client.login({
        accountID: process.env.GD_ACCOUNT_ID,
        password: process.env.GD_PASSWORD
    });

    // Read inbox messages
    const inbox = await client.readMessages();
    console.log(inbox);

    // Send a message to another account
    const sent = await client.sendMessage(
        29294657,
        "Hello World",
        "This is a test message!"
    );
    console.log(sent);

    // Fetch level scores
    const scores = await client.getLevelScores(1234567);
    console.log(scores);

    // Generic endpoint request
    const response = await client.requestEndpoint("uploadGJMessage20.php", {
        toAccountID: 29294657,
        subject: Buffer.from("Test").toString("base64"),
        body: Buffer.from("Hello!").toString("base64")
    });
    console.log(response);
})();

Important: Do not run requests from this documentation site. Use a local Node.js environment and your own GDPlatform credentials.

← Back to Learning Index