{"id":15297458,"url":"https://github.com/tonybenoy/cocapi","last_synced_at":"2026-02-12T12:14:22.493Z","repository":{"id":54048541,"uuid":"140027083","full_name":"tonybenoy/cocapi","owner":"tonybenoy","description":"Python Wrapper for SuperCells Clash Of Clan API","archived":false,"fork":false,"pushed_at":"2024-11-20T13:58:33.000Z","size":134,"stargazers_count":19,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-12-09T21:32:06.187Z","etag":null,"topics":["clash-of-clans","clashapi","clashofclans","python","python-3","wrapper","wrapper-api"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonybenoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"tonybenoy","patreon":"tonybenoy"}},"created_at":"2018-07-06T20:30:44.000Z","updated_at":"2024-11-20T13:57:05.000Z","dependencies_parsed_at":"2024-04-12T03:47:57.676Z","dependency_job_id":null,"html_url":"https://github.com/tonybenoy/cocapi","commit_stats":{"total_commits":76,"total_committers":7,"mean_commits":"10.857142857142858","dds":0.631578947368421,"last_synced_commit":"77d831a9e52fbaee96c900b1b86273d6443d825f"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybenoy%2Fcocapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybenoy%2Fcocapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybenoy%2Fcocapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonybenoy%2Fcocapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonybenoy","download_url":"https://codeload.github.com/tonybenoy/cocapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230355829,"owners_count":18213536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clash-of-clans","clashapi","clashofclans","python","python-3","wrapper","wrapper-api"],"created_at":"2024-09-30T19:17:44.570Z","updated_at":"2026-02-12T12:14:22.480Z","avatar_url":"https://github.com/tonybenoy.png","language":"Python","readme":"\u003cp\u003e\n    \u003ca href=\"https://github.com/tonybenoy/cocapi/actions\"\u003e\n        \u003cimg src=\"https://github.com/tonybenoy/cocapi/workflows/CI/badge.svg\" alt=\"CI Status\" height=\"20\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/cocapi/\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/cocapi\" alt=\"Pypi version\" height=\"21\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp\u003e\n    \u003ca href=\"https://www.python.org/downloads/\"\u003e\u003cimg src=\"https://img.shields.io/badge/python-3.10+-blue.svg\" alt=\"Python version\" height=\"17\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/tonybenoy/cocapi/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/tonybenoy/cocapi\" alt=\"License\" height=\"17\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/astral-sh/ruff\"\u003e\n        \u003cimg src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\" alt=\"Ruff\" height=\"17\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# ClashOfClansAPI\n\nA high-performance Python wrapper for SuperCell's Clash of Clans API with enterprise-grade features including async support, response caching, retry logic, middleware system, and comprehensive metrics.\n\n**🎯 Complete API Coverage**: All official API endpoints implemented\n**⚡ High Performance**: Async support with intelligent caching and rate limiting  \n**🔄 100% Backward Compatible**: Drop-in replacement for existing code  \n**🛡️ Production Ready**: Retry logic, middleware pipeline, metrics tracking, and comprehensive error handling  \n**🚀 Future-Proof**: Custom endpoint support and dynamic Pydantic models\n\nGet Token from [https://developer.clashofclans.com/](https://developer.clashofclans.com/)\n\n## ✨ Key Features\n\n- **🔄 Sync \u0026 Async Support**: Same API works for both sync and async\n- **🚀 Custom Endpoints**: Future-proof with any new SuperCell endpoints  \n- **💾 Intelligent Caching**: Response caching with configurable TTL and statistics\n- **🔁 Smart Retry Logic**: Exponential backoff with configurable retry policies\n- **⚡ Rate Limiting**: Built-in protection against API rate limits (async mode)\n- **🛡️ Comprehensive Error Handling**: Detailed error messages and types\n- **📊 Metrics \u0026 Analytics**: Request performance tracking and insights\n- **🔌 Middleware System**: Pluggable request/response processing pipeline\n- **🎯 Type Safety**: Complete type hints and optional Pydantic models\n- **🌐 Base URL Configuration**: Support for proxies and testing environments\n- **🔄 100% Backward Compatible**: Drop-in replacement for existing code\n\n# Install\n\n```bash\n# Standard installation (dict responses)\npip install cocapi\n\n# With optional Pydantic models support\npip install 'cocapi[pydantic]'\n```\n\n\n# Usage Examples\n\n## Basic Synchronous Usage (Backward Compatible)\n\n```python\nfrom cocapi import CocApi\n\ntoken = 'YOUR_API_TOKEN'\ntimeout = 60  # requests timeout\n\n# Basic initialization (same as before)\napi = CocApi(token, timeout)\n\n# With status codes (same as before)\napi = CocApi(token, timeout, status_code=True)\n```\n\n## Advanced Configuration\n\n```python\nfrom cocapi import CocApi, ApiConfig\n\n# Enterprise-grade configuration\nconfig = ApiConfig(\n    # Performance settings\n    timeout=30,\n    max_retries=5,\n    retry_delay=1.5,  # Base delay for exponential backoff\n    \n    # Caching configuration  \n    enable_caching=True,\n    cache_ttl=600,  # Cache responses for 10 minutes\n    \n    # Async rate limiting (async mode only)\n    enable_rate_limiting=True,\n    requests_per_second=10.0,\n    burst_limit=20,\n    \n    # Advanced features\n    enable_metrics=True,\n    metrics_window_size=1000,  # Track last 1000 requests\n    use_pydantic_models=False  # Enable for type-safe models\n)\n\napi = CocApi('YOUR_API_TOKEN', config=config)\n\n# Management methods\ncache_stats = api.get_cache_stats()\nmetrics = api.get_metrics()\napi.clear_cache()\napi.clear_metrics()\n```\n\n## Asynchronous Usage\n\n```python\nimport asyncio\nfrom cocapi import CocApi, ApiConfig\n\nasync def main():\n    # Method 1: Automatic async mode with context manager (recommended)\n    async with CocApi('YOUR_API_TOKEN') as api:\n        clan = await api.clan_tag('#CLAN_TAG')\n        player = await api.players('#PLAYER_TAG')\n    \n    # Method 2: Explicit async mode\n    api = CocApi('YOUR_API_TOKEN', async_mode=True)\n    async with api:\n        clan = await api.clan_tag('#CLAN_TAG')\n    \n    # Method 3: With custom configuration\n    config = ApiConfig(timeout=30, enable_caching=True)\n    async with CocApi('YOUR_API_TOKEN', config=config) as api:\n        clan = await api.clan_tag('#CLAN_TAG')\n\n# Run async code\nasyncio.run(main())\n```\n\n## 🚀 Enterprise Features\n\n### 📊 Metrics \u0026 Analytics\n\n```python\nfrom cocapi import CocApi, ApiConfig\n\n# Enable metrics tracking\nconfig = ApiConfig(enable_metrics=True, metrics_window_size=1000)\napi = CocApi('YOUR_TOKEN', config=config)\n\n# Get comprehensive metrics after API calls\nmetrics = api.get_metrics()\nprint(f\"Total requests: {metrics['total_requests']}\")\nprint(f\"Average response time: {metrics['avg_response_time']:.2f}ms\")\nprint(f\"Cache hit rate: {metrics['cache_hit_rate']:.1%}\")\nprint(f\"Error rate: {metrics['error_rate']:.1%}\")\n```\n\n### 🔌 Middleware System\n\n```python\nfrom cocapi import CocApi\nfrom cocapi.middleware import add_user_agent_middleware, add_request_id_middleware\n\napi = CocApi('YOUR_TOKEN')\n\n# Add built-in middleware\napi.add_request_middleware(add_user_agent_middleware(\"MyApp/1.0\"))\napi.add_request_middleware(add_request_id_middleware())\n\n# Custom middleware\ndef add_custom_headers(url, headers, params):\n    headers['X-Client-Version'] = '3.0.0'\n    return url, headers, params\n\napi.add_request_middleware(add_custom_headers)\n```\n\n### 🎯 Enhanced Caching\n\n```python\nfrom cocapi import CocApi, ApiConfig\n\nconfig = ApiConfig(enable_caching=True, cache_ttl=900)  # 15 minutes\napi = CocApi('YOUR_TOKEN', config=config)\n\n# Requests are cached automatically\nclan1 = api.clan_tag('#CLAN_TAG')  # Cache miss\nclan2 = api.clan_tag('#CLAN_TAG')  # Cache hit\n\n# Cache statistics and management\nstats = api.get_cache_stats()\napi.clear_cache()\n```\n\n### ⚡ Async Rate Limiting\n\n```python\nfrom cocapi import CocApi, ApiConfig\nimport asyncio\n\nasync def high_throughput_example():\n    config = ApiConfig(\n        enable_rate_limiting=True,\n        requests_per_second=10.0,\n        burst_limit=20\n    )\n    \n    async with CocApi('YOUR_TOKEN', config=config) as api:\n        # Concurrent requests with automatic rate limiting\n        clan_tags = ['#CLAN1', '#CLAN2', '#CLAN3']\n        tasks = [api.clan_tag(tag) for tag in clan_tags]\n        results = await asyncio.gather(*tasks)\n\nasyncio.run(high_throughput_example())\n```\n\n## Pydantic Models (Optional)\n\nFor enhanced type safety and structured data validation, cocapi supports optional Pydantic models:\n\n```python\nfrom cocapi import CocApi, ApiConfig, Clan, Player\n\n# Enable Pydantic models\nconfig = ApiConfig(use_pydantic_models=True)\napi = CocApi('YOUR_API_TOKEN', config=config)\n\n# Get structured clan data\nclan = api.clan_tag('#2PP')  # Returns Clan model instead of dict\nprint(clan.name)             # Type-safe attribute access\nprint(clan.clanLevel)        # IDE autocompletion support\nprint(clan.members)          # Validated data structure\n\n# Get structured player data\nplayer = api.players('#PLAYER_TAG')  # Returns Player model\nprint(player.townHallLevel)         # Type-safe attributes\nprint(player.trophies)\nprint(player.clan.name if player.clan else \"No clan\")\n\n# Works with async too\nasync def get_data():\n    config = ApiConfig(use_pydantic_models=True)\n    async with CocApi('YOUR_TOKEN', config=config) as api:\n        clan = await api.clan_tag('#TAG')  # Returns Clan model\n        return clan.name\n\n# Available models: Clan, Player, ClanMember, League, Achievement, etc.\n# Import them: from cocapi import Clan, Player, ClanMember\n```\n\n### Benefits of Pydantic Models\n\n- **Type Safety**: Catch errors at development time\n- **IDE Support**: Full autocompletion and type hints\n- **Data Validation**: Automatic validation of API responses  \n- **Clean Interface**: Object-oriented access to data\n- **Documentation**: Self-documenting code with model schemas\n- **Optional**: Zero impact if not used (lazy imports)\n\n## Custom Endpoints 🚀\n\nUse any new SuperCell endpoints immediately without waiting for library updates:\n\n```python\nfrom cocapi import CocApi\n\napi = CocApi('YOUR_API_TOKEN')\n\n# Call new endpoints directly\nresult = api.custom_endpoint('/new-endpoint')\nresult = api.custom_endpoint('/clans/search', {'name': 'my clan', 'limit': 10})\n\n# With dynamic Pydantic models\nresult = api.custom_endpoint('/new-endpoint', use_dynamic_model=True)\nprint(result.some_field)  # Type-safe access\n\n# Async support\nasync with CocApi('YOUR_TOKEN') as api:\n    result = await api.custom_endpoint('/new-endpoint')\n```\n\n## Base URL Configuration 🌐\n\nModify base URL for testing, proxying, or adapting to API changes:\n\n```python\nfrom cocapi import CocApi, ApiConfig\n\napi = CocApi('YOUR_TOKEN')\n\n# Change base URL (requires force=True for safety)\napi.set_base_url(\"https://api-staging.example.com/v1\", force=True)\n\n# Or set during initialization\nconfig = ApiConfig(base_url=\"https://my-proxy.com/clash/v1\")\napi = CocApi('YOUR_TOKEN', config=config)\n\n# Reset to official endpoint\napi.reset_base_url()\n```\n\n## 📈 Performance Benefits\n\n### Key Improvements\n- **⚡ Intelligent Caching**: Up to 100% faster for repeated requests\n- **🚀 Async Operations**: Handle dozens of concurrent requests efficiently\n- **🔁 Smart Retry Logic**: Exponential backoff with configurable policies\n- **📈 Monitoring**: Track error rates, response times, and cache performance\n\n### Example Setup\n```python\n# High-performance configuration\nconfig = ApiConfig(\n    enable_caching=True,\n    enable_metrics=True,\n    max_retries=3\n)\n\napi = CocApi('token', config=config)\n\n# Async mode with concurrency\nasync with CocApi('token', config=config) as api:\n    clans = await asyncio.gather(*[\n        api.clan_tag(tag) for tag in clan_tags\n    ])\n```\n\n## Migration Guide \n\n### 🔄 Upgrading to v3.0.0 - Zero Breaking Changes!\n\ncocapi 3.0.0 maintains 100% backward compatibility. Your existing code continues to work unchanged:\n\n```python\n# All existing patterns still work\nfrom cocapi import CocApi\n\napi = CocApi('YOUR_TOKEN')  # ✅ Works\napi = CocApi('YOUR_TOKEN', 60, True)  # ✅ Works\nclan = api.clan_tag('#CLAN_TAG')  # ✅ Works\n\n# To use new features, just add configuration:\nconfig = ApiConfig(enable_caching=True, cache_ttl=300)\napi = CocApi('YOUR_TOKEN', config=config)\n```\n\n## 🚀 What's New in v3.0.0\n\n**Major enterprise features** while maintaining 100% backward compatibility:\n\n- **📊 Enterprise Metrics**: Comprehensive API performance monitoring\n- **🔌 Middleware System**: Pluggable request/response processing  \n- **⚡ Enhanced Async**: Rate limiting and improved concurrency\n- **🚀 Custom Endpoints**: Future-proof support for new SuperCell endpoints\n- **🎯 Type Safety**: Enhanced type hints and Pydantic model integration\n- **🌐 Base URL Config**: Support for staging environments and proxies\n\n### Installation\n```bash\npip install --upgrade cocapi\n# Or with Pydantic support:\npip install --upgrade 'cocapi[pydantic]'\n```\n\n## Previous Releases\n\n**v2.2.x**: Pydantic models, enhanced type safety, async + Pydantic support  \n**v2.1.x**: Unified async support, intelligent caching, retry logic, enhanced configuration\n\n## Full API Reference\n\nAll methods work identically in both sync and async modes - just use `await` when in async context!\n\n---\n\n## Clans\n\n### Information about a Clan\n```python\napi.clan_tag(tag) #example tag \"#2PP\"\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"tag\": \"string\",\n  \"name\": \"string\",\n  \"type\": \"string\",\n  \"description\": \"string\",\n  \"location\": {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"isCountry\": true,\n    \"countryCode\": \"string\"\n  },\n  \"isFamilyFriendly\": true,\n  \"badgeUrls\": {\n    \"small\": \"string\",\n    \"large\": \"string\",\n    \"medium\": \"string\"\n  },\n  \"clanLevel\": 0,\n  \"clanPoints\": 0,\n  \"clanBuilderBasePoints\": 0,\n  \"clanCapitalPoints\": 0,\n  \"capitalLeague\": {\n    \"id\": 0,\n    \"name\": \"string\"\n  },\n  \"requiredTrophies\": 0,\n  \"requiredBuilderBaseTrophies\": 0,\n  \"requiredTownhallLevel\": 0,\n  \"warFrequency\": \"string\",\n  \"warWinStreak\": 0,\n  \"warWins\": 0,\n  \"isWarLogPublic\": true,\n  \"warLeague\": {\n    \"id\": 0,\n    \"name\": \"string\"\n  },\n  \"members\": 0,\n  \"memberList\": [\n    {\n      \"tag\": \"string\",\n      \"name\": \"string\",\n      \"role\": \"string\",\n      \"townHallLevel\": 0,\n      \"expLevel\": 0,\n      \"league\": {\n        \"id\": 0,\n        \"name\": \"string\",\n        \"iconUrls\": {}\n      },\n      \"leagueTier\": {\n        \"id\": 0,\n        \"name\": \"string\",\n        \"iconUrls\": {}\n      },\n      \"trophies\": 0,\n      \"builderBaseTrophies\": 0,\n      \"clanRank\": 0,\n      \"previousClanRank\": 0,\n      \"donations\": 0,\n      \"donationsReceived\": 0,\n      \"playerHouse\": {\n        \"elements\": []\n      },\n      \"builderBaseLeague\": {\n        \"id\": 0,\n        \"name\": \"string\"\n      }\n    }\n  ],\n  \"labels\": [\n    {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"iconUrls\": {}\n    }\n  ],\n  \"clanCapital\": {\n    \"capitalHallLevel\": 0,\n    \"districts\": []\n  },\n  \"chatLanguage\": {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"languageCode\": \"string\"\n  }\n}\n```\n\u003c/details\u003e\n\n#### Members Only\n```python\napi.clan_members(tag)\n```\nReturns clan member list under \"items\" in dict\n\n### Search Clans\n```python\n# Basic search by name\napi.clan(name=\"MyClans\", limit=10)\n\n# Advanced search with filters\napi.clan(\n    name=\"War\",\n    limit=20,\n    war_frequency=\"always\",\n    location_id=32000006,\n    min_members=30,\n    max_members=50,\n    min_clan_points=20000,\n    min_clan_level=10,\n    label_ids=\"56000000,56000001\"\n)\n\n# With pagination\napi.clan(name=\"MyClans\", params={\"after\": \"cursor_token\"})\n```\nSearch all clans by name and/or filtering criteria. Name must be at least 3 characters long if used.\n\n### War Log Information\n```python\napi.clan_war_log(tag)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"result\": \"string\",\n    \"endTime\": \"string\",\n    \"teamSize\": 0,\n    \"attacksPerMember\": 0,\n    \"battleModifier\": \"string\",\n    \"clan\": {\n      \"tag\": \"string\",\n      \"name\": \"string\",\n      \"badgeUrls\": {},\n      \"clanLevel\": 0,\n      \"attacks\": 0,\n      \"stars\": 0,\n      \"destructionPercentage\": 0.0,\n      \"expEarned\": 0\n    },\n    \"opponent\": {\n      \"tag\": \"string\",\n      \"name\": \"string\",\n      \"badgeUrls\": {},\n      \"clanLevel\": 0,\n      \"stars\": 0,\n      \"destructionPercentage\": 0.0\n    }\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Current War Information\n```python\napi.clan_current_war(tag)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"state\": \"string\",\n  \"teamSize\": 0,\n  \"attacksPerMember\": 0,\n  \"battleModifier\": \"string\",\n  \"preparationStartTime\": \"string\",\n  \"startTime\": \"string\",\n  \"endTime\": \"string\",\n  \"clan\": {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"badgeUrls\": {},\n    \"clanLevel\": 0,\n    \"attacks\": 0,\n    \"stars\": 0,\n    \"destructionPercentage\": 0.0,\n    \"members\": [\n      {\n        \"tag\": \"string\",\n        \"name\": \"string\",\n        \"townhallLevel\": 0,\n        \"mapPosition\": 0,\n        \"opponentAttacks\": 0,\n        \"bestOpponentAttack\": {\n          \"order\": 0,\n          \"attackerTag\": \"string\",\n          \"defenderTag\": \"string\",\n          \"stars\": 0,\n          \"destructionPercentage\": 0\n        },\n        \"attacks\": [\n          {\n            \"order\": 0,\n            \"attackerTag\": \"string\",\n            \"defenderTag\": \"string\",\n            \"stars\": 0,\n            \"destructionPercentage\": 0\n          }\n        ]\n      }\n    ]\n  },\n  \"opponent\": {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"badgeUrls\": {},\n    \"clanLevel\": 0,\n    \"attacks\": 0,\n    \"stars\": 0,\n    \"destructionPercentage\": 0.0,\n    \"members\": []\n  }\n}\n```\n\u003c/details\u003e\n\n### Clan League Group Information\n```python\napi.clan_leaguegroup(tag)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"tag\": \"string\",\n  \"state\": \"string\",\n  \"season\": \"string\",\n  \"clans\": [\n    {\n      \"tag\": \"string\",\n      \"clanLevel\": 0,\n      \"name\": \"string\",\n      \"members\": [\n        {\n          \"tag\": \"string\",\n          \"townHallLevel\": 0,\n          \"name\": \"string\"\n        }\n      ],\n      \"badgeUrls\": {}\n    }\n  ],\n  \"rounds\": [\n    {\n      \"warTags\": [\n        \"string\"\n      ]\n    }\n  ]\n}\n```\n\u003c/details\u003e\n\n### Clan Capital Raid Seasons\n```python\napi.clan_capitalraidseasons(tag)\n```\nRetrieve clan's capital raid seasons information\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"state\": \"string\",\n    \"startTime\": \"string\",\n    \"endTime\": \"string\",\n    \"capitalTotalLoot\": 0,\n    \"raidsCompleted\": 0,\n    \"totalAttacks\": 0,\n    \"enemyDistrictsDestroyed\": 0,\n    \"offensiveReward\": 0,\n    \"defensiveReward\": 0,\n    \"members\": [],\n    \"attackLog\": [],\n    \"defenseLog\": []\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Warleague Information\n```python\napi.warleague(war_tag)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"tag\": \"string\",\n  \"state\": \"string\",\n  \"season\": \"string\",\n  \"clans\": [\n    {\n      \"tag\": \"string\",\n      \"clanLevel\": 0,\n      \"name\": \"string\",\n      \"members\": [\n        {\n          \"tag\": \"string\",\n          \"townHallLevel\": 0,\n          \"name\": \"string\"\n        }\n      ],\n      \"badgeUrls\": {}\n    }\n  ],\n  \"rounds\": [\n    {\n      \"warTags\": [\n        \"string\"\n      ]\n    }\n  ]\n}\n```\n\u003c/details\u003e\n\n\n\n\n## Player\n\n### Player information\n```python\napi.players(player_tag) #for example \"#900PUCPV\"\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"tag\": \"string\",\n  \"name\": \"string\",\n  \"townHallLevel\": 0,\n  \"expLevel\": 0,\n  \"trophies\": 0,\n  \"bestTrophies\": 0,\n  \"warStars\": 0,\n  \"attackWins\": 0,\n  \"defenseWins\": 0,\n  \"builderHallLevel\": 0,\n  \"builderBaseTrophies\": 0,\n  \"bestBuilderBaseTrophies\": 0,\n  \"role\": \"string\",\n  \"warPreference\": \"string\",\n  \"donations\": 0,\n  \"donationsReceived\": 0,\n  \"clanCapitalContributions\": 0,\n  \"clan\": {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"clanLevel\": 0,\n    \"badgeUrls\": {}\n  },\n  \"leagueTier\": {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"iconUrls\": {}\n  },\n  \"builderBaseLeague\": {\n    \"id\": 0,\n    \"name\": \"string\"\n  },\n  \"achievements\": [\n    {\n      \"name\": \"string\",\n      \"stars\": 0,\n      \"value\": 0,\n      \"target\": 0,\n      \"info\": \"string\",\n      \"completionInfo\": \"string\",\n      \"village\": \"string\"\n    }\n  ],\n  \"labels\": [\n    {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"iconUrls\": {}\n    }\n  ],\n  \"troops\": [\n    {\n      \"name\": \"string\",\n      \"level\": 0,\n      \"maxLevel\": 0,\n      \"village\": \"string\"\n    }\n  ],\n  \"heroes\": [\n    {\n      \"name\": \"string\",\n      \"level\": 0,\n      \"maxLevel\": 0,\n      \"village\": \"string\"\n    }\n  ],\n  \"heroEquipment\": [],\n  \"spells\": [\n    {\n      \"name\": \"string\",\n      \"level\": 0,\n      \"maxLevel\": 0,\n      \"village\": \"string\"\n    }\n  ]\n}\n```\n\u003c/details\u003e\n\n\n\n\n### Verify Player Token\n```python\napi.verify_player_token(player_tag, \"player_api_token\")\n```\nVerify the API token found in the player's game settings to confirm account ownership.\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"tag\": \"string\",\n  \"token\": \"string\",\n  \"status\": \"string\"\n}\n```\n\u003c/details\u003e\n\n\n## Locations\n\n### All Locations Information\n```python\napi.location()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"isCountry\": true,\n    \"countryCode\": \"string\"\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Information for a Single Location\n```python\napi.location_id(location_id) #for example \"32000249\"\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"id\": 0,\n  \"name\": \"string\",\n  \"isCountry\": true,\n  \"countryCode\": \"string\"\n}\n```\n\u003c/details\u003e\n\n### Top Clans in a Location\n```python\napi.location_id_clan_rank(location_id)\n```\nTop clans in a given location\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"location\": {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"isCountry\": true,\n      \"countryCode\": \"string\"\n    },\n    \"badgeUrls\": {},\n    \"clanLevel\": 0,\n    \"members\": 0,\n    \"clanPoints\": 0,\n    \"rank\": 0,\n    \"previousRank\": 0\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Top Players in a Location\n```python\napi.location_id_player_rank(location_id)\n```\nTop players in a given location\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"expLevel\": 0,\n    \"trophies\": 0,\n    \"attackWins\": 0,\n    \"defenseWins\": 0,\n    \"rank\": 0,\n    \"previousRank\": 0,\n    \"clan\": {\n      \"tag\": \"string\",\n      \"name\": \"string\",\n      \"badgeUrls\": {}\n    },\n    \"league\": {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"iconUrls\": {}\n    },\n    \"leagueTier\": {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"iconUrls\": {}\n    }\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n\n### Top Builder Base Clans in a Location\n```python\napi.location_clans_builder_base(location_id)\n```\nTop builder base clans in a given location\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"location\": {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"isCountry\": true,\n      \"countryCode\": \"string\"\n    },\n    \"badgeUrls\": {},\n    \"clanLevel\": 0,\n    \"members\": 0,\n    \"rank\": 0,\n    \"previousRank\": 0,\n    \"clanBuilderBasePoints\": 0\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Top Builder Base Players in a Location\n```python\napi.location_players_builder_base(location_id)\n```\nTop builder base players in a given location\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"expLevel\": 0,\n    \"rank\": 0,\n    \"previousRank\": 0,\n    \"builderBaseTrophies\": 0,\n    \"clan\": {\n      \"tag\": \"string\",\n      \"name\": \"string\",\n      \"badgeUrls\": {}\n    },\n    \"builderBaseLeague\": {\n      \"id\": 0,\n      \"name\": \"string\"\n    }\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Capital Rankings in a Location\n```python\napi.location_capital_rankings(location_id)\n```\nTop capital rankings in a given location\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"location\": {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"isCountry\": true,\n      \"countryCode\": \"string\"\n    },\n    \"badgeUrls\": {},\n    \"clanLevel\": 0,\n    \"members\": 0,\n    \"rank\": 0,\n    \"previousRank\": 0,\n    \"clanCapitalPoints\": 0\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Top Versus Clans in a Location (Deprecated)\n```python\napi.location_clan_versus(location_tag)\n```\n\u003e **Deprecated**: This endpoint may no longer be available. If the API call fails, a deprecation notice is returned with `error_type: \"deprecated\"`.\n\n### Top Versus Players in a Location (Deprecated)\n```python\napi.location_player_versus(location_tag)\n```\n\u003e **Deprecated**: This endpoint may no longer be available. If the API call fails, a deprecation notice is returned with `error_type: \"deprecated\"`.\n\n\n\n\n## Leagues\n\n### List Leagues\n```python\napi.league()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"iconUrls\": {}\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n\n### League Information\n```python\napi.league_id(league_id)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"id\": 0,\n  \"name\": \"string\",\n  \"iconUrls\": {\n    \"small\": \"string\",\n    \"tiny\": \"string\",\n    \"medium\": \"string\"\n  }\n}\n```\n\u003c/details\u003e\n\n\n### List Season Leagues\n```python\napi.league_season(league_id)\n```\nInformation is available only for Legend League\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": \"string\"\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n\n### League Season Ranking\n```python\napi.league_season_id(league_id, season_id)\n```\nInformation is available only for Legend League. Note: `limit` must be between 100 and 25,000.\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"tag\": \"string\",\n    \"name\": \"string\",\n    \"expLevel\": 0,\n    \"trophies\": 0,\n    \"attackWins\": 0,\n    \"defenseWins\": 0,\n    \"rank\": 0,\n    \"clan\": {\n      \"tag\": \"string\",\n      \"name\": \"string\",\n      \"badgeUrls\": {}\n    },\n    \"leagueTier\": {\n      \"id\": 0,\n      \"name\": \"string\",\n      \"iconUrls\": {}\n    }\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### List Capital Leagues\n```python\napi.capitalleagues()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\"\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Capital League Information\n```python\napi.capitalleagues_id(league_id)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"id\": 0,\n  \"name\": \"string\"\n}\n```\n\u003c/details\u003e\n\n### List Builder Base Leagues\n```python\napi.builderbaseleagues()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\"\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### Builder Base League Information\n```python\napi.builderbaseleagues_id(league_id)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"id\": 0,\n  \"name\": \"string\"\n}\n```\n\u003c/details\u003e\n\n### List League Tiers\n```python\napi.leaguetiers()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"iconUrls\": {\n      \"small\": \"string\",\n      \"large\": \"string\"\n    }\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### League Tier Information\n```python\napi.leaguetiers_id(league_tier_id)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"id\": 0,\n  \"name\": \"string\",\n  \"iconUrls\": {\n    \"small\": \"string\",\n    \"large\": \"string\"\n  }\n}\n```\n\u003c/details\u003e\n\n### List War Leagues\n```python\napi.warleagues()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\"\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n### War League Information\n```python\napi.warleagues_id(league_id)\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"id\": 0,\n  \"name\": \"string\"\n}\n```\n\u003c/details\u003e\n\n\n\n\n## Gold Pass\n\n### Current Gold Pass Season\n```python\napi.goldpass()\n```\nGet information about the current gold pass season\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\n  \"startTime\": \"string\",\n  \"endTime\": \"string\" \n}\n```\n\u003c/details\u003e\n\n\n## Labels\n\n### List Clan Labels\n```python\napi.labels_clans()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"iconUrls\": {}\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n\n### List Player Labels\n```python\napi.labels_players()\n```\n\u003cdetails\u003e\n \u003csummary\u003eClick to view output\u003c/summary\u003e\n\n```text\n{\"items\":\n[\n  {\n    \"id\": 0,\n    \"name\": \"string\",\n    \"iconUrls\": {}\n  }\n],\n\"paging\": {\"cursors\": {}}\n}\n```\n\u003c/details\u003e\n\n\n## Credits\n- [All Contributors](../../contributors)\n\n*Note versions below 2.0.0 are not supported anymore*\n\n*DISCLAIMER: cocapi is not affiliated with SuperCell©.\n","funding_links":["https://github.com/sponsors/tonybenoy","https://patreon.com/tonybenoy"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonybenoy%2Fcocapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonybenoy%2Fcocapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonybenoy%2Fcocapi/lists"}