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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jdoodle-client

v1.0.2

Published

JDoodle API client

Downloads

67

Readme

JDoodle API Client

JavaScript JDoodle API client

Distribution

Unpkg - https://unpkg.com/jdoodle-client@latest/dist/

Install

Node

npm install jdoodle-client

All distribution files are in node_modules/jdoodle-client/dist/

Browser

<script src="https://unpkg.com/jdoodle-client@latest/dist/jdoodle-client.browser.js"></script>

Use

Node

const jdoodle = require('jdoodle-client');

// Load JDOODLE_XXX process.env values for configuring endpoints and
// credentials from .env file. This prevents putting personal key info
// into version control. Example template.env is available in the dist folder
require('dotenv').load();

// Use the jdoodle object, example server code (using Koa) might look like that:
httpRouter.post(jdoodle.defaultExecutePath, async ctx => {
  ctx.body = await jdoodle.execute(ctx.request.body);
});

httpRouter.post(jdoodle.defaultCreditSpentPath, async ctx => {
  ctx.body = await jdoodle.creditSpent();
});

Browser

// Use the jdoodle (window.jdoodle) object, example browser code might look like that:
(() => { 'use strict';
  const elem = id => document.getElementById(id);
  const on = (t, e, h) => t.addEventListener(e, h);
  const ready = h => on(document, 'DOMContentLoaded', h);

  ready(() => {
    on(elem('execute'), 'click', async () => {
      // Gather language, versionIndex, stdin, script from UI elements

      let json = await jdoodle.execute({
        language,
        versionIndex: Number(versionIndex) || 0,
        stdin,
        script
      });

      // Use returned json
    });

    on(elem('creditSpent'), 'click', async () => {
      let json = await jdoodle.creditSpent();

      // Use returned json
    });
  });
})();

ES module

// Node
import jdoodle from 'jdoodle-client/dist/jdoodle-client.node';

// Bundlers
import jdoodle from 'jdoodle-client';

// Use the imports

API

The following properties/functions are available through the jdoodle namespace object returned from require('jdoodle-client') on node or available as window.jdoodle in the browser (the ES module has the namespace object as default export):

  • version - library version

  • execute([opts]) - execute code, the opts are:

    • endpoint - node: JDoodle API endpoint, browser: your server endpoint
    • clientId - (node only) JDoodle clientId, set via .env
    • clientSecret - (node only) JDoodle clientSecret, set via .env
    • language - language code
    • versionIndex - language version code (details about language and versionIndex codes)
    • stdin - standard input
    • script - program source
  • creditSpent([opts]) - check spent credit, the opts are:

    • endpoint - node: JDoodle API endpoint, browser: your server endpoint
    • clientId - (node only) JDoodle clientId, set via .env
    • clientSecret - (node only) JDoodle clientSecret, set via .env

    All opts have defaults so just calling the functions is a quick test if things are properly set up, the return value is a promise resolving to JSON even in the presence of errors (containing limited information about the error), for more control use the callExecuteAPI and callCreditSpentAPI variants with appropriate error handling either via promise then-catch chain or try-catch block with async/await

See the example repo for complete code example (the relevant code is in app.js, layout.pug and index.pug)