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.0.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.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file cf-helper-0.2.0.tar.gz.

File metadata

  • Download URL: cf-helper-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 42aaa21c7595286be25253c7af07f7f52aebb3aa5c2e48f3b4b51c74f28c88bd
MD5 b105600cba32a006a0b7c813ceed1d30
BLAKE2b-256 d94ec0a5126961b12bf0d8e61c89b21917c34668a3ba1b28f58cb408c8fa1b37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cf_helper-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89c5e874cebfd1d6419ca000d062917e01015a158eda17649847281b3d3570ff
MD5 257a57974aa2be5e1bddd3210753e6dd
BLAKE2b-256 395000a5d62d8e484643ea920db84ec7bfc8d26811aed5e71b7d8196042d6187

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