ctfy.sdk.resources.competitions
client.competitions — discover competitions (list / get).
Acting within a competition — register, your team, invites, challenges,
instances, submissions, standings — lives on the scoped handle
client.competition(id) (ctfy.sdk.competition.Competition).
1"""``client.competitions`` — discover competitions (list / get). 2 3Acting *within* a competition — register, your team, invites, challenges, 4instances, submissions, standings — lives on the scoped handle 5``client.competition(id)`` (:class:`ctfy.sdk.competition.Competition`). 6""" 7 8from __future__ import annotations 9 10import builtins 11from typing import Any 12 13from ctfy.sdk._helpers import _extract_items, _raise_for_status 14from ctfy.sdk.base import BaseHttpClient 15from ctfy.server.models import CompetitionDetail, CompetitionInfo 16 17 18class CompetitionsResource: 19 """Browse competitions. To act within one, use ``client.competition(id)``.""" 20 21 def __init__(self, http: BaseHttpClient) -> None: 22 self._http = http 23 24 def list( 25 self, phase: str = "", offset: int = 0, limit: int = 50 26 ) -> builtins.list[CompetitionInfo]: 27 """Public competition list. ``phase`` ∈ ``"" | "upcoming" | 28 "running" | "past"`` ("" = all). Start here, then scope into one 29 with ``client.competition(comp.id)``.""" 30 params: dict[str, Any] = {"offset": offset, "limit": limit} 31 if phase: 32 params["phase"] = phase 33 resp = self._http.request("GET", "/competitions", params=params) 34 _raise_for_status(resp) 35 return _extract_items(resp.json(), CompetitionInfo) 36 37 def get(self, competition_id: str) -> CompetitionDetail: 38 """Full competition detail including resolved challenge summaries 39 (``.challenges``). Same as ``client.competition(id).detail()``.""" 40 resp = self._http.request("GET", f"/competitions/{competition_id}") 41 _raise_for_status(resp) 42 return CompetitionDetail.model_validate(resp.json())
class
CompetitionsResource:
19class CompetitionsResource: 20 """Browse competitions. To act within one, use ``client.competition(id)``.""" 21 22 def __init__(self, http: BaseHttpClient) -> None: 23 self._http = http 24 25 def list( 26 self, phase: str = "", offset: int = 0, limit: int = 50 27 ) -> builtins.list[CompetitionInfo]: 28 """Public competition list. ``phase`` ∈ ``"" | "upcoming" | 29 "running" | "past"`` ("" = all). Start here, then scope into one 30 with ``client.competition(comp.id)``.""" 31 params: dict[str, Any] = {"offset": offset, "limit": limit} 32 if phase: 33 params["phase"] = phase 34 resp = self._http.request("GET", "/competitions", params=params) 35 _raise_for_status(resp) 36 return _extract_items(resp.json(), CompetitionInfo) 37 38 def get(self, competition_id: str) -> CompetitionDetail: 39 """Full competition detail including resolved challenge summaries 40 (``.challenges``). Same as ``client.competition(id).detail()``.""" 41 resp = self._http.request("GET", f"/competitions/{competition_id}") 42 _raise_for_status(resp) 43 return CompetitionDetail.model_validate(resp.json())
Browse competitions. To act within one, use client.competition(id).
def
list( self, phase: str = '', offset: int = 0, limit: int = 50) -> list[ctfy.server.models.CompetitionInfo]:
25 def list( 26 self, phase: str = "", offset: int = 0, limit: int = 50 27 ) -> builtins.list[CompetitionInfo]: 28 """Public competition list. ``phase`` ∈ ``"" | "upcoming" | 29 "running" | "past"`` ("" = all). Start here, then scope into one 30 with ``client.competition(comp.id)``.""" 31 params: dict[str, Any] = {"offset": offset, "limit": limit} 32 if phase: 33 params["phase"] = phase 34 resp = self._http.request("GET", "/competitions", params=params) 35 _raise_for_status(resp) 36 return _extract_items(resp.json(), CompetitionInfo)
Public competition list. phase ∈ "" | "upcoming" |
"running" | "past" ("" = all). Start here, then scope into one
with client.competition(comp.id).
38 def get(self, competition_id: str) -> CompetitionDetail: 39 """Full competition detail including resolved challenge summaries 40 (``.challenges``). Same as ``client.competition(id).detail()``.""" 41 resp = self._http.request("GET", f"/competitions/{competition_id}") 42 _raise_for_status(resp) 43 return CompetitionDetail.model_validate(resp.json())
Full competition detail including resolved challenge summaries
(ctfy.sdk.resources.challenges). Same as client.competition(id).detail().