Skip to content
Jonathan Wu edited this page Aug 3, 2021 · 9 revisions

Welcome

This page describes CTFOJ's API and how to use it. All endpoints labelled with Login required signify that they need to be authenticated. To make an authenticated request, include a session cookie in the request header.*

* Starting in v3.0.0, API tokens will be provided to users to use instead.

Issues/Troubleshooting

Found a bug? File a bug report here

Sample Markdown response

All Markdown responses will return a Markdown file containing the requested Markdown content.

Request (curl):

curl --cookie "session=30b39c5e-1e7b-42a5-b7e8-fbd61a0df57f" \
     http://127.0.0.1:5000/api/problem/description/helloworld

Response:

Here's a sample Hello World problem. It can include [links](https://www.youtube.com/watch?v=dQw4w9WgXcQ) because it uses Markdown!

The flag for this problem is: `CTF{welcome_to_ctf_club}`

API Endpoints

GET /problem/description/<problem_id>

Login required

Usage

This endpoint is used to get the problem description with the specified problem id.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The problem referenced by the problem_id does not exist None
200 The request has succeeded Markdown

GET /problem/hints/<problem_id>

Login required

Usage

This endpoint is used to get any hints associated with the specified problem id. If there are no hints, the response body will be empty.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The problem referenced by the problem_id does not exist None
200 The request has succeeded Markdown

GET /problem/editorial/<problem_id>

Login required

Usage

This endpoint is used to get the editorial associated with the specified problem id. If the problem does not have an editorial, the response body will be empty.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The problem referenced by the problem_id does not exist None
200 The request has succeeded Markdown

GET /contest/<contest_id>/problem/description/<problem_id>

Login required

Usage

This endpoint is used to get the problem description with the specified contest & problem id.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The problem or contest referenced by the problem_id or contest_id does not exist None
200 The request has succeeded Markdown

GET /contest/<contest_id>/problem/hints/<problem_id>

Login required

Usage

This endpoint is used to get any hints associated with specified contest & problem id. If there are no hints, the response body will be empty.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The problem or contest referenced by the problem_id or contest_id does not exist None
200 The request has succeeded Markdown

GET /contest/<contest_id>

Login required

Usage

This endpoint is used to get the description of the contest with the specified contest id.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The contest referenced by the contest_id does not exist None
200 The request has succeeded Markdown

GET /announcement/<announcement_id>

Login special

Usage

This endpoint is used to get the contents of an announcement with the specified id. Authentication will be required if the site requires logging in to view announcements.

Response

Status Code Meaning Response Format
401 You are unauthorized; make sure you have included a valid session cookie in your request None
404 The announcement referenced by the announcement_id does not exist None
200 The request has succeeded Markdown

GET /homepage

Login special

Usage

This endpoint is used to get the contents of the homepage, if it is enabled. If the homepage is disabled, admin authentication will be required.

Response

Status Code Meaning Response Format
403 The homepage is disabled and you are not an admin None
200 The request has succeeded Markdown
Clone this wiki locally