Skip to main content

ValLib

PyPI - Version GitHub deployments GitHub

A Python authentication module for the RiotGames API, and basic endpoint provider for Valorant.

Features

  • Full auth flow
  • Request helpers
  • Basic endpoints for Valorant
  • Captcha "bypass" without using external services
  • Ability to use external Captcha solvers

Installation

The preferred method of installation is through pip but if you know better use the package manager that you want.

pip install ValLib

Reference

Basic structure

ValLib contains this basic building blocks:

  • User a dataclass containing username and password
  • Auth a dataclass containing ever auth param
  • AuthException a exception class for only when the auth goes wrong because of Riot

And the following methods:

  • authenticate to auth with username+password
  • cookie_token to auth with cookies instead of username+password
  • make_headers to convert Auth into headers for making requests

Usage

Without API helper

import ValLib
import requests

user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
headers = ValLib.make_headers(auth)
data = requests.get("https://auth.riotgames.com/userinfo", headers=headers)
print(data.json())

With API helper

import ValLib

user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
data = ValLib.get("https://auth.riotgames.com/userinfo", auth)
print(data.json())

Regions and Shards

Getting the region and the shard is often one of the most complicated of managing the API. So for that we have the get_region and get_shard methods inside ValLib.api and the ExtraAuth dataclass inside ValLib.structs.

import ValLib
from ValLib.api import get_region, get_shard
from ValLib.structs import ExtraAuth

user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
region = get_region(auth)
shard = get_shard(region)
extra = ExtraAuth(user.username, region, auth)

With this new instance of ExtraAuth we can use the custom API methods that require it of ValLib.api.

Custom methods

Inside ValLib.api there are this customs methods:

  • get_preference to fetch the in-game settings for Valorant
  • set_preference to set the in-game settings for Valorant
  • get_load_out to get the loadout (cosmetics + incognito) for Valorant
  • set_load_out to set the loadout (cosmetics + incognito) for Valorant
  • get_session to grab information about the current Valorant session

Custom Captcha provider

If you need to make automatic auth or just need another way of dealing with captcha you can make your own CaptchaSolver class. Here is an example how to do so:

import ValLib
import requests
from ValLib.captcha import CaptchaSolver, set_solver

class DumbCaptcha(CaptchaSolver):
    def token(self, rqdata, site_key):
        r = requests.get(
            "https://myapi.com",
            json={"rqdata": rqdata, "siteKey": site_key}
        )
        return r.text()

set_solver(DumbCaptcha())
user = ValLib.User("MyUser", "MyPass")
auth = ValLib.authenticate(user) # Will use api for captcha solving

DISCLAIMER: most captcha solving APIs exploit people to solve captchas so I'd recommend against using them but it's at your own risk.

Custom MFA Code

When login into a MFA guarded account, the library will use a standard input for getting the MFA code, but you can use your own, here is an example:

import ValLib
from ValLib.mfa import MfaInput, set_mfa

class MyMfa(MfaInput):
    def mfa(self) -> str:
        return magical_gui_input()

set_mfa(MyMfa())
user = ValLib.User("MyUser", "MyPass")
auth = ValLib.authenticate(user) # Will use your func for MFA input

Roadmap

  • Async
  • More endpoints
  • Better documentation
  • Better exports

Running Tests

Tests need to be run in a development environment with GUI, a navigator, pytest and filling this environment variables.

USERNAME="TestUser"
PASSWORD="TestPassword"

And then running pytest.

Acknowledgements

  • Thanks to Valorant-API and their mantainers
  • Thanks to Hawolt for discovering the Captcha solver
  • Thanks to Techdoodle for his API docs
  • Thanks to the Valorant App Developers discord

Release files for ValLib 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ValLib 1.5.0
File Size Uploaded
vallib-1.5.0.tar.gz 28.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ValLib 1.5.0
File Interpreter ABI Platform
ValLib-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.2 kB

Release files / vallib-1.5.0.tar.gz

Download URL vallib-1.5.0.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
73ac65740bf0e765cfcf55e5cf2d852d603388fb4ac692b3bd5d64286fb29c8b
BLAKE2b-256 checksum
How to use checksums
523cac33e42d91982b5416ba9494198e58182e0e1e837bb48ba495891750a414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / ValLib-1.5.0-py3-none-any.whl

Download URL ValLib-1.5.0-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a891e48d35bf141f20cbd02c93d4c2b5e9e2fc901e9139a566e435131822b934
BLAKE2b-256 checksum
How to use checksums
0664dde2389d6cddd840b54cb38c55690861c715fed7de1a53218b81157bc0ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page