Skip to main content

A Python API wrapper for the Toontown Rewritten and Corporate Clash APIs

Project description

pytoontown

A Python API Wrapper for popular toontown games (Toontown Rewritten, Toontown: Corporate Clash). Get data on invasions, population, districts, news and more!

Features

The Toontown Rewritten API Features 3 Classes:

  • ToontownRewrittenInvasion
  • ToontownRewrittenPopulation
  • ToontownRewrittenSillyMeter

The Corporate Clash API features one class, CorporateClashAPI, which contains information on districts and the latest corporate clash news.

Installing

python3 -m pip install --upgrade pytoontown

Documentation

Read the documentation here

Code Example

    from pytoontown.toontownrewritten import *
    from pytoontown.corporateclash import *
    from time import sleep

    invasion = ToontownRewrittenInvasion()
    population = ToontownRewrittenPopulation()
    sillymeter = ToontownRewrittenSillyMeter()
    clash = CorporateClashAPI()

    #Refreshes all of the API data
    def refresh():
        invasion.refresh()
        population.refresh()
        sillymeter.refresh()
        clash.refresh()

    #Print out all of the API Data
    def print_data():
        refresh()
        #Retrieve the invasion data as an array.
        #For more information on `as_array`, view the documentation.
        print(f"TTR Invasions: {invasion.invasions(as_array=True)}")

        #Total population in TTR
        print(f"Total Population: {population.total_population}")

        #Population by district in TTR, represented as a dictionary
        print(f"Population by District: {population.population_by_district}")

        #TTR Silly Meter State, which is either "Active", "Reward", or "Inactive"
        print(f"Silly meter state: {sillymeter.state()}")

        #TTR Silly meter rewards (the three silly teams available)
        print(f"Silly Meter rewards: {sillymeter.rewards()}")

        #Description of the Silly teams available
        print(f"Silly meter reward descriptions: {sillymeter.reward_descriptions()}")

        #Silly Team winner (if in reward state)
        print(f"Silly meter winner: {sillymeter.winner()}")

        #how many points each silly team has
        print(f"Silly meter reward points: {sillymeter.reward_points()}")

        #Corporate clash district breakdown, represented by an array of district objects (dictionaries) (read documentation for more information)
        print(f"Corporate clash districts: {clash.districts()}")

        #Corporate clash news articles, represneted by an array of news articles (dictionaries) (read documentation for more information)
        print(f"Corporate clash news: {clash.news()}")

    
    #Print out the API data every 10 minutes
    while(True):
        print_data()
        time.sleep(600)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytoontown-0.0.6.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

pytoontown-0.0.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pytoontown-0.0.6.tar.gz.

File metadata

  • Download URL: pytoontown-0.0.6.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for pytoontown-0.0.6.tar.gz
Algorithm Hash digest
SHA256 ea8a117ad1a25d188abb19f3248c8a2fa53a5889afdc31511fb150565caf4558
MD5 7620880b18edc0523ed08acaf551247a
BLAKE2b-256 d2ee9beae667f4d063ab49ab6f4d715c2f70015f22a58c006cd152eac1b4a4c2

See more details on using hashes here.

File details

Details for the file pytoontown-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: pytoontown-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for pytoontown-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b1f029f5d5a2770443cab1cfc9b5a9ac26cf5ff9e38369902eff48e67160b052
MD5 2d57f48ff52f6983f80a0fde8ad4b1cb
BLAKE2b-256 c7046f2be3c547ae1876fc727f0e0148f6d2e96b4f20fcde6ec2c28f8886d03f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page