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 🙏

© 2024 – Pkg Stats / Ryan Hefner

codeforces-plus

v1.0.3

Published

A Typescript library to simplify Codeforces API

Downloads

251

Readme

Codeforces Plus - A Simplified Codeforces API Client in TypeScript

npm version License: MIT Typescript

codeforces-plus is a TypeScript library that abstracts the complexity of interacting with the Codeforces API. It provides a simple and easy-to-use interface to fetch data from Codeforces, eliminating the need for managing API requests or handling API authentication.

With codeforces-plus, you can quickly access data like contest standings, user submissions, problem details, and much more without worrying about API types and intricate authentication steps.


Key Features

  • Strongly Typed: Fully typed methods and parameters, providing type safety and code completion in TypeScript.
  • 🖥️ Auto-Completion: Enjoy IntelliSense features in your IDE, including suggestions for functions, types, and parameters as you type.
  • 🔄 Seamless API Integration: Automatically handles API signing for requests requiring authorization.
  • 🚀 Simple to Use: Concise methods that eliminate manual API request creation.
  • 🔑 Easy Authentication: Supports API key and secret-based authentication.
  • 🛡️ Error Handling: Provides consistent error responses for easy debugging.

Installation

You can install codeforces-plus via npm or yarn.

Using npm:

npm install codeforces-plus

Using yarn:

yarn add codeforces-plus

Quick Start

Below is an example of how to use the library to interact with the Codeforces API using codeforces-plus package, such as fetching contest standings.

import {FetchCodeforcesData} from "codeforces-plus";

const demoFun= async () => {
  const res=await FetchCodeforcesData({
    creds:{                         // creds object is optional
      apiKey:"API_KEY",
      apiSecret:"API_SECRET"
    },
    method:"contest.standings",
    props:{
      contestId:566,
      asManager:true,
      participantTypes:"CONTESTANT"
    }
  })

  console.log(res)
}

demoFun()

Without API Credentials

For public API methods, you can omit the creds object:

import {FetchCodeforcesData} from "codeforces-plus";

const demoFun= async () => {
  const res=await FetchCodeforcesData({
    method:"recentActions",
    props:{
      maxCount:1
    }
  })

  console.log(res)
}

demoFun()

Api Response

In case of errors during the API request, FetchCodeforcesData returns a response object that includes the status and error fields. Example of error handling:

{
  status: 'OK',
  result: [
    { timeSeconds: 1727572643, blogEntry: [Object], comment: [Object] },
    { timeSeconds: 1727570332, blogEntry: [Object], comment: [Object] },
    { timeSeconds: 1727568558, blogEntry: [Object], comment: [Object] },
    { timeSeconds: 1727568011, blogEntry: [Object], comment: [Object] },
    { timeSeconds: 1727567865, blogEntry: [Object], comment: [Object] }
  ],
  queryUrl: 'https://codeforces.com/api/recentActions?maxCount=5'
}

Authentication Credentials

For authenticated requests, you need to provide your Codeforces API key and secret. To generate these credentials, follow these steps:

  • Log in to your Codeforces account.
  • Go to your API settings page.
  • Generate and store your API key and secret.

The codeforces-plus library will handle signing requests by calculating an apiSig based on your API credentials.

Method Types

An image showing auto-completion of methods

Props Types

An image showing auto-completion of props

Contributing

I welcome contributions! Whether it’s fixing a bug, improving the documentation, or adding new features, feel free to open an issue or submit a pull request.

To contribute:

  • Fork this repository.
  • Create a new branch (git checkout -b feature/your-feature-name).
  • Commit your changes (git commit -m 'Add new feature').
  • Push the branch (git push origin feature/your-feature-name).
  • Open a pull request.

License

This project is licensed under the MIT License. Feel free to use it as you wish.

Contact

For support or questions, please create an issue in the repository.

Changelog

v1.0.0 - Release with support for all Codeforces API methods.