Creates a new Polygon SDK instance.
SDK configuration with API credentials
Private InternalapiPrivate InternalapiPrivate InternalbasePrivategenerateInternalGenerates cryptographic signature for API request authentication. Implements Polygon's SHA-512 based signature scheme with random salt.
API method name (e.g., 'problems.list')
Request parameters
Signature string (6-char random prefix + SHA-512 hash)
PrivaterequestInternalExecutes an authenticated API request to Polygon. Handles parameter encoding, signature generation, and response parsing.
Expected response type
API method to call
Request parameters
If true, return raw text instead of parsed JSON
Parsed response data
Retrieves list of problems accessible to the authenticated user. Can filter by various criteria including owner, name, and deletion status.
Optionaloptions: { showDeleted?: boolean; id?: number; name?: string; owner?: string }Optional filter parameters
OptionalshowDeleted?: booleanInclude deleted problems (default: false)
Optionalid?: numberFilter by specific problem ID
Optionalname?: stringFilter by problem name
Optionalowner?: stringFilter by owner username
Array of problems matching filters
Creates a new empty problem with given name. After creation, you must call updateWorkingCopy to start editing.
Name/title for the new problem
Newly created problem object with ID
Retrieves problem configuration including I/O files, limits, and interactive flag.
Problem identifier
Optionalpin: stringOptional PIN code for protected problems
Problem configuration details
Updates problem configuration settings. Only specified fields will be updated; others remain unchanged.
Problem identifier
Fields to update
Optionalpin: stringOptional PIN code
Commits changes from working copy, creating a new revision. Optionally sends email notification to watchers.
Problem identifier
Optionaloptions: { minorChanges?: boolean; message?: string }Commit options
OptionalminorChanges?: booleanDon't send email if true
Optionalmessage?: stringCommit message
Optionalpin: stringOptional PIN code
Retrieves problem statements in all available languages.
Problem identifier
Optionalpin: stringOptional PIN code
Map of language code to statement
Creates or updates problem statement for a specific language. Only provided fields will be updated; others remain unchanged.
Problem identifier
Language code (e.g., 'english', 'russian')
Statement sections to save
Optionalpin: stringOptional PIN code
// Save English statement
await sdk.saveStatement(12345, 'english', {
name: 'Sum of Two Numbers',
legend: 'Calculate the sum of two integers a and b.',
input: 'Two integers a and b (1 ≤ a, b ≤ 10^9)',
output: 'Print a single integer — the sum of a and b.',
notes: 'This is a straightforward addition problem.'
});
Retrieves list of statement resource files (images, PDFs, etc.). Resources can be referenced in problem statements.
Problem identifier
Optionalpin: stringOptional PIN code
Array of resource files
Uploads or updates a statement resource file (e.g., image, diagram). Files are automatically converted to base64 if provided as Buffer.
Problem identifier
Resource file name
File content (string or Buffer)
OptionalcheckExisting: booleanIf true, only allows adding new files
Optionalpin: stringOptional PIN code
Sets the checker (output validator) for the problem. Can use standard testlib checkers or custom checker from source files.
Problem identifier
Checker file name from source files
Optionalpin: stringOptional PIN code
Sets the input validator for the problem. Validator checks if test inputs meet problem constraints.
Problem identifier
Validator file name from source files
Optionalpin: stringOptional PIN code
Gets list of extra validators configured for the problem. Extra validators provide additional input validation beyond main validator.
Problem identifier
Optionalpin: stringOptional PIN code
Array of extra validator names
Gets the name of currently configured interactor program. Interactors are used for interactive problems.
Problem identifier
Optionalpin: stringOptional PIN code
Interactor file name
Sets the interactor for an interactive problem. Interactor manages communication between solution and judge.
Problem identifier
Interactor file name from source files
Optionalpin: stringOptional PIN code
Retrieves all validator self-test cases. These tests verify that the validator correctly accepts/rejects inputs.
Problem identifier
Optionalpin: stringOptional PIN code
Array of validator test cases
Adds or updates a validator self-test case. Used to verify validator correctly validates inputs.
Problem identifier
Test number
Input to validate
Expected validation result
Optionaloptions: { checkExisting?: boolean; testGroup?: string; testset?: string }Additional options
OptionalcheckExisting?: booleanIf true, only adding is allowed
OptionaltestGroup?: stringTest group name
Optionaltestset?: stringTestset name
Optionalpin: stringOptional PIN code
Retrieves all checker self-test cases. These tests verify that the checker produces correct verdicts.
Problem identifier
Optionalpin: stringOptional PIN code
Array of checker test cases
Adds or updates a checker self-test case. Verifies checker correctly judges contestant outputs.
Problem identifier
Test number
Test input data
Contestant's output to check
Correct answer (jury's answer)
Expected checker verdict
OptionalcheckExisting: booleanIf true, only adding is allowed
Optionalpin: stringOptional PIN code
Retrieves all files associated with the problem. Returns files organized by type: resource, source, and auxiliary.
Problem identifier
Optionalpin: stringOptional PIN code
Object containing file lists by type
Retrieves content of a specific file. Returns raw file content as string.
Problem identifier
File type
File name
Optionalpin: stringOptional PIN code
File content as string
Uploads or updates a file in the problem package. Supports resource, source, and auxiliary files with automatic base64 conversion.
Problem identifier
File type
File name
File content (string or Buffer)
Optionaloptions: {Additional file options
OptionalcheckExisting?: booleanIf true, only adding is allowed
OptionalsourceType?: stringSource language/compiler (e.g., 'cpp.g++17')
OptionalforTypes?: stringFile types pattern for resources
Optionalstages?: stringCompilation/runtime stages for resources
Optionalassets?: stringAsset types for resources
Optionalpin: stringOptional PIN code
Retrieves all solutions for the problem. Solutions include main, correct, and incorrect solutions with various tags.
Problem identifier
Optionalpin: stringOptional PIN code
Array of solution objects
Retrieves source code of a specific solution. Returns raw solution code as string.
Problem identifier
Solution file name
Optionalpin: stringOptional PIN code
Solution source code
Uploads or updates a solution with specified tag. Tag indicates expected behavior (correct, wrong answer, TLE, etc.).
Problem identifier
Solution file name
Solution source code
Expected behavior tag
Optionaloptions: { checkExisting?: boolean; sourceType?: string }Additional options
OptionalcheckExisting?: booleanIf true, only adding is allowed
OptionalsourceType?: stringLanguage/compiler (e.g., 'cpp.g++17')
Optionalpin: stringOptional PIN code
import fs from 'fs';
// Upload main correct solution
const code = fs.readFileSync('main.cpp', 'utf-8');
await sdk.saveSolution(12345, 'main.cpp', code, 'MA', {
sourceType: 'cpp.g++17'
});
Adds or removes extra tags for solution on specific testset or test group. Extra tags allow different expected behaviors for different test groups.
Problem identifier
Solution name
If true, removes tag; if false, adds tag
Tag options (must specify testset OR testGroup)
Optionaltestset?: stringTestset name
OptionaltestGroup?: stringTest group name
Optionaltag?: "OK" | "RJ" | "TL" | "TO" | "WA" | "PE" | "ML" | "RE"Extra tag (required when adding)
Optionalpin: stringOptional PIN code
Retrieves test generation script for specified testset. Script contains commands for generating tests using generators.
Problem identifier
Testset name (usually 'tests')
Optionalpin: stringOptional PIN code
Generation script content
Saves test generation script for specified testset. Script defines how tests are generated using generator programs.
Problem identifier
Testset name
Script content with generation commands
Optionalpin: stringOptional PIN code
Retrieves all tests for specified testset. Can optionally exclude input data to reduce response size.
Problem identifier
Testset name (usually 'tests')
OptionalnoInputs: booleanIf true, excludes input data from response
Optionalpin: stringOptional PIN code
Array of test cases
Retrieves input data for a specific test. Returns raw input content as string.
Problem identifier
Testset name
Test number (1-indexed)
Optionalpin: stringOptional PIN code
Test input data
Retrieves expected answer for a specific test. Answer is generated by running main solution on test input.
Problem identifier
Testset name
Test number (1-indexed)
Optionalpin: stringOptional PIN code
Test answer data
Adds a new test or updates existing test. For manual tests, provide testInput. For generated tests, use script.
Problem identifier
Testset name
Test number (1-indexed)
Test input data
Optionaloptions: TestOptionsAdditional test properties
Options for adding or updating a test via the Polygon API. TestOptions
OptionalcheckExisting?: booleanWhether to check if test already exists
OptionaltestGroup?: stringName of the test group
OptionaltestPoints?: numberPoints assigned to the test
OptionaltestDescription?: stringDescription of the test
OptionaltestUseInStatements?: booleanWhether to use test in statements
OptionaltestInputForStatements?: stringInput to show in statements
OptionaltestOutputForStatements?: stringOutput to show in statements
OptionalverifyInputOutputForStatements?: booleanVerify I/O for statements
Optionalpin: stringOptional PIN code
Assigns one or more tests to a specific test group. Groups must be enabled for the testset before using this method.
Problem identifier
Testset name
Group name to assign tests to
Array of test numbers to assign
Optionalpin: stringOptional PIN code
Enables or disables test groups for a testset. When enabled, tests can be organized into groups for partial scoring.
Problem identifier
Testset name
True to enable, false to disable
Optionalpin: stringOptional PIN code
Enables or disables point scoring for the problem. When enabled, individual tests can be assigned point values.
Problem identifier
True to enable, false to disable
Optionalpin: stringOptional PIN code
Retrieves configuration for one or all test groups. Returns group settings including points policy, feedback policy, and dependencies.
Problem identifier
Testset name
Optionalgroup: stringSpecific group name (omit to get all groups)
Optionalpin: stringOptional PIN code
Array of test group configurations
Configures settings for a test group. Sets points policy, feedback policy, and group dependencies.
Problem identifier
Testset name
Group name
Optionaloptions: {Group configuration options
OptionalpointsPolicy?: "COMPLETE_GROUP" | "EACH_TEST"How points are awarded
OptionalfeedbackPolicy?: "NONE" | "POINTS" | "ICPC" | "COMPLETE"Feedback level
Optionaldependencies?: stringComma-separated list of groups that must pass first
Optionalpin: stringOptional PIN code
Retrieves all tags associated with the problem. Tags categorize problems (e.g., 'dp', 'graphs', 'math').
Problem identifier
Optionalpin: stringOptional PIN code
Array of tag strings
Saves tags for the problem, replacing all existing tags. Tags help categorize and search for problems.
Problem identifier
Array of tag strings
Optionalpin: stringOptional PIN code
Retrieves general description of the problem. Description provides overview and context for the problem.
Problem identifier
Optionalpin: stringOptional PIN code
Problem description text
Saves general description for the problem. Can be empty string to clear description.
Problem identifier
Description text (can be empty)
Optionalpin: stringOptional PIN code
Retrieves general tutorial for the problem. Tutorial provides solution approach and explanation.
Problem identifier
Optionalpin: stringOptional PIN code
Tutorial text
Saves general tutorial for the problem. Can be empty string to clear tutorial.
Problem identifier
Tutorial text (can be empty)
Optionalpin: stringOptional PIN code
Lists all built packages for the problem. Shows package state, type, and revision information.
Problem identifier
Optionalpin: stringOptional PIN code
Array of package objects
Downloads a built package as a zip archive.
Problem identifier
Package ID from listPackages
Optionaltype: "standard" | "linux" | "windows"Package type (default: 'standard')
Optionalpin: stringOptional PIN code
Package zip file as Buffer
Starts building a new package for the problem. Package will be built asynchronously; use listPackages to check status.
Problem identifier
If true, build full package (standard + linux + windows)
If true, run all solutions on all tests for verification
Optionalpin: stringOptional PIN code
Retrieves list of problems in a contest. Returns basic problem information for all contest problems.
Contest identifier
Optionalpin: stringOptional PIN code for protected contests
Array of problem objects
Comprehensive SDK for Codeforces Polygon API. Provides type-safe methods for all Polygon operations including problem management, statements, tests, solutions, checkers, validators, and package building.
Features:
PolygonSDK
Example
Example
Example
Example