Блог пользователя Droby

Автор Droby, 11 месяцев назад, По-английски

Introducing atcoder-api — A TypeScript/JavaScript Wrapper for AtCoder

Hi Codeforces!

I'm excited to share a new npm package I built:
atcoder-api — a lightweight and fully typed API wrapper to fetch user stats, contest info, and rating history from AtCoder!


Features

  • Fetch upcoming and recent contests
  • Get detailed user profiles and statistics
  • Retrieve user contest participation history
  • Built-in rate limiting to avoid server overload
  • TypeScript support out of the box
  • Lightweight and fast

Installation

npm install @qatadaazzeh/atcoder-api

Usage

Fetching Contests

import { fetchUpcomingContests, fetchRecentContests } from '@qatadaazzeh/atcoder-api';

// Get upcoming contests
const upcoming = await fetchUpcomingContests();
console.log('Found '+ upcoming.length +' upcoming contests');

// Get recent contests
const recent = await fetchRecentContests();
console.log('Found ' + recent.length+  ' recent contests');

Getting User Info

import { fetchUserInfo } from '@qatadaazzeh/atcoder-api';

// Get user profile
const user = await fetchUserInfo('tourist');
console.log(user.userName + 'has a rating of ' + user.userRating);

// Access contest history
console.log('Participated in ' + user.userContests.length +' contests');

User Contest History

import { fetchUserContestList } from '@qatadaazzeh/atcoder-api';

// Get contest participation history for a user
const contestHistory = await fetchUserContestList('tourist');

// Find contests where the user's performance was above 3000
const highPerformance = contestHistory.filter(c => c.userPerformance > 3000);
console.log(highPerformance.length + ' contests with performance > 3000');

API Reference

Contest Functions

  • fetchContestList(type?: 'upcoming' | 'recent')
  • fetchUpcomingContests()
  • fetchRecentContests()

User Functions

  • fetchUserInfo(userId: string)
  • fetchUserContestList(userId: string)

TypeScript Types Exported

  • Contest — metadata about each contest
  • User — profile and rating details
  • UserContest — performance in contests

Notes

  • Not affiliated with AtCoder — it scrapes publicly available endpoints.
  • Please respect rate limits to avoid overwhelming servers.
  • MIT licensed and open to contributions!

Links


Feedback, suggestions, and contributions are welcome.
If you use it to build something cool — let me know in the comments!

Happy hacking and good luck in your contests!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится