Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

speedcode-cli

Command-line client for interacting with the Speedcode platform.

Overview

speedcode-cli lets you:

  • List available problems
  • Submit solutions from a single file or a JSON payload
  • Check submission status

This CLI works against both:

  • FastCoder-Frontend (localhost) for local development
  • Speedcode (speedcode.org) for the hosted service

Requirements

  • Python 3.9+
  • An API key (see “Authentication”)

Installation (local development)

cd speedcode-cli
pip install -e .

Authentication

  1. Sign in
  1. Get your API key (preferred: UI)

Alternative (API, requires browser session cookie):

  • FastCoder-Frontend: GET http://localhost:3000/auth/api-key
  • Speedcode: GET https://speedcode.org/api/auth/api-key

Rotate your key (UI recommended):

  • UI: use the “Rotate” button on the /keys page
  • API: POST /auth/api-key/rotate (same base URLs as above)

Security:

  • Your CLI config is stored at ~/.config/speedcode/config.json (override with SPEEDCODE_CONFIG_PATH).
  • Treat your API key like a password. Rotate immediately if exposed.

Configuration

Set the API base URL and API key:

# Local FastCoder-Frontend backend
speedcode configure --base-url http://localhost:3000 --api-key <YOUR_API_KEY>

# Hosted Speedcode backend (note the /api prefix)
speedcode configure --base-url https://speedcode.org/api --api-key <YOUR_API_KEY>

Notes:

  • Configuration is stored at ~/.config/speedcode/config.json (or at the path set by SPEEDCODE_CONFIG_PATH).
  • On first run, both --base-url and --api-key are required. Subsequent runs require at least one.

Usage

Problems: list

# Pretty table (default)
speedcode problems list

# JSON output
speedcode problems list --json

# Choose columns and filter
speedcode problems list --columns const_id,title --search graph --limit 20

Sample table output:

CONST_ID        TITLE                         SHORT_DESCRIPTION
--------------  ----------------------------  -------------------------------
graph_mst       Minimum Spanning Tree         Build an MST over weighted graph
vector_add      Vector Addition                Implement vector addition kernel

Display options:

  • --json: machine-readable JSON list
  • --columns: comma-separated fields (default: const_id,title,short_description)
  • --limit: max rows
  • --search: case-insensitive filter on const_id/title
  • --no-header: hide header
  • --truncate: truncate long fields (default 60; 0 disables)

Problems: get

Fetch details for a specific problem: allowed files, inputs, README, and optional file contents.

# Summary view
speedcode problems get graph_mst

# Print README
speedcode problems get graph_mst --readme

# Show competitor-visible files (truncated)
speedcode problems get graph_mst --files --truncate 300

# Download competitor-visible files to ./problem-files
speedcode problems get graph_mst --download --out-dir ./problem-files

# Restrict to specific file paths
speedcode problems get graph_mst --files --only solution.cpp --only include/helpers.hpp

# Full JSON descriptor
speedcode problems get graph_mst --json

Options:

  • --json: output full JSON
  • --readme: print README/description
  • --files: print competitor-visible file contents
  • --truncate N: truncate long file contents (default 200; 0 disables)
  • --download: write competitor-visible files to disk
  • --out-dir DIR: directory used with --download (default: .)
  • --only PATH: restrict to specific file paths (repeatable)

Submit: single file

For problems where competitors submit a single file (e.g., solution.cpp):

speedcode submit-file \
  --problem-id graph_mst \
  --file /path/to/solution.cpp \
  --input small \
  --target correctness

Options:

  • --problem-id: problem const_id
  • --file: local path to your modified file
  • --path-in-problem: destination path within the problem (default: solution.cpp)
  • --input: one or more input targets (repeatable)
  • --target: one or more targets (correctness, benchmark, cilkscale, cilksan, perf-profiler)

Returns a token you can use to check status.

Submit: JSON payload

speedcode submit submission.json

Example file (exercise submission):

{
  "submission_type": "exercise",
  "problem_id": "graph_mst",
  "submission": {
    "targets": ["correctness"],
    "input_targets": ["small"],
    "modified_files": [
      { "path": "solution.cpp", "content": "<base64>", "encoding": "base64" }
    ]
  }
}

Status

speedcode status <TOKEN>

Prints the combined response for your submission.

Command reference

Configure

  • speedcode configure --base-url <URL> --api-key <KEY>
    • First run requires both flags; later runs require at least one

Problems

  • speedcode problems list [--json] [--columns ...] [--limit N] [--search Q] [--no-header] [--truncate N]
  • speedcode problems get <ID> [--json] [--readme] [--files] [--truncate N] [--download] [--out-dir DIR] [--only PATH]

Submit

  • speedcode submit-file --problem-id <ID> --file <PATH> --input <TARGET> [--target correctness ...] [--path-in-problem solution.cpp]
  • speedcode submit <FILE.json>

Status

  • speedcode status <TOKEN>

Troubleshooting

  • 401 Unauthorized: Verify your API key (rotate if needed) and base URL.
  • Hosted base URL must include /api (e.g., https://speedcode.org/api).
  • Problem list shows empty: ensure you’re authenticated with a valid key.

Tips

Help

speedcode --help
speedcode problems --help
speedcode submit-file --help

speedcode-cli

Command-line client for interacting with the Speedcode platform.

Installation (local development)

cd /home/ubuntu/speedcode-dev/speedcode-cli
pip install -e .

Ensure your backend API server is running and accessible.

Configure

speedcode configure --base-url http://localhost:3000 --api-key <YOUR_API_KEY>
  • Obtain an API key from the web UI (/get_api_key) while logged in, or via curl with an authenticated session.
  • The CLI stores configuration at ~/.config/speedcode/config.yaml.

Submit

Prepare a submission file (JSON) describing the exercise submission using speedcode-models structures. Example:

{
  "problem_id": "my-problem-const-id",
  "submission": {
    "targets": ["correctness"],
    "input_targets": ["small"],
    "modified_files": [
      {"path": "solution.cpp", "content": "<base64>", "encoding": "base64"}
    ]
  }
}

Submit:

speedcode submit submission.json

The command prints a polling token.

Status

speedcode status <TOKEN>

Prints the combined response for the submission.

About

A command-line interface for submitting solutions to Speedcode.org

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages