Resources
Base classes
Resource(http)
Base for every resource binding.
Concrete resources set :attr:path and :attr:model as class-level
constants and compose any subset of the :class:_ListOps,
:class:_GetOps, :class:_CreateOps, :class:_UpdateOps,
:class:_DeleteOps mixins to expose the operations that the CTFd API
actually supports for that resource.
Source code in ctfd/resources/_base.py
_ListOps(http)
Bases: Resource
Mixin: GET /<path> collection listing and pagination.
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
_GetOps(http)
_CreateOps(http)
_UpdateOps(http)
_DeleteOps(http)
Awards
AwardsResource(http)
Bases: _ListOps[Award], _GetOps[Award], _CreateOps[Award], _DeleteOps
/awards — list, retrieve, create, delete (CTFd does not expose PATCH).
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Brackets
BracketsResource(http)
Bases: _ListOps[Bracket], _CreateOps[Bracket], _UpdateOps[Bracket], _DeleteOps
/brackets — no single-bracket GET endpoint is exposed by CTFd.
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Challenges
ChallengesResource(http)
Bases: _ListOps[Challenge], _GetOps[Challenge], _CreateOps[Challenge], _UpdateOps[Challenge], _DeleteOps
Source code in ctfd/resources/_base.py
attempt(challenge_id, submission)
async
Submit an attempt against a challenge (POST /challenges/attempt).
Source code in ctfd/resources/challenges.py
types()
async
List the challenge types registered on the server.
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Comments
CommentsResource(http)
Bases: _ListOps[Comment], _CreateOps[Comment], _DeleteOps
/comments — collection list/create + per-id delete. CTFd exposes no GET-by-id or PATCH.
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Configs
ConfigsResource(http)
Bases: Resource
/configs — keyed by string (not integer id), plus the /configs/fields sub-resource.
The collection endpoint also accepts PATCH for bulk updates, which has
no equivalent in the generic CRUD mixins.
Source code in ctfd/resources/_base.py
bulk_update(body)
async
Update multiple configuration keys in one call (PATCH /configs).
Source code in ctfd/resources/configs.py
fields()
async
List configurable user/team profile fields (GET /configs/fields).
Source code in ctfd/resources/configs.py
Exports
ExportsResource(http)
Bases: Resource
Bindings for the /exports/raw endpoint.
The endpoint streams a ZIP archive of the entire CTFd instance, so the methods exposed here return raw bytes rather than parsed models.
Source code in ctfd/resources/_base.py
raw()
async
stream(chunk_size=DEFAULT_CHUNK_SIZE)
async
Stream the export archive in chunks of chunk_size bytes.
Source code in ctfd/resources/exports.py
Files
FilesResource(http)
Bases: _ListOps[File], _GetOps[File], _DeleteOps, Resource
/files — list, retrieve, delete, plus multipart upload and raw download.
Per the CTFd swagger, POST /files is multipart and uses the file
form field (singular) plus optional type, location,
challenge_id, page_id and solution_id companions; it is exposed
as :meth:upload rather than create because the return type is a list
of created records, not a single one.
Source code in ctfd/resources/_base.py
upload(file, *, type=None, location=None, challenge_id=None, page_id=None, solution_id=None)
async
Upload a file and return the created :class:File records.
file accepts any value supported by httpx's files= argument:
a raw bytes blob, a binary file-like object, or a (filename, content,
content_type) tuple.
Source code in ctfd/resources/files.py
download(file_id)
async
Download the raw bytes of a stored file.
Fetches the file record to resolve its location, then requests the
site-root URL {site}/files/{location} (CTFd serves uploads outside
of /api/v1).
Source code in ctfd/resources/files.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Flags
FlagsResource(http)
Bases: _ListOps[Flag], _GetOps[Flag], _CreateOps[Flag], _UpdateOps[Flag], _DeleteOps
Source code in ctfd/resources/_base.py
types()
async
List the registered flag types (GET /flags/types).
type(type_name)
async
Fetch the definition of a single flag type (GET /flags/types/{name}).
Source code in ctfd/resources/flags.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Hints
HintsResource(http)
Bases: _ListOps[Hint], _GetOps[Hint], _CreateOps[Hint], _UpdateOps[Hint], _DeleteOps
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Notifications
NotificationsResource(http)
Bases: _ListOps[Notification], _GetOps[Notification], _CreateOps[Notification], _DeleteOps
/notifications — list, retrieve, create, delete.
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Pages
PagesResource(http)
Bases: _ListOps[Page], _GetOps[Page], _CreateOps[Page], _UpdateOps[Page], _DeleteOps
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Scoreboard
ScoreboardResource(http)
Bases: Resource
/scoreboard — public scoreboard listings (no per-id endpoints).
Source code in ctfd/resources/_base.py
list()
async
Return the full scoreboard (GET /scoreboard).
top(count)
async
Return the top count entries (GET /scoreboard/top/{count}).
CTFd returns this endpoint as a mapping keyed by position (e.g.
"1": {...}, "2": {...}); the mapping is preserved here.
Source code in ctfd/resources/scoreboard.py
Shares
SharesResource(http)
Solutions
SolutionsResource(http)
Bases: _ListOps[Solution], _GetOps[Solution], _CreateOps[Solution], _UpdateOps[Solution], _DeleteOps
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Statistics
StatisticsResource(http)
Bases: Resource
/statistics/* — aggregate counters and matrices.
These endpoints return heterogeneous payloads (per-category counters, percentages, time-series matrices, ...), so they are exposed as raw mappings rather than strongly-typed models.
Source code in ctfd/resources/_base.py
Submissions
SubmissionsResource(http)
Bases: _ListOps[Submission], _GetOps[Submission], _CreateOps[Submission], _UpdateOps[Submission], _DeleteOps
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Tags
TagsResource(http)
Bases: _ListOps[Tag], _GetOps[Tag], _CreateOps[Tag], _UpdateOps[Tag], _DeleteOps
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Teams
TeamsResource(http)
Bases: _ListOps[Team], _GetOps[Team], _CreateOps[Team], _UpdateOps[Team], _DeleteOps
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Tokens
TokensResource(http)
Bases: _ListOps[Token], _GetOps[Token], _CreateOps[Token], _DeleteOps
/tokens — list, retrieve, create, delete (no PATCH on tokens).
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Topics
TopicsResource(http)
Bases: _ListOps[Topic], _GetOps[Topic], _CreateOps[Topic], _DeleteOps
/topics — list, retrieve, create, delete by id, plus unlink on the collection.
Source code in ctfd/resources/_base.py
unlink(*, target_id, type)
async
Detach a topic from a target (challenge, page, ...).
Maps to DELETE /topics?type=...&target_id=...; the topic record
itself is preserved.
Source code in ctfd/resources/topics.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Unlocks
UnlocksResource(http)
Bases: _ListOps[Unlock], _CreateOps[Unlock]
/unlocks — list and create only (no per-id endpoints).
Source code in ctfd/resources/_base.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.
Users
UsersResource(http)
Bases: _ListOps[User], _GetOps[User], _CreateOps[User], _UpdateOps[User], _DeleteOps
Source code in ctfd/resources/_base.py
email(user_id, body)
async
Send an email to a user (POST /users/{id}/email).
Source code in ctfd/resources/users.py
list(**params)
async
Fetch the first page of the collection as a list.
Source code in ctfd/resources/_base.py
iter(**params)
Return an async iterator that walks every page of the collection.