Skip to main content

Question API

The /api/question route serves a single coding challenge question from the dataset. Questions can be filtered by ID, slug, difficulty, or topic tag. When multiple questions match the filters a random one is returned, making the endpoint suitable for powering randomised game sessions.

Code Battlegrounds - Question API (1.0.0)

Download OpenAPI specification:Download

REST endpoint for retrieving coding questions sourced from the LeetCode-style dataset (public/dataset.csv).

The dataset is loaded once at server start and cached in memory. Every call returns exactly one question object, chosen randomly from the questions that match the supplied filters.

questions

Coding challenge questions

Get a single coding question

Returns one question, picked at random from all questions that match the supplied filters. Omit all query parameters to receive a uniformly random question from the full dataset.

query Parameters
id
integer
Example: id=1

Numeric LeetCode-style Question ID (e.g. 1 for Two Sum).

slug
string
Example: slug=two-sum

URL slug of the question (e.g. two-sum).

difficulty
string
Enum: "Easy" "Medium" "Hard"
Example: difficulty=Medium

Filter by difficulty level (case-insensitive).

topic
string
Example: topic=dynamic programming

Partial, case-insensitive match against any topic tag on the question (e.g. dynamic matches Dynamic Programming).

Responses

Response samples

Content type
application/json
{
  • "question": {
    }
}