Skip to content
VadVergasov edited this page Jan 20, 2021 · 19 revisions

Table of Contents

api_requests

The main class for the API requests.

CodeforcesApi Objects

class CodeforcesApi(CodeforcesApiRequestMaker)

Class for using official API requests.

__init__

 | __init__(api_key=None, secret=None, random_number=1000000)

Initializing class. All we will need is a session to optimize performance.

blog_entry_comments

 | blog_entry_comments(blog_entry_id)

Get blogEntry.commnets for blog, blog_entry_id required.

Returns parsed response from codeforces.com.

blog_entry_view

 | blog_entry_view(blog_entry_id)

Get blogEntry.view for blog, blog_entry_id required.

Returns parsed response from codeforces.com.

contest_hacks

 | contest_hacks(contest_id)

Get contest.hacks for contest, contest_id required.

Returns parsed response from codeforces.com.

contest_list

 | contest_list(gym=False)

Get all contests you can get all gym by gym parameter.

Returns parsed response from codeforces.com

contest_rating_changes

 | contest_rating_changes(contest_id)

Get contest.ratingChanges for the contest, contest_id required.

Returns parsed response from codeforces.com.

contest_standings

 | contest_standings(contest_id, start=-1, count=-1, handles=[""], room=-1, show_unofficial=False)

Get contest.standings for contest, contest_id required.

From is replaced with a start, because from is reserved python word.

count defines how many submits will be returned.

handles should be a list of handles to get (max 10000).

room is the number of the room which is needed.

show_unofficial is used for adding or removing not official participants.

Returns parsed response from codeforces.com.

contest_status

 | contest_status(contest_id, handle="", start=-1, count=-1)

Get contest.status for contest, contest_id required.

From is replaced with a start, because from is reserved python word.

count defines how many submits will be returned.

handle is used for specifying a user.

Returns parsed response from codeforces.com.

problemset_problems

 | problemset_problems(tags=[""], problemset_name="")

Get problemset.problems.

tags is a list of tags for tasks.

problemset_name is a string with an additional archive name. For example 'acmsguru'.

Returns parsed response from codeforces.com.

problemset_recent_status

 | problemset_recent_status(count, problemset_name="")

Get problemset.recentStatus.

count is the number of returned submits, up to 1000.

problemset_name is a string with an additional archive name.

For example 'acmsguru'.

Returns parsed response from codeforces.com.

recent_actions

 | recent_actions(max_count=100)

Get recentActions.

max_count is the number of returned actions.

max_count should be less or equal to 100.

Returns parsed response from codeforces.com.

user_blog_entries

 | user_blog_entries(handle)

Get user.blogEntries.

handle is required.

Returns parsed response from codeforces.com.

user_friends

 | user_friends(only_online=False)

Get user.friends.

Auth is required for this method, so create a class instance with api_key and secret.

only_online should be boolean.

Returns parsed response from codeforces.com.

user_info

 | user_info(handles)

Get user.info.

handles should be a list of users, up to 10000.

Returns parsed response from codeforces.com.

user_rated_list

 | user_rated_list(active_only=False)

Get user.ratedList.

active_only is used to show only users, which participated last month.

Returns parsed response from codeforces.com.

user_rating

 | user_rating(handle)

Get user.rating.

handle should be a string.

Returns parsed response from codeforces.com.

user_status

 | user_status(handle, start=-1, count=-1)

Get user.status.

handle is required.

From was replaced with a start because from is reserved python word.

count is the number of attempts to return.

Returns parsed response from codeforces.com.

parse_methods

Parse methods from codeforces.com

CodeforcesParser Objects

class CodeforcesParser()

__init__

 | __init__()

Initializing class. All we will need is a session to optimize performance.

get_solution

 | get_solution(contest_id, submit_id)

Returns source code for specified submit.

contest_id is the id of contest.

submit_id is the id of sumbission.

get_tags

 | get_tags(contest_id, index, include_rating=False)

Get tags of the given problem.

contest_id is the number of the contest.

index is the number of the problem, better to be a capital letter. Also could be an integer or lowercase letter.

include_rating is bool which indicates include or not task rating.

__init__

Importing all classes from modules

api_request_maker

Class for generating request URLs, which includes working with random, unpacking parameters, calculating hashes.

CodeforcesApiRequestMaker Objects

class CodeforcesApiRequestMaker()

__init__

 | __init__(api_key=None, secret=None, random_number=1000000)

Initializes main variables: api_key, secret, random (default is between 1 and 1000000 unless specified)

generate_request

 | generate_request(method_name, **fields)

Generates request URL for API.

check_return_code

 | check_return_code(response)

Checks if a returned response is OK.

If not OK Exception will be raised will additional info.

renew_rand

 | renew_rand(random_number=1000000)

It's recommended that you renew your apiSig for each request default is between 100000 and 1000000 unless specified)

Clone this wiki locally