API

codeforces

api

Functions to call the codeforces api.

codeforces.api.call(method, key=None, secret=None, **kwargs)

Call a Codeforces API method.

Parameters:
  • method (str) – Name of method to call, list of all methods can be found at https://codeforces.com/api/help.
  • key (str, optional) – Your api key (needed for authorized calls)
  • secret (str, optional) – Secret for your api key.
  • **kwargs – Arguments for the api call
Returns:

A python object containing the results of the api call.

Return type:

any

problem

Functions to info about a problem.

codeforces.problem.get_info(contest_id, index, gym=False, lang='en')

Get info for a contest problem.

Parameters:
  • contest_id (int) – Id of the contest. It is not the round number. It can be seen in contest URL. For example: /contest/566/status
  • index (str) – Usually a letter of a letter, followed by a digit, that represent a problem index in a contest. It can be seen in problem URL. For example: /contest/566/A
  • gym (bool) – If true gym problem is returned otherwise regular problem is returned.
Returns:

  • title (str) – Title of the problem.
  • time_limit (str) – Time limit specification for the problem.
  • memory_limit (str) – Memory limit specification for the problem.
  • sample_tests (zip) – Sample tests given for the problem.

error

All exceptions used in codeforces.

exception codeforces.error.CodeforcesAPIError(comment, method, args)

Raised by api.call if method returns a error or is not found.