Skip to content

cli

cli

cocapi CLI — query the Clash of Clans API from the terminal.

Requires the cli extra::

pip install 'cocapi[cli]'

login

login(
    email: str = Option(
        ..., "--email", "-e", help="Developer portal email."
    ),
    password: str = Option(
        ...,
        "--password",
        "-p",
        help="Developer portal password.",
    ),
) -> None

Log in with developer portal credentials and persist the API key.

After logging in, all other commands will use the persisted key automatically — no --token needed.

Source code in cocapi/cli.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
@app.command()
def login(
    email: str = typer.Option(..., "--email", "-e", help="Developer portal email."),
    password: str = typer.Option(
        ..., "--password", "-p", help="Developer portal password."
    ),
) -> None:
    """Log in with developer portal credentials and persist the API key.

    After logging in, all other commands will use the persisted key
    automatically — no --token needed.
    """
    config = ApiConfig(persist_keys=True)
    try:
        api = CocApi.from_credentials(email, password, config=config)
    except Exception as e:
        typer.echo(f"Login failed: {e}", err=True)
        raise typer.Exit(1) from None
    typer.echo(f"Logged in. Token persisted to {_DEFAULT_KEY_STORAGE_PATH}")
    typer.echo(f"Token: {api.token[:20]}...")

clan

clan(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get clan information.

Source code in cocapi/cli.py
144
145
146
147
148
149
150
151
152
153
@app.command()
def clan(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get clan information."""
    _output(_get_api(token, email, password).clan_tag(tag), as_json)

player

player(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get player information.

Source code in cocapi/cli.py
156
157
158
159
160
161
162
163
164
165
@app.command()
def player(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get player information."""
    _output(_get_api(token, email, password).players(tag), as_json)

members

members(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        50, "--limit", "-l", help="Max members to show."
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List clan members.

Source code in cocapi/cli.py
168
169
170
171
172
173
174
175
176
177
178
179
180
@app.command()
def members(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(50, "--limit", "-l", help="Max members to show."),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List clan members."""
    _output(
        _get_api(token, email, password).clan_members(tag, {"limit": limit}), as_json
    )

war

war(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get current clan war.

Source code in cocapi/cli.py
183
184
185
186
187
188
189
190
191
192
@app.command()
def war(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get current clan war."""
    _output(_get_api(token, email, password).clan_current_war(tag), as_json)

search

search(
    name: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        10, "--limit", "-l", help=_LIMIT_HELP
    ),
    war_frequency: str | None = Option(
        None,
        "--war-frequency",
        help="Filter: always, moreThanOncePerWeek, etc.",
    ),
    location_id: int | None = Option(
        None, "--location-id", help="Filter by location ID."
    ),
    min_members: int | None = Option(
        None, "--min-members", help="Filter by min members."
    ),
    max_members: int | None = Option(
        None, "--max-members", help="Filter by max members."
    ),
    min_clan_points: int | None = Option(
        None,
        "--min-points",
        help="Filter by min clan points.",
    ),
    min_clan_level: int | None = Option(
        None,
        "--min-level",
        help="Filter by min clan level.",
    ),
    label_ids: str | None = Option(
        None,
        "--label-ids",
        help="Comma-separated label IDs.",
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Search clans by name.

Source code in cocapi/cli.py
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
@app.command()
def search(
    name: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(10, "--limit", "-l", help=_LIMIT_HELP),
    war_frequency: str | None = typer.Option(
        None, "--war-frequency", help="Filter: always, moreThanOncePerWeek, etc."
    ),
    location_id: int | None = typer.Option(
        None, "--location-id", help="Filter by location ID."
    ),
    min_members: int | None = typer.Option(
        None, "--min-members", help="Filter by min members."
    ),
    max_members: int | None = typer.Option(
        None, "--max-members", help="Filter by max members."
    ),
    min_clan_points: int | None = typer.Option(
        None, "--min-points", help="Filter by min clan points."
    ),
    min_clan_level: int | None = typer.Option(
        None, "--min-level", help="Filter by min clan level."
    ),
    label_ids: str | None = typer.Option(
        None, "--label-ids", help="Comma-separated label IDs."
    ),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Search clans by name."""
    _output(
        _get_api(token, email, password).clan(
            name,
            limit,
            war_frequency=war_frequency,
            location_id=location_id,
            min_members=min_members,
            max_members=max_members,
            min_clan_points=min_clan_points,
            min_clan_level=min_clan_level,
            label_ids=label_ids,
        ),
        as_json,
    )

leagues

leagues(
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List leagues.

Source code in cocapi/cli.py
242
243
244
245
246
247
248
249
250
@app.command()
def leagues(
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List leagues."""
    _output(_get_api(token, email, password).league(), as_json)

goldpass

goldpass(
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get current gold pass season.

Source code in cocapi/cli.py
253
254
255
256
257
258
259
260
261
@app.command()
def goldpass(
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get current gold pass season."""
    _output(_get_api(token, email, password).goldpass(), as_json)

locations

locations(
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        50, "--limit", "-l", help=_LIMIT_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List locations.

Source code in cocapi/cli.py
264
265
266
267
268
269
270
271
272
273
@app.command()
def locations(
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(50, "--limit", "-l", help=_LIMIT_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List locations."""
    _output(_get_api(token, email, password).location({"limit": limit}), as_json)

warlog

warlog(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        20, "--limit", "-l", help="Max entries."
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get clan war log.

Source code in cocapi/cli.py
276
277
278
279
280
281
282
283
284
285
286
287
288
@app.command()
def warlog(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(20, "--limit", "-l", help="Max entries."),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get clan war log."""
    _output(
        _get_api(token, email, password).clan_war_log(tag, {"limit": limit}), as_json
    )

cwl

cwl(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get clan's current CWL league group.

Source code in cocapi/cli.py
291
292
293
294
295
296
297
298
299
300
@app.command()
def cwl(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get clan's current CWL league group."""
    _output(_get_api(token, email, password).clan_leaguegroup(tag), as_json)

raids

raids(
    tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        5, "--limit", "-l", help="Max seasons."
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get clan capital raid seasons.

Source code in cocapi/cli.py
303
304
305
306
307
308
309
310
311
312
313
314
315
316
@app.command()
def raids(
    tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(5, "--limit", "-l", help="Max seasons."),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get clan capital raid seasons."""
    _output(
        _get_api(token, email, password).clan_capitalraidseasons(tag, {"limit": limit}),
        as_json,
    )

cwl_war

cwl_war(
    war_tag: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get a specific CWL war by war tag.

Source code in cocapi/cli.py
319
320
321
322
323
324
325
326
327
328
@app.command(name="cwl-war")
def cwl_war(
    war_tag: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get a specific CWL war by war tag."""
    _output(_get_api(token, email, password).warleague(war_tag), as_json)

location_info

location_info(
    location_id: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get info for a specific location by ID.

Source code in cocapi/cli.py
331
332
333
334
335
336
337
338
339
340
@app.command(name="location")
def location_info(
    location_id: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get info for a specific location by ID."""
    _output(_get_api(token, email, password).location_id(location_id), as_json)

rankings

rankings(
    location_id: str,
    ranking_type: str = Argument(
        help="Type: clans, players, clans-builder-base, players-builder-base, capitals."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        20, "--limit", "-l", help=_LIMIT_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get rankings for a location.

Examples:

cocapi rankings 32000087 clans

cocapi rankings 32000087 players --limit 50

cocapi rankings 32000087 capitals
Source code in cocapi/cli.py
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
@app.command(name="rankings")
def rankings(
    location_id: str,
    ranking_type: str = typer.Argument(
        help="Type: clans, players, clans-builder-base, players-builder-base, capitals."
    ),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(20, "--limit", "-l", help=_LIMIT_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get rankings for a location.

    Examples:

        cocapi rankings 32000087 clans

        cocapi rankings 32000087 players --limit 50

        cocapi rankings 32000087 capitals
    """
    api = _get_api(token, email, password)
    params = {"limit": limit}
    methods = {
        "clans": api.location_id_clan_rank,
        "players": api.location_id_player_rank,
        "clans-builder-base": api.location_clans_builder_base,
        "players-builder-base": api.location_players_builder_base,
        "capitals": api.location_capital_rankings,
    }
    method = methods.get(ranking_type)
    if method is None:
        typer.echo(
            f"Error: unknown ranking type '{ranking_type}'. "
            f"Choose from: {', '.join(methods)}",
            err=True,
        )
        raise typer.Exit(1)
    _output(method(location_id, params), as_json)

league_info

league_info(
    league_id: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Get info for a specific league by ID.

Source code in cocapi/cli.py
385
386
387
388
389
390
391
392
393
394
@app.command(name="league")
def league_info(
    league_id: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Get info for a specific league by ID."""
    _output(_get_api(token, email, password).league_id(league_id), as_json)

league_seasons

league_seasons(
    league_id: str,
    season_id: str | None = Argument(
        None, help="Season ID (e.g. 2025-01) for rankings."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        50, "--limit", "-l", help=_LIMIT_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List league seasons, or get rankings for a specific season.

Examples:

cocapi league-seasons 29000022

cocapi league-seasons 29000022 2025-01 --limit 100
Source code in cocapi/cli.py
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
@app.command(name="league-seasons")
def league_seasons(
    league_id: str,
    season_id: str | None = typer.Argument(
        None, help="Season ID (e.g. 2025-01) for rankings."
    ),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(50, "--limit", "-l", help=_LIMIT_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List league seasons, or get rankings for a specific season.

    Examples:

        cocapi league-seasons 29000022

        cocapi league-seasons 29000022 2025-01 --limit 100
    """
    api = _get_api(token, email, password)
    if season_id:
        _output(api.league_season_id(league_id, season_id, {"limit": limit}), as_json)
    else:
        _output(api.league_season(league_id, {"limit": limit}), as_json)

war_leagues

war_leagues(
    league_id: str | None = Argument(
        None, help="War league ID for details."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List war leagues, or get a specific war league by ID.

Source code in cocapi/cli.py
424
425
426
427
428
429
430
431
432
433
434
435
436
437
@app.command(name="war-leagues")
def war_leagues(
    league_id: str | None = typer.Argument(None, help="War league ID for details."),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List war leagues, or get a specific war league by ID."""
    api = _get_api(token, email, password)
    if league_id:
        _output(api.warleagues_id(league_id), as_json)
    else:
        _output(api.warleagues(), as_json)

capital_leagues

capital_leagues(
    league_id: str | None = Argument(
        None, help="Capital league ID for details."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        50, "--limit", "-l", help=_LIMIT_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List capital leagues, or get a specific capital league by ID.

Source code in cocapi/cli.py
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
@app.command(name="capital-leagues")
def capital_leagues(
    league_id: str | None = typer.Argument(None, help="Capital league ID for details."),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(50, "--limit", "-l", help=_LIMIT_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List capital leagues, or get a specific capital league by ID."""
    api = _get_api(token, email, password)
    if league_id:
        _output(api.capitalleagues_id(league_id), as_json)
    else:
        _output(api.capitalleagues({"limit": limit}), as_json)

builder_base_leagues

builder_base_leagues(
    league_id: str | None = Argument(
        None, help="Builder base league ID for details."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        50, "--limit", "-l", help=_LIMIT_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List builder base leagues, or get a specific one by ID.

Source code in cocapi/cli.py
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
@app.command(name="builder-base-leagues")
def builder_base_leagues(
    league_id: str | None = typer.Argument(
        None, help="Builder base league ID for details."
    ),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(50, "--limit", "-l", help=_LIMIT_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List builder base leagues, or get a specific one by ID."""
    api = _get_api(token, email, password)
    if league_id:
        _output(api.builderbaseleagues_id(league_id), as_json)
    else:
        _output(api.builderbaseleagues({"limit": limit}), as_json)

league_tiers

league_tiers(
    tier_id: str | None = Argument(
        None, help="League tier ID for details."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    limit: int = Option(
        50, "--limit", "-l", help=_LIMIT_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List league tiers, or get a specific tier by ID.

Source code in cocapi/cli.py
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
@app.command(name="league-tiers")
def league_tiers(
    tier_id: str | None = typer.Argument(None, help="League tier ID for details."),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    limit: int = typer.Option(50, "--limit", "-l", help=_LIMIT_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List league tiers, or get a specific tier by ID."""
    api = _get_api(token, email, password)
    if tier_id:
        _output(api.leaguetiers_id(tier_id), as_json)
    else:
        _output(api.leaguetiers({"limit": limit}), as_json)

labels

labels(
    label_type: str = Argument(
        help="Type: clans or players."
    ),
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

List labels for clans or players.

Examples:

cocapi labels clans

cocapi labels players
Source code in cocapi/cli.py
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
@app.command()
def labels(
    label_type: str = typer.Argument(help="Type: clans or players."),
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """List labels for clans or players.

    Examples:

        cocapi labels clans

        cocapi labels players
    """
    api = _get_api(token, email, password)
    if label_type == "clans":
        _output(api.labels_clans(), as_json)
    elif label_type == "players":
        _output(api.labels_players(), as_json)
    else:
        typer.echo(
            f"Error: unknown label type '{label_type}'. Choose from: clans, players",
            err=True,
        )
        raise typer.Exit(1)

verify_token

verify_token(
    player_tag: str,
    player_token: str,
    token: str | None = Option(
        None, "--token", "-t", help=_TOKEN_HELP
    ),
    email: str | None = Option(
        None, "--email", "-e", help=_EMAIL_HELP
    ),
    password: str | None = Option(
        None, "--password", "-p", help=_PASSWORD_HELP
    ),
    as_json: bool = Option(
        False, "--json", help=_JSON_HELP
    ),
) -> None

Verify a player API token (from in-game settings).

Source code in cocapi/cli.py
522
523
524
525
526
527
528
529
530
531
532
533
534
535
@app.command(name="verify-token")
def verify_token(
    player_tag: str,
    player_token: str,
    token: str | None = typer.Option(None, "--token", "-t", help=_TOKEN_HELP),
    email: str | None = typer.Option(None, "--email", "-e", help=_EMAIL_HELP),
    password: str | None = typer.Option(None, "--password", "-p", help=_PASSWORD_HELP),
    as_json: bool = typer.Option(False, "--json", help=_JSON_HELP),
) -> None:
    """Verify a player API token (from in-game settings)."""
    _output(
        _get_api(token, email, password).verify_player_token(player_tag, player_token),
        as_json,
    )