No description
Find a file
2024-08-06 19:53:07 -06:00
py_valorant Release 2024-08-06 19:34:53 -06:00
.gitignore Release 2024-08-06 19:34:53 -06:00
LICENSE Release 2024-08-06 19:34:53 -06:00
README.md Fixed typo 🥲 2024-08-06 19:53:07 -06:00
setup.py Release 2024-08-06 19:34:53 -06:00

Type-Safe Synchronous and Asynchronous Python wrapper for Valorant-API.com

This library supports both sync, and async for its endpoints, is type-checked and supports caching

Installation

pip install -U py-valorant

Quick start

This API does not require any type of authentication key.

Each endpoint object is documented.

First, initialize a ValorantAPI or ValorantAPIAsync object

#Sync
from py_valorant import ValorantAPI

api = ValorantAPI()
#Async
from py_valorant import ValorantAPIAsync

api = ValorantAPIAsync()
Parameters
  • language Optional[LANGUAGE] - Defualts to 'en-US'
    • The language of the supported returned strings (localized in the API).

Then you access any of the attributes inside that object. For this example, we'll use the agent attribute

Fetch every agent

#Sync
agents = api.agent.fetch_all()
#Async
agents = await api.agent.fetch_all()
Parameters
  • is_playable_character Optional[bool] - Defualts to False
  • cache Optional[bool] - Defualts to False
    • If True returns values saved in cache and if not found it fetches normally and saves to cache
    • If False removes the values previously cached by this method and its used parameters and fetches normally without caching
Returns
  • List[Agent]

Now let's print to the console all the Agents' display name

for agent in agents:
  print(str(agent)) # agent.display_name also works

Convert a URL to bytes

from py_valorant.utils import url_to_bytes

downloaded = url_to_bytes('https://exampleimage.com/image.png')
Parameters
  • url str
    • The URL of the resource to convert
  • run_thread Optional[bool] - Defualts to False
    • Whether to run the function in a new Thread
Returns
  • BytesIO