Skip to content

jotonedev/ctftime_api

Repository files navigation

ctftime_api

PyPI - Python Version PyPI - Status PyPI - Version

A simple Python wrapper for the CTFTime API that provides an asynchronous interface to retrieve CTF event and team information.

Features

  • Asynchronous: Utilize Python's async/await for non-blocking API requests.
  • Type Safe: Fully type annotated using Pydantic models.
  • Modular: Organized into client and models modules for easy maintenance and extension.
  • Tested: Includes comprehensive unit tests in the tests directory.

Installation

Install via Poetry:

git clone https://github.com/jotonedev/ctftime_api
cd ctftime_api
poetry install

Or via pip (recommended):

pip install ctftime_api

Usage

Create a client to interact with the CTFTime API. For example, to get the top teams for the current year:

import asyncio
from ctftime_api.client import CTFTimeClient

async def main():
    client = CTFTimeClient()
    top_teams = await client.get_top_teams_per_year()
    for team in top_teams:
        print(f"{team.name} (ID: {team.id}) - Points: {team.points}")
    await client.close()

asyncio.run(main())

For more detailed examples, check the examples directory.

Documentation

Full API documentation is available at https://jotonedev.github.io/ctftime_api.

Contributing

This project is licensed under the GNU General Public License v3 or later (GPLv3+).

Additional Resources