mirror of
https://github.com/UnaPepsi/valorant-api-python.git
synced 2026-03-10 14:14:16 -06:00
No description
| py_valorant | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| setup.py | ||
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
languageOptional[LANGUAGE] - Defualts to'en-US'- The language of the supported returned strings (
localizedin the API).
- The language of the supported returned strings (
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_characterOptional[bool] - Defualts toFalse- According to https://dash.valorant-api.com/endpoints/agents set this to
Trueto remove possible duplicates
- According to https://dash.valorant-api.com/endpoints/agents set this to
cacheOptional[bool] - Defualts toFalse- If
Truereturns values saved in cache and if not found it fetches normally and saves to cache - If
Falseremoves the values previously cached by this method and its used parameters and fetches normally without caching
- If
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
urlstr- The URL of the resource to convert
run_threadOptional[bool] - Defualts toFalse- Whether to run the function in a new Thread
Returns
BytesIO