Skip to main content

Willump is a Python3 helper for the League of Legends LCU API

Reason this release was yanked:

doesn't include staticmethod start so you need to import the class itself to use willump

Project description

Willump

Willump is a Python3 helper for the League of Legends LCU API. Willump is asynchronous and can communicate on both HTTPS and WSS channels.

Starting Willump

Starting Willump is as easy as:

from willump import Willump
import asyncio

willump = await Willump.start()

This starts willump's http and websocket clients, and blocks until willump can connect to the League Client Ux process and server

Using HTTP methods

Willump can can make http requests to any LCU endpoint

response = await willump.request('get', '/lol-summoner/v1/current-summoner')
#request can be used to execute 'get', as well as any other http method
print(await response.json())

Subscribing to websocket events

Willump's websocket can subscribe to LCU events. Willump can attach a user defined default_handler to an event subscription which will be fired any time willump receives a websocket message pertaining to the event and the message is not otherwise handled. default_handler is a function which accepts json formatted data as its sole argument and returns None, or a disposable value.

async def un_default_event_handler(data):
  print("user defined default event handler")
  print(json.dumps(data, indent=4, sort_keys=True))

my_first_subscription = await willump.subscribe('OnJsonApiEvent', default_handler=un_default_event_handler)

You can add subscriptions to an event by resubscribing to the same event

new_subscription = await willump.subscribe('OnJsonApiEvent')

If you want to attach an already made subscription to another event, you can pass it to the subscription handler:

same_as_new_subscription = await willump.subscribe('OnJsonApiEvent_patcher_v1_status', subscription=new_subscription)
print(same_subscription_as_new_subscription is new_subscription) #subscription is shallow copied so this should print true

You can get the attached subscriptions to an event:

all_subscriptions = willump.get_subscriptions('OnJsonApiEvent')

Willump can also unsubscribe from events to stop listening for them entirely, or can remove a subscription from an event:

await willump.unsubscribe('OnJsonApiEvent', my_first_subscription) #new_subscription is still active
await willump.unsubscribe('OnJsonApiEvent') #This removes new_subscription, as well as any other subscriptions on 'OnJsonApiEvent'

Attaching endpoint filters to event subscriptions

Willump's subscriptions contain two further kinds of filters on websocket events -- uri filters and path filters. These are collectively known as endpoint filters. An endpoint filter is a function that runs when a certain endpoint is specified by the event response. A subscription can have multiple endpoint handlers attached to it. Path filters end in '/', and run when the specified endpoint is any sub-endpoint of the path. Uri filters run when the endpoint is the same as the filter's uri. You can attach endpoint filters through the subscription itself, or via Willump with the subscription instance. Endpoint handlers take the same signature as default_handler. They must take in json formatted data and return None, or a disposable value. Uri handlers and path handlers will both fire if they overlap. If an endpoint filter is fired, the subscription's default_handler will not fire. Attaching two endpoint handlers to the same endpoint will overwrite the pre-existing endpoint handler.

async def custom_uri_handler(data):
  print('current-summoner uri got triggered. This is custom_uri_handler')

async def custom_path_handler(data):
  print('/lol-summoner/ path got triggered. This is custom_path_handler')
  print('full triggered uri is:', data['uri'])

#adding uri endpoint filter via subscription instance
my_first_subscription.filter_endpoint('/lol-summoner/v1/current-summoner',
                                      custom_uri_handler)

#adding path endpoint filter via subscription instance through Willump
willump.subscription_filter_endpoint(my_first_subscription, '/lol-summoner/',
                                 custom_path_handler)

#unfiltering endpoints
willump.subscription_unfilter_endpoint(my_first_subscription, '/lol-summoner/')
my_first_subscription.unfilter_endpoint('/lol-summoner/v1/current-summoner')

Closing willump

Closing willump attempts to close the http and ws connections, gather outstanding subscription tasks, and gracefully exit.

await willump.close()

Willump isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.

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

willump-1.1.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

willump-1.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file willump-1.1.2.tar.gz.

File metadata

  • Download URL: willump-1.1.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for willump-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e30006d7702b0ea4311f4efe643d6c2a80a6e2328855f1dff9eaf404d38d711e
MD5 8ffead1b65e35546ad0b1375f0801a4b
BLAKE2b-256 6f3eddd6512eb114f8324df6e5bfcb685671932e669f9c5e270322e6a420b745

See more details on using hashes here.

File details

Details for the file willump-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: willump-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for willump-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1ce6fc900ad0c0de58b24865a1288f83dbfe8476e4d3b10fbca3ca94e3c8a10
MD5 f6b849cc788cefa0e7c63695ee37a31e
BLAKE2b-256 54980d564434d4f3d22347af8c07451c8a85ea37a9659b076938a4e862948c3c

See more details on using hashes here.

Supported by

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