A Python package to interact with the Clash of Clans API
Project description
Clashpy Python Package
The Clashpy Python package provides a simple and convenient way to interact with the Clash of Clans API, allowing you to retrieve information about clans and players in the Clash of Clans game.
Installation
You can install the Clashpy package using pip:
pip install clashpy
Usage
- Import the necessary classes from the package:
import clashpy
api_key = "your_api_key_here"
- Create an instance of the
Connectclass with your API key:
connect = clashpy.Connect(api_key)
- Create instances of
ClanorPlayerusing theclanandplayermethods of theConnectinstance:
# Example for Clan
clan_id = "#2YVQ0VJ8P"
clan = connect.clan(clan_id)
members, chat = clan.info("members", "chatLanguage")
warlog = clan.warlog()
# Example for Player
player_tag = "#PJ2ULUGQ0"
my_player = connect.player(player_tag)
heroes, exp = my_player.info("heroes", "expLevel")
- Use the created instances to retrieve information about clans and players.
Classes
Connect
The Connect class is used to create instances of the Clan and Player classes, and takes your Clash of Clans API key as an argument.
Methods:
clan(tag): Create an instance of theClanclass with the specified clan tag.player(tag): Create an instance of thePlayerclass with the specified player tag.
Clan
The Clan class allows you to retrieve information about a Clash of Clans clan.
Methods:
info(*args): Retrieve clan information for the specified attributes. Pass attribute names as arguments to get specific data.members(): Retrieve a list of clan members.warlog(): Retrieve the war log for the clan.capitalraidseasons(): Retrieve the capital raid seasons for the clan.currentwar(): Retrieve information about the clan's current war.warleague(): Retrieve information about the clan's current war league group.warleaguewars(): Retrieve information about the clan's war league wars.
Available Arguments:
tagnametypedescriptionlocationisFamilyFriendlybadgeUrlsclanLevelclanPointsclanBuilderBasePointsclanVersusPointsclanCapitalPointscapitalLeaguerequiredTrophieswarFrequencywarWinStreakwarWinsisWarLogPublicwarLeaguemembersmemberListlabelsrequiredBuilderBaseTrophiesrequiredVersusTrophiesrequiredTownhallLevelclanCapitalchatLanguage
Player
The Player class allows you to retrieve information about a Clash of Clans player.
Methods:
info(*args): Retrieve player information for the specified attributes. Pass attribute names as arguments to get specific data.
Available Arguments:
tagnametownHallLeveltownHallWeaponLevelexpLeveltrophiesbestTrophieswarStarsattackWinsdefenseWinsbuilderHallLevelbuilderBaseTrophiesversusTrophiesbestBuilderBaseTrophiesbestVersusTrophiesversusBattleWinsrolewarPreferencedonationsdonationsReceivedclanCapitalContributionsclanleaguebuilderBaseLeagueachievementsplayerHouselabelstroopsheroesspells
Example
import clashpy
api_key = "your_api_key_here"
connect = clashpy.Connect(api_key)
# Retrieve clan and player information
clan_id = "#2YVQ0VJ8P"
clan = connect.clan(clan_id)
members, chat = clan.info("members", "chatLanguage")
warlog = clan.warlog()
player_tag = "#PJ2ULUGQ0"
my_player = connect.player(player_tag)
heroes, exp = my_player.info("heroes", "expLevel")
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on the GitHub repository.
License
This package is open-source and available under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clashpy-1.0.2.tar.gz.
File metadata
- Download URL: clashpy-1.0.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057b838d8be9ccbb5540dc8c8c195e39093cecbaf4a90b243fb0e18e0e53d300
|
|
| MD5 |
fdad66a4119c04f8fc6d06427e54d347
|
|
| BLAKE2b-256 |
5b572cd419f6704dc42d7723ef83b78cf90575d0fd1db839c8256128dd8527cc
|
File details
Details for the file clashpy-1.0.2-py3-none-any.whl.
File metadata
- Download URL: clashpy-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
226861a445d8b8c7f96069b1f921a499d83f667c14d167513a60880c57cdb01d
|
|
| MD5 |
78d1e874a754f8c5f21c641199babcd6
|
|
| BLAKE2b-256 |
4da86b99bbe7b7449ffab303cd0de8bc03c9508eb2daeaabcf1b5bb1f02b9628
|