Skip to main content

A Python library for interacting with Codeforces API and automating tasks.

Project description

cf-helper Library

A Python library for interacting with the Codeforces API, allowing you to fetch user information, ratings, problems, contests, and more.


Table of Contents


Installation

To use cf-helper, you need to install the library. Ensure you have pip installed on your system.

pip install cf-helper

API Key Setup (Optional)

To access private data via the Codeforces API, you'll need to generate an API key:

  1. Go to Codeforces: Visit Codeforces API Settings.
  2. Create a New API Key: Provide a name for the key. Codeforces will generate:
    • Key: The public part of the API key.
    • Secret: A private part used for signing requests.
  3. Store the Key and Secret:
    • Add your key and secret to a .env file in your project directory:
      key="your_api_key"
      secret="your_api_secret"
      

Usage

Importing the Library

The library provides utilities for easy interaction with the Codeforces API. Simplify your imports using the cf_helper package.

from cf_helper import *
# No need to do below steps if only public functions are used
from dotenv import load_dotenv
import os

load_dotenv()
key = os.getenv("key")
secret = os.getenv("secret")

Examples

Below are examples of various functions provided by the library.

Fetch User Information

handle = "CodeLegendX"
print_user_info(handle)

Fetch User Status

print_user_status(handle, noOfEntries=2)

Fetch User Friends

print_user_friends(handle, key, secret, noOfFriends=2)

Fetch Problems

print_problems(noOfEntries=2, tags="dp", rating=1900)

Fetch Contest Rating Changes

print_rating_changes(contest_id=2040, noOfEntries=2)

Fetch User Contest Rating Change

print_user_rating_change(contest_id=2040, handle="CodeLegendX")

Fetch Accepted Submission

print_submission_link(handle, contestId=2040, index='C')

Fetch Contest Standings

print_contest_standings(contestId=2040, from_index=1, count=5, showUnofficial=True)

Fetch User Standing in Contest

print_user_standing(contestId=2006, handles="tourist;jiangly", showUnofficial=True)

Functions

  • print_user_info(handle): Display user information in a readable format.
  • print_user_status(handle, noOfEntries): Display user submission status.
  • print_user_friends(handle, key, secret, noOfFriends, only_online): Display user friends.
  • print_problems(noOfEntries, tags, rating): Display problems.
  • print_rating_changes(contest_id, noOfEntries): Display contest rating changes.
  • print_user_rating_change(contest_id, handle):: Display user contest rating change.
  • print_submission_link(handle, contestId, index): Display accepted submission link.
  • print_contest_standings(contestId, from_index, count, showUnofficial): Display contest standings.
  • print_user_standing(contestId, handles, showUnofficial): Display standings for specific handles in a contest.

Limitations

  • Public Data Only: Without an API key, only public data is accessible.
  • Rate Limits: The Codeforces API has rate limits. Avoid excessive requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cf_helper-0.2.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cf_helper-0.2.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file cf_helper-0.2.1.tar.gz.

File metadata

  • Download URL: cf_helper-0.2.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for cf_helper-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c834000fdc344de97184d9ce633667fd9dbf8e9339d2da8e7c5e420f0ea1b439
MD5 40e8e11244625c96a39dceee7b841ad4
BLAKE2b-256 395b5a8f75b70b88db30a9184faf380677c3ae6243702c84dc7c22c77c4ad258

See more details on using hashes here.

File details

Details for the file cf_helper-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cf_helper-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for cf_helper-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a062e55467a5a5b4fe9bd28958e03c49f00ff0a856c3deef83f68826869a3341
MD5 ba9c474482da6aa6514fc6cc420fc1e8
BLAKE2b-256 5d4f0ee7861beb6b06029044a108a36a26435507d1bf55ebf9cbc8dc279e6174

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page