Polyman Documentation - v2.2.2
    Preparing search index...

    Class PolygonSDK

    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:

    • Automatic authentication with SHA-512 signature generation
    • Full TypeScript type safety
    • Support for all Polygon API endpoints (54+ methods)
    • PIN code support for protected problems
    • File upload/download with Buffer support
    • Comprehensive error handling

    PolygonSDK

    // Initialize SDK
    const sdk = new PolygonSDK({
    apiKey: process.env.POLYGON_API_KEY!,
    apiSecret: process.env.POLYGON_API_SECRET!
    });
    // List and filter problems
    const myProblems = await sdk.listProblems({ owner: 'username' });
    // Create and configure a problem
    const problem = await sdk.createProblem('A+B Problem');
    await sdk.updateWorkingCopy(problem.id);
    await sdk.updateProblemInfo(problem.id, {
    timeLimit: 2000,
    memoryLimit: 256
    });
    await sdk.commitChanges(problem.id, { message: 'Initial setup' });
    // Upload files and solutions
    import fs from 'fs';
    const code = fs.readFileSync('main.cpp', 'utf-8');
    await sdk.saveSolution(problem.id, 'main.cpp', code, 'MA');
    Index

    Constructors

    • Creates a new Polygon SDK instance.

      Parameters

      Returns PolygonSDK

      If credentials are invalid or missing

      const sdk = new PolygonSDK({
      apiKey: 'your-api-key',
      apiSecret: 'your-api-secret'
      });

    Properties

    apiKey: string
    apiSecret: string
    baseUrl: string

    Methods

    • Internal

      Generates cryptographic signature for API request authentication. Implements Polygon's SHA-512 based signature scheme with random salt.

      Parameters

      • methodName: string

        API method name (e.g., 'problems.list')

      • params: Record<string, string | number | boolean>

        Request parameters

      Returns string

      Signature string (6-char random prefix + SHA-512 hash)

    • Internal

      Executes an authenticated API request to Polygon. Handles parameter encoding, signature generation, and response parsing.

      Type Parameters

      • T

        Expected response type

      Parameters

      • methodName: string

        API method to call

      • params: Record<string, string | number | boolean> = {}

        Request parameters

      • returnRaw: boolean = false

        If true, return raw text instead of parsed JSON

      Returns Promise<T>

      Parsed response data

      If API returns FAILED status or network error occurs

    • Retrieves list of problems accessible to the authenticated user. Can filter by various criteria including owner, name, and deletion status.

      Parameters

      • Optionaloptions: { showDeleted?: boolean; id?: number; name?: string; owner?: string }

        Optional filter parameters

        • OptionalshowDeleted?: boolean

          Include deleted problems (default: false)

        • Optionalid?: number

          Filter by specific problem ID

        • Optionalname?: string

          Filter by problem name

        • Optionalowner?: string

          Filter by owner username

      Returns Promise<Problem[]>

      Array of problems matching filters

      // List all accessible problems
      const allProblems = await sdk.listProblems();
      // List only your own problems
      const myProblems = await sdk.listProblems({ owner: 'username' });
      // Include deleted problems
      const withDeleted = await sdk.listProblems({ showDeleted: true });
    • Creates a new empty problem with given name. After creation, you must call updateWorkingCopy to start editing.

      Parameters

      • name: string

        Name/title for the new problem

      Returns Promise<Problem>

      Newly created problem object with ID

      If problem creation fails

      const problem = await sdk.createProblem('A+B Problem');
      console.log('Created problem ID:', problem.id);
      await sdk.updateWorkingCopy(problem.id);
    • Retrieves problem configuration including I/O files, limits, and interactive flag.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code for protected problems

      Returns Promise<ProblemInfo>

      Problem configuration details

      const info = await sdk.getProblemInfo(12345);
      console.log(`Time: ${info.timeLimit}ms, Memory: ${info.memoryLimit}MB`);
    • Updates problem configuration settings. Only specified fields will be updated; others remain unchanged.

      Parameters

      • problemId: number

        Problem identifier

      • info: Partial<ProblemInfo>

        Fields to update

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Update only time and memory limits
      await sdk.updateProblemInfo(12345, {
      timeLimit: 2000,
      memoryLimit: 256
      });
      // Mark as interactive problem
      await sdk.updateProblemInfo(12345, { interactive: true });
    • Updates working copy to latest committed version. Required before making changes to a problem.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      await sdk.updateWorkingCopy(12345);
      // Now you can modify the problem
    • Discards all uncommitted changes in working copy. Reverts to last committed version.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Discard changes if something went wrong
      await sdk.discardWorkingCopy(12345);
    • Commits changes from working copy, creating a new revision. Optionally sends email notification to watchers.

      Parameters

      • problemId: number

        Problem identifier

      • Optionaloptions: { minorChanges?: boolean; message?: string }

        Commit options

        • OptionalminorChanges?: boolean

          Don't send email if true

        • Optionalmessage?: string

          Commit message

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Commit with message
      await sdk.commitChanges(12345, {
      message: 'Updated time limits and added test cases'
      });
      // Minor commit without notification
      await sdk.commitChanges(12345, {
      minorChanges: true,
      message: 'Fixed typo'
      });
    • Retrieves problem statements in all available languages.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<Record<string, Statement>>

      Map of language code to statement

      const statements = await sdk.getStatements(12345);
      console.log('Available languages:', Object.keys(statements));
      console.log('English legend:', statements['english'].legend);
    • Creates or updates problem statement for a specific language. Only provided fields will be updated; others remain unchanged.

      Parameters

      • problemId: number

        Problem identifier

      • lang: string

        Language code (e.g., 'english', 'russian')

      • statement: Partial<Omit<Statement, "encoding">>

        Statement sections to save

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // 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.'
      });
      // Update only the tutorial
      await sdk.saveStatement(12345, 'english', {
      tutorial: 'Simply add the two numbers together.'
      });
    • Retrieves list of statement resource files (images, PDFs, etc.). Resources can be referenced in problem statements.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<File[]>

      Array of resource files

      const resources = await sdk.getStatementResources(12345);
      resources.forEach(r => {
      console.log(`Resource: ${r.name} (${r.length} bytes)`);
      });
    • Uploads or updates a statement resource file (e.g., image, diagram). Files are automatically converted to base64 if provided as Buffer.

      Parameters

      • problemId: number

        Problem identifier

      • name: string

        Resource file name

      • file: string | Buffer<ArrayBufferLike>

        File content (string or Buffer)

      • OptionalcheckExisting: boolean

        If true, only allows adding new files

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      import fs from 'fs';

      // Upload an image
      const image = fs.readFileSync('diagram.png');
      await sdk.saveStatementResource(12345, 'diagram.png', image);
      // Upload text file
      await sdk.saveStatementResource(12345, 'notes.txt', 'Additional notes');
    • Gets the name of currently configured checker program.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Checker file name

      const checker = await sdk.getChecker(12345);
      console.log('Current checker:', checker); // e.g., 'wcmp.cpp'
    • Sets the checker (output validator) for the problem. Can use standard testlib checkers or custom checker from source files.

      Parameters

      • problemId: number

        Problem identifier

      • checker: string

        Checker file name from source files

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Use standard token checker
      await sdk.setChecker(12345, 'wcmp.cpp');
      // Use custom checker
      await sdk.setChecker(12345, 'checker.cpp');
    • Gets the name of currently configured validator program.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Validator file name

      const validator = await sdk.getValidator(12345);
      console.log('Current validator:', validator);
    • Sets the input validator for the problem. Validator checks if test inputs meet problem constraints.

      Parameters

      • problemId: number

        Problem identifier

      • validator: string

        Validator file name from source files

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Set validator
      await sdk.setValidator(12345, 'validator.cpp');
    • Gets list of extra validators configured for the problem. Extra validators provide additional input validation beyond main validator.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string[]>

      Array of extra validator names

      const extraVals = await sdk.getExtraValidators(12345);
      console.log('Extra validators:', extraVals);
    • Gets the name of currently configured interactor program. Interactors are used for interactive problems.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Interactor file name

      const interactor = await sdk.getInteractor(12345);
      console.log('Current interactor:', interactor);
    • Sets the interactor for an interactive problem. Interactor manages communication between solution and judge.

      Parameters

      • problemId: number

        Problem identifier

      • interactor: string

        Interactor file name from source files

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Set interactor for interactive problem
      await sdk.setInteractor(12345, 'interactor.cpp');
    • Retrieves all validator self-test cases. These tests verify that the validator correctly accepts/rejects inputs.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<ValidatorTest[]>

      Array of validator test cases

      const valTests = await sdk.getValidatorTests(12345);
      valTests.forEach(t => {
      console.log(`Test ${t.index}: ${t.expectedVerdict}`);
      });
    • Adds or updates a validator self-test case. Used to verify validator correctly validates inputs.

      Parameters

      • problemId: number

        Problem identifier

      • testIndex: number

        Test number

      • testInput: string

        Input to validate

      • testVerdict: "VALID" | "INVALID"

        Expected validation result

      • Optionaloptions: { checkExisting?: boolean; testGroup?: string; testset?: string }

        Additional options

        • OptionalcheckExisting?: boolean

          If true, only adding is allowed

        • OptionaltestGroup?: string

          Test group name

        • Optionaltestset?: string

          Testset name

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Add valid input test
      await sdk.saveValidatorTest(12345, 1, '5 10', 'VALID');
      // Add invalid input test (negative numbers)
      await sdk.saveValidatorTest(12345, 2, '-1 5', 'INVALID');
    • Retrieves all checker self-test cases. These tests verify that the checker produces correct verdicts.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<CheckerTest[]>

      Array of checker test cases

      const checkTests = await sdk.getCheckerTests(12345);
      checkTests.forEach(t => {
      console.log(`Test ${t.index}: ${t.expectedVerdict}`);
      });
    • Adds or updates a checker self-test case. Verifies checker correctly judges contestant outputs.

      Parameters

      • problemId: number

        Problem identifier

      • testIndex: number

        Test number

      • testInput: string

        Test input data

      • testOutput: string

        Contestant's output to check

      • testAnswer: string

        Correct answer (jury's answer)

      • testVerdict: "OK" | "WRONG_ANSWER" | "PRESENTATION_ERROR" | "CRASHED"

        Expected checker verdict

      • OptionalcheckExisting: boolean

        If true, only adding is allowed

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Checker should accept correct answer
      await sdk.saveCheckerTest(12345, 1, '5 10', '15', '15', 'OK');
      // Checker should reject wrong answer
      await sdk.saveCheckerTest(12345, 2, '5 10', '16', '15', 'WRONG_ANSWER');
      // Checker should detect presentation error
      await sdk.saveCheckerTest(12345, 3, '5 10', '15 ', '15', 'PRESENTATION_ERROR');
    • Retrieves all files associated with the problem. Returns files organized by type: resource, source, and auxiliary.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<FilesResponse>

      Object containing file lists by type

      const files = await sdk.getFiles(12345);
      console.log(`Resource files: ${files.resourceFiles.length}`);
      console.log(`Source files: ${files.sourceFiles.length}`);
      console.log(`Aux files: ${files.auxFiles.length}`);
      // List all source files
      const files = await sdk.getFiles(12345);
      files.sourceFiles.forEach(f => {
      console.log(`${f.name} (${f.sourceType})`);
      });
    • Retrieves content of a specific file. Returns raw file content as string.

      Parameters

      • problemId: number

        Problem identifier

      • type: "resource" | "source" | "aux"

        File type

      • name: string

        File name

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      File content as string

      // View generator source code
      const code = await sdk.viewFile(12345, 'source', 'gen.cpp');
      console.log(code);
      // View resource file
      const data = await sdk.viewFile(12345, 'resource', 'grader.h');
    • Uploads or updates a file in the problem package. Supports resource, source, and auxiliary files with automatic base64 conversion.

      Parameters

      • problemId: number

        Problem identifier

      • type: "resource" | "source" | "aux"

        File type

      • name: string

        File name

      • file: string | Buffer<ArrayBufferLike>

        File content (string or Buffer)

      • Optionaloptions: {
            checkExisting?: boolean;
            sourceType?: string;
            forTypes?: string;
            stages?: string;
            assets?: string;
        }

        Additional file options

        • OptionalcheckExisting?: boolean

          If true, only adding is allowed

        • OptionalsourceType?: string

          Source language/compiler (e.g., 'cpp.g++17')

        • OptionalforTypes?: string

          File types pattern for resources

        • Optionalstages?: string

          Compilation/runtime stages for resources

        • Optionalassets?: string

          Asset types for resources

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      import fs from 'fs';

      // Upload generator source file
      const genCode = fs.readFileSync('gen.cpp', 'utf-8');
      await sdk.saveFile(12345, 'source', 'gen.cpp', genCode, {
      sourceType: 'cpp.g++17'
      });
      // Upload resource file (grader)
      const grader = fs.readFileSync('grader.cpp', 'utf-8');
      await sdk.saveFile(12345, 'resource', 'grader.cpp', grader, {
      forTypes: 'cpp.*',
      stages: 'COMPILE',
      assets: 'SOLUTION'
      });
    • Retrieves all solutions for the problem. Solutions include main, correct, and incorrect solutions with various tags.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<Solution[]>

      Array of solution objects

      const solutions = await sdk.getSolutions(12345);
      const mainSol = solutions.find(s => s.tag === 'MA');
      console.log(`Main solution: ${mainSol?.name}`);
      // List all solutions with their tags
      const solutions = await sdk.getSolutions(12345);
      solutions.forEach(s => {
      console.log(`${s.name} (${s.tag})`);
      });
    • Retrieves source code of a specific solution. Returns raw solution code as string.

      Parameters

      • problemId: number

        Problem identifier

      • name: string

        Solution file name

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Solution source code

      // View main solution code
      const code = await sdk.viewSolution(12345, 'main.cpp');
      console.log(code);
    • Uploads or updates a solution with specified tag. Tag indicates expected behavior (correct, wrong answer, TLE, etc.).

      Parameters

      • problemId: number

        Problem identifier

      • name: string

        Solution file name

      • file: string | Buffer<ArrayBufferLike>

        Solution source code

      • tag: "OK" | "MA" | "RJ" | "TL" | "TO" | "WA" | "PE" | "ML" | "RE"

        Expected behavior tag

      • Optionaloptions: { checkExisting?: boolean; sourceType?: string }

        Additional options

        • OptionalcheckExisting?: boolean

          If true, only adding is allowed

        • OptionalsourceType?: string

          Language/compiler (e.g., 'cpp.g++17')

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      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'
      });
      // Upload TLE solution
      const tleSol = fs.readFileSync('slow.cpp', 'utf-8');
      await sdk.saveSolution(12345, 'slow.cpp', tleSol, 'TL');
      // Upload wrong answer solution
      const waSol = fs.readFileSync('wrong.cpp', 'utf-8');
      await sdk.saveSolution(12345, 'wrong.cpp', waSol, 'WA');
    • Adds or removes extra tags for solution on specific testset or test group. Extra tags allow different expected behaviors for different test groups.

      Parameters

      • problemId: number

        Problem identifier

      • name: string

        Solution name

      • remove: boolean

        If true, removes tag; if false, adds tag

      • options: {
            testset?: string;
            testGroup?: string;
            tag?: "OK" | "RJ" | "TL" | "TO" | "WA" | "PE" | "ML" | "RE";
        }

        Tag options (must specify testset OR testGroup)

        • Optionaltestset?: string

          Testset name

        • OptionaltestGroup?: string

          Test group name

        • Optionaltag?: "OK" | "RJ" | "TL" | "TO" | "WA" | "PE" | "ML" | "RE"

          Extra tag (required when adding)

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Add TL tag for specific test group
      await sdk.editSolutionExtraTags(12345, 'slow.cpp', false, {
      testGroup: 'large',
      tag: 'TL'
      });
      // Remove extra tag from testset
      await sdk.editSolutionExtraTags(12345, 'solution.cpp', true, {
      testset: 'tests'
      });
    • Retrieves test generation script for specified testset. Script contains commands for generating tests using generators.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name (usually 'tests')

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Generation script content

      const script = await sdk.getScript(12345, 'tests');
      console.log('Generation script:', script);
    • Saves test generation script for specified testset. Script defines how tests are generated using generator programs.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • source: string

        Script content with generation commands

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Save generation script
      const script = `
      gen 1 10 > $
      gen 11 100 > $
      gen 101 1000 > $
      `;
      await sdk.saveScript(12345, 'tests', script);
    • Retrieves all tests for specified testset. Can optionally exclude input data to reduce response size.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name (usually 'tests')

      • OptionalnoInputs: boolean

        If true, excludes input data from response

      • Optionalpin: string

        Optional PIN code

      Returns Promise<Test[]>

      Array of test cases

      // Get all tests with input data
      const tests = await sdk.getTests(12345, 'tests');
      tests.forEach(t => {
      console.log(`Test ${t.index}: ${t.manual ? 'manual' : 'generated'}`);
      });
      // Get tests without input data (faster)
      const testsInfo = await sdk.getTests(12345, 'tests', true);
    • Retrieves input data for a specific test. Returns raw input content as string.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • testIndex: number

        Test number (1-indexed)

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Test input data

      const input = await sdk.getTestInput(12345, 'tests', 1);
      console.log('Test 1 input:', input);
    • Retrieves expected answer for a specific test. Answer is generated by running main solution on test input.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • testIndex: number

        Test number (1-indexed)

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Test answer data

      const answer = await sdk.getTestAnswer(12345, 'tests', 1);
      console.log('Expected answer:', answer);
      // Compare input and answer
      const input = await sdk.getTestInput(12345, 'tests', 1);
      const answer = await sdk.getTestAnswer(12345, 'tests', 1);
      console.log(`Input: ${input}, Answer: ${answer}`);
    • Adds a new test or updates existing test. For manual tests, provide testInput. For generated tests, use script.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • testIndex: number

        Test number (1-indexed)

      • testInput: string

        Test input data

      • Optionaloptions: TestOptions

        Additional test properties

        Options for adding or updating a test via the Polygon API. TestOptions

        • OptionalcheckExisting?: boolean

          Whether to check if test already exists

        • OptionaltestGroup?: string

          Name of the test group

        • OptionaltestPoints?: number

          Points assigned to the test

        • OptionaltestDescription?: string

          Description of the test

        • OptionaltestUseInStatements?: boolean

          Whether to use test in statements

        • OptionaltestInputForStatements?: string

          Input to show in statements

        • OptionaltestOutputForStatements?: string

          Output to show in statements

        • OptionalverifyInputOutputForStatements?: boolean

          Verify I/O for statements

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Add simple manual test
      await sdk.saveTest(12345, 'tests', 1, '5 10');
      // Add test with description and group
      await sdk.saveTest(12345, 'tests', 2, '1000000 2000000', {
      testDescription: 'Large numbers test',
      testGroup: 'large',
      testPoints: 10
      });
      // Add sample test for statement
      await sdk.saveTest(12345, 'tests', 1, '1 2', {
      testUseInStatements: true,
      testInputForStatements: '1 2',
      testOutputForStatements: '3'
      });
    • Assigns one or more tests to a specific test group. Groups must be enabled for the testset before using this method.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • testGroup: string

        Group name to assign tests to

      • testIndices: number[]

        Array of test numbers to assign

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Assign tests 1-5 to 'small' group
      await sdk.setTestGroup(12345, 'tests', 'small', [1, 2, 3, 4, 5]);
      // Assign specific tests to 'large' group
      await sdk.setTestGroup(12345, 'tests', 'large', [10, 11, 12]);
    • Enables or disables test groups for a testset. When enabled, tests can be organized into groups for partial scoring.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • enable: boolean

        True to enable, false to disable

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Enable test groups
      await sdk.enableGroups(12345, 'tests', true);
      // Disable test groups
      await sdk.enableGroups(12345, 'tests', false);
    • Enables or disables point scoring for the problem. When enabled, individual tests can be assigned point values.

      Parameters

      • problemId: number

        Problem identifier

      • enable: boolean

        True to enable, false to disable

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Enable point scoring
      await sdk.enablePoints(12345, true);
      // Disable point scoring
      await sdk.enablePoints(12345, false);
    • Retrieves configuration for one or all test groups. Returns group settings including points policy, feedback policy, and dependencies.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • Optionalgroup: string

        Specific group name (omit to get all groups)

      • Optionalpin: string

        Optional PIN code

      Returns Promise<TestGroup[]>

      Array of test group configurations

      // Get all test groups
      const groups = await sdk.viewTestGroup(12345, 'tests');
      groups.forEach(g => {
      console.log(`${g.name}: ${g.pointsPolicy}, ${g.feedbackPolicy}`);
      });
      // Get specific group
      const [group] = await sdk.viewTestGroup(12345, 'tests', 'large');
      console.log('Dependencies:', group.dependencies);
    • Configures settings for a test group. Sets points policy, feedback policy, and group dependencies.

      Parameters

      • problemId: number

        Problem identifier

      • testset: string

        Testset name

      • group: string

        Group name

      • Optionaloptions: {
            pointsPolicy?: "COMPLETE_GROUP" | "EACH_TEST";
            feedbackPolicy?: "NONE" | "POINTS" | "ICPC" | "COMPLETE";
            dependencies?: string;
        }

        Group configuration options

        • OptionalpointsPolicy?: "COMPLETE_GROUP" | "EACH_TEST"

          How points are awarded

        • OptionalfeedbackPolicy?: "NONE" | "POINTS" | "ICPC" | "COMPLETE"

          Feedback level

        • Optionaldependencies?: string

          Comma-separated list of groups that must pass first

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Configure group with ICPC feedback
      await sdk.saveTestGroup(12345, 'tests', 'group1', {
      pointsPolicy: 'COMPLETE_GROUP',
      feedbackPolicy: 'ICPC'
      });
      // Set group dependencies
      await sdk.saveTestGroup(12345, 'tests', 'hard', {
      dependencies: 'easy,medium'
      });
    • Retrieves all tags associated with the problem. Tags categorize problems (e.g., 'dp', 'graphs', 'math').

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string[]>

      Array of tag strings

      const tags = await sdk.viewTags(12345);
      console.log('Problem tags:', tags.join(', '));
    • Saves tags for the problem, replacing all existing tags. Tags help categorize and search for problems.

      Parameters

      • problemId: number

        Problem identifier

      • tags: string[]

        Array of tag strings

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Set problem tags
      await sdk.saveTags(12345, ['dp', 'greedy', 'implementation']);
      // Clear all tags
      await sdk.saveTags(12345, []);
    • Retrieves general description of the problem. Description provides overview and context for the problem.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Problem description text

      const desc = await sdk.viewGeneralDescription(12345);
      console.log('Description:', desc);
    • Saves general description for the problem. Can be empty string to clear description.

      Parameters

      • problemId: number

        Problem identifier

      • description: string

        Description text (can be empty)

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      await sdk.saveGeneralDescription(12345,
      'This problem tests understanding of dynamic programming.'
      );
      // Clear description
      await sdk.saveGeneralDescription(12345, '');
    • Retrieves general tutorial for the problem. Tutorial provides solution approach and explanation.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<string>

      Tutorial text

      const tutorial = await sdk.viewGeneralTutorial(12345);
      console.log('Tutorial:', tutorial);
    • Saves general tutorial for the problem. Can be empty string to clear tutorial.

      Parameters

      • problemId: number

        Problem identifier

      • tutorial: string

        Tutorial text (can be empty)

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      await sdk.saveGeneralTutorial(12345,
      'Use dynamic programming with O(n^2) complexity.'
      );
      // Clear tutorial
      await sdk.saveGeneralTutorial(12345, '');
    • Lists all built packages for the problem. Shows package state, type, and revision information.

      Parameters

      • problemId: number

        Problem identifier

      • Optionalpin: string

        Optional PIN code

      Returns Promise<Package[]>

      Array of package objects

      const packages = await sdk.listPackages(12345);
      packages.forEach(pkg => {
      console.log(`Package ${pkg.id}: ${pkg.state} (rev ${pkg.revision})`);
      });
      // Find latest ready package
      const ready = packages.filter(p => p.state === 'READY');
      const latest = ready.sort((a, b) => b.id - a.id)[0];
    • Downloads a built package as a zip archive.

      Parameters

      • problemId: number

        Problem identifier

      • packageId: number

        Package ID from listPackages

      • Optionaltype: "standard" | "linux" | "windows"

        Package type (default: 'standard')

      • Optionalpin: string

        Optional PIN code

      Returns Promise<Buffer<ArrayBufferLike>>

      Package zip file as Buffer

      import fs from 'fs';

      // Download linux package
      const zipData = await sdk.downloadPackage(12345, 456, 'linux');
      fs.writeFileSync('problem-package.zip', zipData);
      // Download standard package
      const pkg = await sdk.downloadPackage(12345, 456);
      fs.writeFileSync('problem.zip', pkg);
    • Starts building a new package for the problem. Package will be built asynchronously; use listPackages to check status.

      Parameters

      • problemId: number

        Problem identifier

      • full: boolean

        If true, build full package (standard + linux + windows)

      • verify: boolean

        If true, run all solutions on all tests for verification

      • Optionalpin: string

        Optional PIN code

      Returns Promise<void>

      // Build full verified package
      await sdk.buildPackage(12345, true, true);
      console.log('Package building started');
      // Build standard package without verification (faster)
      await sdk.buildPackage(12345, false, false);
    • Retrieves list of problems in a contest. Returns basic problem information for all contest problems.

      Parameters

      • contestId: number

        Contest identifier

      • Optionalpin: string

        Optional PIN code for protected contests

      Returns Promise<Problem[]>

      Array of problem objects

      const problems = await sdk.getContestProblems(789);
      problems.forEach(p => {
      console.log(`${p.name} (ID: ${p.id})`);
      });