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-api

v1.0.3

Published

Codeforces API Client Library for Node.js

Downloads

13

Readme

NodeJS Client Library for Codeforces API

Build Status Coverage Status npm version Dependency Status

codeforces-api-node is a simple NodeJS library for Codeforces Api with streaming support.

Install

$ npm install codeforces-api

Usage

codeforces-api-node supports both ES5 and ES6.

Basic


//ES5
var Codeforces = require('codeforces-api');

//ES2015
import Codeforces from 'codeforces-api';

//set API keys for authentication
Codeforces.setApis('your_codeforces_api_key', 'your_codeforces_api_secret');


Codeforces.method( parameters , callback );

Usage

Codeforces.user.rating({ handle: 'user_handle' } , function (err, data) {

    if (err) {
        //handle error and return
    }

    //use data
});

Methods & Parameters

Full description of the API can be found on : Official API Doc

| Method | Parameters | Description | | ----------------------- | ------------------------------------------------------------ |:-------------------------------------------------------------------:| | blogEntry.comments | *blogEntryId | More | | blogEntry.view | *blogEntryId | More | | contest.hacks | contestId | More | | contest.list | gym | More | | contest.ratingChanges | *contestId | More | | contest.standings | *contestId , from , count , handles , room , showUnofficial | More | | contest.status | *contestId , handle , from , count | More | | problemset.problems | tags | More | | problemset.recentStatus | *count | More | | recentActions | *maxCount | More | | user.blogEntries | *handle | More | | user.friends | onlyOnline | More | | user.info | *handles | More | | user.ratedList | activeOnly | More | | user.rating | *handle | More | | user.status | *handle , from , count | More |

*required parameters

Note

handles and tags can be multiple.There are two different ways to set:

  1. Semicilon-separated string:
tags: 'greedy;dp;graphs'
  1. As array:
tags: ['greedy','dp','graphs']

Authorization

Although most of the method of the API supports anonymously request, codeforces-api-node does not allow anonymous request yet.To access API data, must set API and SECRET key before calling methods.To generate API and SECRET KEY visit: API Settings

Return Data

All data return in JSON format.For full description of data format visit: Return Objects

Streaming

This feature and example from npm request package. For more have a look : Request Package Doc

You can stream responses to a file stream.When json data is huge, you may need this feature.

Codeforces.user.ratedList( parameters, callback )
               .pipe( fs.createWriteStream('./rateedList.json') );

//version >= 1.0.2 (with or without callback)
Codeforces.user.ratedList( parameters )
               .pipe( fs.createWriteStream('./ratedList.json') );

Also emits response events.

Codeforces.user.ratedList( parameters, function(err, data){

    if(err){ //request error  }

    //data also available here

}).on('data', function(data) {
    // decompressed data as it is received
    console.log('decoded chunk: ' + data)
})
.on('response', function(response) {

    // unmodified http.IncomingMessage object
    response.on('data', function(data) {
        // compressed data as it is received
        console.log('received ' + data.length + ' bytes of compressed data')
    });

}).pipe( fs.createWriteStream('./ratedList.json') );

Contributing

Everyone wellcome!

  • Create an issue > Fork > Create own branch > Commit changes > Push the branch > Creat pull request

Test

Before running test, must set API and SECRET key in environment variable.Keys are:

CFK = API Key
CFS = API Secret

After setting keys, simply run

npm test

License

MIT © Ahmed Dinar