Skip to main content

Client package for the download of Legion TD 2 game data.

Project description

pyltd2

Client package for the download of Legion TD 2 game data.

Installation

Dependencies

  • numpy (>= 1.16.5)
  • pandas (>= 1.2.0)
  • tqdm (>= 4.64.0)
  • requests (>= 2.1.0)

pyltdq2 can be installed using pip with the following command:

pip install pyltd2

Data structure

The object stores the data into five separate objects, regarding separate information about each match:

  1. The fighters the player built during each wave and their position(_id, playerId, wave, fighter, x, y, seq_num)
  2. The actions (Placed/Sold/Upgraded) the player made during each wave (alternative to the previous one, makes the file smaller but requires re-building the data)(_id, playerId, wave, fighter, x, y, action, seq_num)
  3. The fighters the player had(_id, playerId, fighter_1, fighter_2, ..., fighter_30)
  4. The king's hp at the end of the wave(_id, wave, left_hp, right_hp)
  5. The king's upgrades bought by each player during each wave(_id, playerId, wave, upgrade, seq_num)
  6. The leaks a player had during each wave(_id, playerId, wave, unit, seq_num)
  7. The match itself(_id, version, date, queueType, endingWave, gameLength, gameElo, playerCount, humanCount, kingSpell, side_won)
  8. The mercenaries the player received or sent during a wave(_id, playerId, received, wave, mercenary, seq_num)
  9. The party members of each match(_id, member_1, member_2, member_3, member_4, member_5, member_6, member_7, member_8)
  10. The players of the match(_id, playerId, playerName, playerSlot, legion, workers, value, cross, overallElo, stayedUntilEnd, chosenSpell, partySize, legionSpecificElo, mvpScore, leekValue, leaksCaughtValue, leftAtSeconds)
  11. The player's economy during each wave(_id, playerId, wave, workers, income, networth)
  12. The spell upgrades available in the match(_id, choice_1, choice_2, choice_3)

Examples

The following example shows how to get the details of the next 50 matches, starting from the first match played (2018-08-03T15:39:00Z) and returning the data as a DataFrame object.

from pyltd2 import LTD2Fetcher

fetcher = LTD2Fetcher("your_api_token")
fetcher.get(return_as_df=True)

The object uses the getMatchesByFilter API command to fetch a maximum of 50 matches, starting from the date_after datetime provided.

To download data for the period of time between date_after-date_before and save them to a csv file, you can use the ExhaustiveFetcher object. The following example downloads matches from 2018-08-03T15:39:00Z until 2019-12-25T22:03:40Z and saves the data to csv files inside the data folder.

from datetime import datetime
from pyltd2 import LTD2Fetcher, ExhaustiveFetcher

fetcher = LTD2Fetcher(
    "your_api_token", 
    date_after=datetime(2018, 8, 3, 15, 39, 00), 
    date_before=datetime(2019, 12, 25, 22, 3, 40)
)
api2csv = ExhaustiveFetcher("./data", fetcher=fetcher)
api2csv.start_fetching()

You can get your own api token by registering here.

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

pyltd2-1.0.1rc0.tar.gz (15.2 kB view hashes)

Uploaded Source

Built Distribution

pyltd2-1.0.1rc0-py3-none-any.whl (16.7 kB view hashes)

Uploaded Python 3

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