Results 1 to 1 of 1

Thread: coc.py: A Python API Wrapper for the Clash of Clans API

  1. #1

    coc.py: A Python API Wrapper for the Clash of Clans API

    coc.py is an easy to use, asynchronous API wrapper for the Clash of Clans API written in python.

    Key Features:


    • Asynchronous code
    • Entire coverage of the official Clash of Clans API
    • Email/password login removes the stress of managing tokens with a dynamic IP
    • Optimised for speed and performance
    • Open source project
    • Detailed documentation and changelogs

    Installing:

    Installing is easy:

    • Windows: py -3 -m pip install -U coc.py
    • Linux/OS X: python3 -m pip install -U coc.py


    Quick Example:


    Code:
    import coc
    import asyncio
    
    client = coc.Client('email', 'password')
    
    async def get_some_player(tag):
        player = await client.get_player(tag)
    
        print(player.name)
        # alternatively,
        print(str(player))
    
    async def get_five_clans(name):
        players = await client.search_clans(name=name, limit=5)
        for n in players:
            print(n, n.tag)
    
    async def main():
        await get_some_player('tag')
        await get_five_clans('name')
        await client.close()
    
    if __name__ == '__main__':
        loop = asyncio.get_event_loop()
        loop.run_until_complete(main())
    It's as simple as that! Furthermore, this library is new and will be regularly receiving updates, as the API (hopefully) grows with the game. Feel free to open an issue on GitHub if you encounter a problem, or a pull request if you have an idea that could be implemented!


    Helpful links:




    Cheers,
    mathsman
    Last edited by mathsman5132; May 1st, 2019 at 09:04 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •