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

leetcode-apis

v1.0.1

Published

LeetCode, CodeChef, and GeeksforGeeks API client

Readme

npm install leetcode-apis

Programmatic clients and an optional HTTP server that expose a consistent REST surface for LeetCode, CodeChef and GeeksforGeeks data. This package is useful both as an npm dependency (import the leetcode, codechef, and geeksforgeeks clients) and as a standalone server that can be run locally or in production.

Table of contents

  • Installation
  • Usage (package)
  • Usage (server)
  • API reference
  • Publishing to npm
  • Local testing
  • Configuration
  • Contributing & License

Installation

Install from npm (replace with your package name / scope):

npm install leetcode-apis

Or use the repo directly for development:

Set-Location "d:\leetcode-apis"
npm install

Usage (import as a package)

The package exports ready-to-use client instances from src/index.js. Example (ESM):

import { leetcode, codechef, geeksforgeeks } from 'leetcode-gfg-codechef-api';
// LeetCode example
const profile = await leetcode.getUserProfile('your_username');
console.log(profile);

// CodeChef example
const ccProfile = await codechef.scrapeUserProfile('your_username');
console.log(ccProfile);

// GeeksforGeeks example
const gfg = await geeksforgeeks.getUserProfile('your_username');
console.log(gfg);

Refer to the src/controllers and src/utils files for available client methods and response shapes.

Usage (run the server)

Start the server locally (PowerShell):

Set-Location "d:\leetcode-apis"
npm run start

By default the server runs at http://localhost:3000.

Health check: GET /health Root docs: GET / returns a JSON index of exposed endpoints and examples.

API Reference

Base mount points:

  • LeetCode: /leetcode
  • CodeChef: /codechef
  • GeeksforGeeks: /geeksforgeeks

LeetCode

  • GET /leetcode/daily — Daily challenge (processed)
  • GET /leetcode/dailyQuestion — Raw daily question
  • GET /leetcode/select?titleSlug=<slug> — Problem details
  • GET /leetcode/problems — Problems list (query: limit, skip, tags, difficulty)
  • GET /leetcode/:username — User profile
  • GET /leetcode/:username/badges
  • GET /leetcode/:username/solved
  • GET /leetcode/:username/contest
  • GET /leetcode/:username/contest/history
  • GET /leetcode/:username/submission
  • GET /leetcode/:username/acSubmission
  • GET /leetcode/:username/calendar
  • GET /leetcode/userProfile/:username
  • GET /leetcode/languageStats?username=<name>
  • GET /leetcode/skillStats/:username
  • GET /leetcode/userProfileUserQuestionProgressV2/:userSlug
  • GET /leetcode/userContestRankingInfo/:username
  • GET /leetcode/user/:username/complete

Discussions (LeetCode)

  • GET /leetcode/trendingDiscuss?first=<n>
  • GET /leetcode/discussTopic/:topicId
  • GET /leetcode/discussComments/:topicId

CodeChef

  • GET /codechef/user/:username
  • GET /codechef/user/:username/rating
  • GET /codechef/user/:username/ranking
  • GET /codechef/user/:username/stats
  • GET /codechef/contests

GeeksforGeeks

  • GET /geeksforgeeks/user/:username
  • GET /geeksforgeeks/user/:username/stats
  • GET /geeksforgeeks/user/:username/solved
  • GET /geeksforgeeks/user/:username/practice
  • GET /geeksforgeeks/user/:username/contests
  • GET /geeksforgeeks/user/:username/school
  • GET /geeksforgeeks/user/:username/complete
  • GET /geeksforgeeks/problem-of-the-day

Examples (PowerShell)

# LeetCode daily
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/daily"

# Problem details
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/select?titleSlug=two-sum"

# CodeChef profile
Invoke-RestMethod -Uri "http://localhost:3000/codechef/user/some_user"

# GeeksforGeeks problem of the day
Invoke-RestMethod -Uri "http://localhost:3000/geeksforgeeks/problem-of-the-day"

Publishing to npm

Before publishing, ensure package.json includes the correct fields:

  • name: set to the package name (scoped packages recommended, e.g. @your-scope/leetcode-gfg-codechef-api).
  • version: follow semver.
  • description: short package description.
  • main / module: entry file for consumers.
  • files: list files/folders to include in the package (minimize size).
  • repository, license, keywords, author.

First publish (scoped package):

npm login
npm publish --access public

Subsequent publishes:

npm version patch   # or minor / major
npm publish

If you publish an unscoped package you can omit --access public.

Local testing and linking

To test the package locally from another project use npm pack or npm link:

# Create tarball
cd d:\leetcode-apis
npm pack

# In test project
npm install ../d\-leetcode-apis/leetcode-gfg-codechef-api-1.0.0.tgz

Or:

cd d:\leetcode-apis
npm link

# In test project
npm link leetcode-gfg-codechef-api

Configuration & Environment

Environment variables respected by the server:

  • PORT — port to run the server (default 3000)
  • NODE_ENV — environment name
  • YOUR_DOMAIN — optional

Rate limiting is enabled via src/middleware/rateLimiter.js. Keep usage reasonable and respect upstream terms of service.

Development

  • Entry: server.js mounts routers in src/routes.
  • Exported clients: src/index.js.
  • Controllers and utility clients live in src/controllers and src/utils.

Contributing

Contributions and issues are welcome. Please:

  1. Open an issue describing the problem or feature.
  2. Fork the repo and send a PR with tests or a clear description of changes.

License

Add a license to package.json (MIT recommended) and include a LICENSE file in the repo.


If you'd like, I can now:

  • Add an example package.json configured for npm publishing.
  • Create a minimal dist build step and npm prepublish script.

Which of those should I add next?

Placeholder update to match patch requirements before replacing file fully.

LeetCode, CodeChef & GeeksforGeeks Unified API

Fast, production-ready REST API to query LeetCode, CodeChef, and GeeksforGeeks data: daily problems, problem details and lists, user profiles, submissions, contests, rankings, language and skill stats, and discussion threads.

Runs on Express with security hardening (Helmet), CORS, compression, and rate limiting.

Quick Start

  • Prerequisites: Node.js 18+ and PowerShell (pwsh).
  • Install dependencies:
Set-Location "d:\leetcode-apis"
npm install
  • Start the server:
npm run start
  • Health check: http://localhost:3000/health
  • API docs summary: http://localhost:3000/

Configuration

  • Environment variables (optional):
    • PORT: API port (default 3000).
    • NODE_ENV: environment label (development by default).
    • YOUR_DOMAIN: used only for logging or custom setups.

Rate limiting is enabled via src/middleware/rateLimiter.js. Keep test traffic reasonable.

Base Paths

  • LeetCode routes: http://localhost:3000/leetcode/...
  • CodeChef routes: http://localhost:3000/... (prefixes begin with /codechef/...)
  • GeeksforGeeks routes: http://localhost:3000/... (prefixes begin with /geeksforgeeks/...)

LeetCode API Endpoints

  • GET /leetcode/daily: Daily challenge question (processed view).
  • GET /leetcode/dailyQuestion: Raw daily question data.
  • GET /leetcode/select?titleSlug=<slug>: Question details for a specific problem.
  • GET /leetcode/problems: Problems list.
    • Query params: limit, skip, tags (space or + separated), difficulty (EASY|MEDIUM|HARD).
  • GET /leetcode/:username: User profile summary.
  • GET /leetcode/:username/badges: User badges.
  • GET /leetcode/:username/solved: Solved count & breakdown.
  • GET /leetcode/:username/contest: Contest participation details.
  • GET /leetcode/:username/contest/history: Full contest history (most recent first).
  • GET /leetcode/:username/contest/history?attendedOnly=true: Attended contests only.
  • GET /leetcode/:username/submission: Recent submissions.
  • GET /leetcode/:username/acSubmission: Accepted submissions only.
  • GET /leetcode/:username/calendar: Submission calendar.
  • GET /leetcode/userProfile/:username: Full profile in a single call.
  • GET /leetcode/languageStats?username=<name>: Language statistics.
  • GET /leetcode/skillStats/:username: Skill statistics.
  • GET /leetcode/userProfileUserQuestionProgressV2/:userSlug: Question progress.
  • GET /leetcode/userContestRankingInfo/:username: Contest ranking info.
  • GET /leetcode/user/:username/complete: Aggregate of all user data in one call.

LeetCode Examples (PowerShell)

# Daily
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/daily"

# Problem details
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/select?titleSlug=two-sum"

# Problems list with filters
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/problems?limit=10&tags=array+string&difficulty=EASY"

# User complete data
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/user/john_doe/complete"

Discussion Endpoints (LeetCode)

  • GET /leetcode/trendingDiscuss?first=<n>: Trending discussions.
  • GET /leetcode/discussTopic/:topicId: Discussion topic details.
  • GET /leetcode/discussComments/:topicId: Comments for a topic.

Discussion Examples

Invoke-RestMethod -Uri "http://localhost:3000/leetcode/trendingDiscuss?first=10"
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/discussTopic/12345"
Invoke-RestMethod -Uri "http://localhost:3000/leetcode/discussComments/12345"

CodeChef API Endpoints

  • GET /codechef/user/:username: User profile.
  • GET /codechef/user/:username/rating: User rating (returns 0 if no contests).
  • GET /codechef/user/:username/ranking: User ranking.
  • GET /codechef/user/:username/stats: Complete user statistics.
  • GET /codechef/contests: Contest list.

CodeChef Examples

Invoke-RestMethod -Uri "http://localhost:3000/codechef/user/john_doe"
Invoke-RestMethod -Uri "http://localhost:3000/codechef/user/john_doe/rating"
Invoke-RestMethod -Uri "http://localhost:3000/codechef/contests"

GeeksforGeeks API Endpoints

  • GET /geeksforgeeks/user/:username: User profile.
  • GET /geeksforgeeks/user/:username/stats: User statistics.
  • GET /geeksforgeeks/user/:username/solved: Solved problems.
  • GET /geeksforgeeks/user/:username/practice: Practice problems overview.
  • GET /geeksforgeeks/user/:username/contests: Contest history.
  • GET /geeksforgeeks/user/:username/school: School progress.
  • GET /geeksforgeeks/user/:username/complete: Aggregate of all user data.
  • GET /geeksforgeeks/problem-of-the-day: Problem of the day.

GeeksforGeeks Examples

Invoke-RestMethod -Uri "http://localhost:3000/geeksforgeeks/user/john_doe"
Invoke-RestMethod -Uri "http://localhost:3000/geeksforgeeks/problem-of-the-day"

Health & Root

  • GET /health: Server health status and metadata.
  • GET /: JSON index summarizing all endpoints and examples.

Error Handling

  • 404: Unknown route returns structured JSON with path and timestamp.
  • Central error middleware formats unexpected errors consistently.

Notes

  • Public endpoints; no API key required.
  • Respect rate limits and upstream site policies.
  • Responses mirror upstream structures where applicable; fields can evolve.

Development

  • Entry: server.js mounts routers from src/routes/*.
  • Core clients in src/utils/* and controllers in src/controllers/*.
  • Exported SDK-like clients: src/index.js exports leetcode, codechef, geeksforgeeks for programmatic use.

License

This project is intended for personal or educational use. Do not abuse upstream services.