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

@ronits2407/cp-api

v1.0.8

Published

One unified, fault-tolerant SDK to fetch contests, profiles, problems, submissions, and analytics from all major competitive programming platforms.

Readme

@ronits2407/cp-api 🏆

One unified, fault-tolerant SDK to fetch upcoming contests, user profiles, problem sets, submissions, and analytics from all major competitive programming platforms.

npm version License: MIT

Scraping and aggregating competitive programming data is notoriously fragmented. Codeforces has a clean REST API, LeetCode requires GraphQL, and AtCoder lacks a reliable official API.

@ronit/cp-api abstracts all this pain away. It provides a single, robust, and highly configurable TypeScript API replacing hundreds of lines of scraping code with single-line, declarative commands.

✨ Features

  • 🌐 Universal Support: Natively supports Codeforces, AtCoder, LeetCode, and CodeChef.
  • 🚀 Unified API: Fetch aggregated upcoming contests, compare users across platforms, and get unified analytics.
  • 🛡️ Production-Grade Resilience: Built-in HTTP client with exponential backoff, jitter, and automatic retry on 429/503.
  • 🚦 Intelligent Rate Limiting: Token-bucket rate limiting configurable per-platform to never get IP-banned.
  • ⚡ Blazing Fast Cache: Built-in LRU caching for all endpoints to minimize network overhead.
  • 📊 Analytics Engine: Compute common solved problems, rating progress, and tag/difficulty distributions on the fly.
  • 🎯 Strongly Typed: 100% TypeScript with full interfaces for all platform responses.

📦 Installation

npm install @ronit/cp-api
# or
yarn add @ronit/cp-api
# or
pnpm add @ronit/cp-api

🛠️ Configuration

Configure the SDK globally. It uses deep-merging, so you only need to specify what you want to change:

import { cp } from '@ronit/cp-api';

cp.configure({
  rateLimit: {
    enabled: true,
    strategy: 'token-bucket',
    onRateLimit: 'wait',
    platforms: {
      codeforces: { requestsPerSecond: 2 }, // Aggressive
      leetcode: { requestsPerSecond: 0.5 }  // Conservative
    }
  },
  http: {
    timeout: 15000,
    maxRetries: 3
  },
  cache: {
    enabled: true,
    ttlMs: 5 * 60 * 1000 // 5 minutes
  }
});

🚀 Quick Start

1. The Unified Contests Feed

Get all upcoming contests across all platforms, sorted by start time:

const upcoming = await cp.contests.getUpcoming({
  platforms: ['CODEFORCES', 'LEETCODE', 'ATCODER'],
  keywords: ['div. 2', 'weekly'], // Filter by name
  limit: 5
});

2. Comprehensive User Profiles

Fetch a user's unified data, optionally pulling in their full problem history and streaks in parallel:

const profile = await cp.users.get('tourist', {
  platforms: ['CODEFORCES', 'ATCODER'],
  includeSubmissions: true,
  includeStreak: true,
  includeRatingHistory: true
});

3. Analytics & Insights

Compare multiple users or get deep insights into a single user's performance:

// Find problems solved by both users
const common = await cp.analytics.getCommonSolvedProblems(['tourist', 'jiangly'], 'CODEFORCES');

// Get tag distribution (e.g. dp: 150, math: 120, graphs: 90)
const tags = await cp.analytics.getTagDistribution('tourist');

// Get difficulty distribution buckets
const difficulty = await cp.analytics.getDifficultyDistribution('tourist', 'CODEFORCES');
// Returns: { '<800': 10, '800-1199': 45, '2400+': 890 }

🧩 Deep-Dive Platform APIs

If you need platform-specific features, access them directly through the singleton:

Codeforces

const heatmap = await cp.codeforces.getUserActivityHeatmap('tourist');
const randomHard = await cp.codeforces.getRandomProblem({ minRating: 2400, tags: ['dp'] });
const hacks = await cp.codeforces.getHackResults('1234');

LeetCode

const daily = await cp.leetcode.getDailyChallenge();
const solvedCount = await cp.leetcode.getUserSolvedCount('neal_wu');

AtCoder

const acProblems = await cp.atcoder.getUserSolvedProblems('tourist', { minDifficulty: 2000 });
const ranking = await cp.atcoder.getTopRatedUsers(100);

🩺 System Health & Observability

Ensure all platforms are reachable before running batch jobs:

const health = await cp.health.check();
console.log(health.filter(h => !h.reachable)); // Find downed platforms

Listen to internal events for logging:

cp.on('fetch:error', (data) => console.error(`Failed ${data.platform}:`, data.error));
cp.on('rateLimit:wait', (data) => console.warn(`Throttling ${data.platform}...`));

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

📝 License

This project is MIT licensed.