API Reference¶
Client¶
- class valorant.Client(key: str, locale: Optional[str] = Lex.LOCALE, region: str = 'na', route: str = 'americas', load_content: bool = True)¶
Represents a connection to the Riot Games API. Interacts specifically with VALORANT related endpoints.
A number of options can be passed to the
Client.- Parameters
key (str) – An access key used to authenticate with the API. Depending on the key’s access level, match endpoints may be restricted.
locale (Optional[str]) – The region locale to use when making requests. This defaults to the system’s locale as determined by Python. (i.e locale.getdefaultlocale()) If set to
None,ContentItemDTO.localizedNameswill be included in the response.region (Optional[str]) – The region to use when making requests. This defaults to na. Valid regions include na, eu, latam, etc. See
Lex.REGIONSfor a complete list of valid regions.route (Optional[str]) – The region route to use when making requests for Riot Accounts. This defaults to americas. Valid routes are americas, asia, europe, and esports. See
Lex.ROUTESfor a complete list of valid routes.load_content (bool) – Whether to load and cache content data from VALORANT upon initialization. Defaults to True.
Changed in version 1.0: Renamed reload parameter to load_content.
- asset(**attributes: Mapping[str, Any]) Optional[Union[ActDTO, ContentItemDTO]]¶
Find an item in VALORANT content data matching all given attributes. Returns
Noneif item is not found. This works because there are no semantic distinctions between Content Items.For example,
client.asset(name="Viper")would return aContentItemDTOdenoting content data for Viper.Note
If content data is not cached, this function will make a request for it when called. Be wary of ratelimits should you decide not to cache content data.
- Parameters
attributes (Mapping[str, Any]) – A mapping of keyword arguments to match for.
- Return type
Optional[Union[ActDTO, ContentItemDTO]]
- get_acts() List[ActDTO]¶
Get a
ContentListofActDTOobjects from VALORANT.- Return type
- get_characters() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent an Agent from VALORANT.- Return type
- get_charm_levels() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Gun Buddy Variant from VALORANT.- Return type
- get_charms() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Gun Buddy from VALORANT.- Return type
- get_chromas(strip: bool = False) List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Gun Skin or Gun Skin Color Variant from VALORANT.- Parameters
strip (bool) – If set to
True, the\r\nand\ncharacters will be replaced by a single space character. This is useful for formatting the gun skin names.- Return type
- get_content(cache: bool = True) ContentDTO¶
Get complete content data from VALORANT.
- Parameters
cache – If set to
True, the Client will cache the response data, and subsequent calls wills return the cache. Update this cache by callingClient.get_content()again with cache set toTrue.
Note
The cache provided is stored in memory and will not persist across program restarts.
- Return type
- get_current_act() Optional[ActDTO]¶
Helper function to get the current act from VALORANT. Returns
Noneif the current act can’t be determined.- Return type
Optional[ActDTO]
- get_equips() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent an Equippable items from from VALORANT (Includes abilities and standard guns/melee).- Return type
- get_game_modes() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Game Mode from VALORANT.- Return type
- get_leaderboard(size: int = 100, page: int = 0, pages: Optional[int] = None, actID: str = '') Union[LeaderboardDTO, LeaderboardIterator]¶
Get the ranked leaderboard for an Act in VALORANT.
- Parameters
size (int) – Size of the leaderboard players to include. Can be between
1and100. If this value is greater than100, the remaining items in leaderboard will beNone.page (Optional[int]) – Page of the leaderboard to retrieve. For example, page 4 of a leaderboard with a size of 50 will skip the first 200 players.
pages – Number of pages to retrieve from the leaderboard. If specified, the
pageparameter will be ignored. This will return aLeaderboardIteratorof the retrieved pages.actID (str) – ID of the Act to get the leaderboard from. This defaults to the currently active Act.
Examples:
# Get players from 101-200th rank on the leaderboard. lb = client.get_leaderboard(size=100, page=2)
# Loop through multiple leaderboard pages. pages = client.get_leaderboard(size=50, pages=3) for page in pages: print(page.totalPlayers)
Note
The
LeaderboardIteratorwill request the next page of the leaderboard after each iteration. Be wary of running into ratelimits when iterating over a large amount of pages.- Return type
Union[LeaderboardDTO, LeaderboardIterator]
- get_maps() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Map from VALORANT.- Return type
- get_platform_status() PlatformDataDTO¶
Get status of VALORANT for the given platform.
- Return type
- get_player_cards() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Player Card from VALORANT.- Return type
- get_player_titles() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Player Title from VALORANT.- Return type
- get_skin_levels() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Gun Skin from VALORANT (Including levels, but not color variants).- Return type
- get_skins() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Gun Skin from VALORANT (Not including levels or color variants.)- Return type
- get_spray_levels() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Spray Variant from VALORANT.- Return type
- get_sprays() List[ContentItemDTO]¶
Get a
ContentListofContentItemDTOobjects that each represent a Spray from VALORANT.- Return type
- get_user(puuid: str, route: str = 'americas') Optional[AccountDTO]¶
Get a Riot Account by their PUUID. Returns
Noneif user could not be found.- Parameters
puuid (str) – The PUUID of the account to retrieve.
route (str) – Geographical route to get the account from. See
Lex.ROUTESfor a list of valid routes. Defaults americas.
- Return type
Optional[AccountDTO]
- get_user_by_name(name: str, route: str = 'americas') Optional[AccountDTO]¶
Gets a Riot Account by their game name and tag line. Returns
Noneif user could not be found.- Parameters
name (str) – The account’s full game name and tag line, split by a hastag. (i.e frissyn#6969)
route (str) – Geographical route to get the account from. See
Lex.ROUTESfor a list of valid routes. Defaults americas.
- Return type
Optional[AccountDTO]
LocalClient¶
- class valorant.LocalClient(reigon='na')¶
Client for interacting with the local instance of the VALORANT application. This is called the RCS API. The game must be running for this class to function properly. Currently unstable, complete support is coming soon.
Warning
While interacting with the RCS API is not explicitly disallowed, please have some common sense.
valorant.pyis not liable for any punishment you may recieve if you break Riot’s Terms of Service. (i.e. creating an Auto Agent Selector)- Parameters
region (str) – The region to instance the client with. If this doesn’t match the game’s region there could be some unexpected behavior.
Expressions¶
- valorant.exp(op: str, value: Any) Expression¶
Shorthand method for creating expressions to use alongside
ContentList.get()orContentList.get_all(). Expressions can also be created directly.- Parameters
op (Text) – The operator used to compare the element trait to the given value.
value (Any) – The value to compare the element trait to.
- Return type
- class valorant.Expression(op: str, value: Any)¶
Utility class for generating logical statements from a given operator and value. Supports object and logical operators. Also supports dot operators and member functions.
- Parameters
op (Text) – The operator used to compare the element trait to the given value.
value (Any) – The value to compare the element trait to.
Note
The Expression class only supports logical and object comparisons, and cannot generate “flipped” statements. (i.e
is notworks, butnot indoesn’t.)- statement(a: Any) bool¶
Executes the generated logical statement against the passed value.
Examples:
exp = valorant.Expression('>=', 50) exp.statement(10) # => False
exp = valorant.Expression('.endswith', '!') exp.statement("Hello, World!") # => True
- Parameters
a (Any) – The value to test against.
- Return type
Lexicon¶
- class valorant.Lex¶
Reference class for storing constants to be used across the library. Initializing isn’t allowed and will throw a
NotImplementedError.- CLIENT_API = 'https://pd.{code}.a.pvp.net/'¶
URL for the Valorant client API.
- CONTENT_NAMES = ['acts', 'characters', 'charmLevels', 'charms', 'chromas', 'equips', 'gameModes', 'maps', 'playerCards', 'playerTitles', 'skinLevels', 'skins', 'sprays']¶
List of content data attribute names.
- ENDPOINTS = {'web': {'content': 'val/content/v1/contents', 'game-name': 'riot/account/v1/accounts/by-riot-id/{name}/{tag}', 'leaderboard': 'val/ranked/v1/leaderboards/by-act/{actID}', 'match': 'val/match/v1/matches/{matchID}', 'match-queue': 'val/match/v1/recent-matches/by-queue/{queue}', 'matchlists': 'val/match/v1/matchlists/by-puuid/{puuid}', 'puuid': 'riot/account/v1/accounts/by-puuid/{puuid}', 'status': 'val/status/v1/platform-data'}}¶
Mappings of endpoint names to endpoint paths for the client and web API.
- HEADERS = {'web': {'Accept-Charset': 'application/x-www-form-urlencoded; charset=UTF-8'}}¶
Default headers for the client and web API.
- LOCALE = 'en-US'¶
Default locale as determine by Python’s locale module.
- LOCALES = ['ar-AE', 'de-DE', 'en-GB', 'en-US', 'es-ES', 'es-MX', 'fr-FR', 'id-ID', 'it-IT', 'ja-JP', 'ko-KR', 'pl-PL', 'pt-BR', 'ru-RU', 'th-TH', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']¶
List of locales supported by the client and web API.
- RANKS = {0: 'Unrated', 1: 'Unused1', 2: 'Unused2', 3: 'Iron 1', 4: 'Iron 2', 5: 'Iron 3', 6: 'Bronze 1', 7: 'Bronze 2', 8: 'Bronze 3', 9: 'Silver 1', 10: 'Silver 2', 11: 'Silver 3', 12: 'Gold 1', 13: 'Gold 2', 14: 'Gold 3', 15: 'Platinum 1', 16: 'Platinum 2', 17: 'Platinum 3', 18: 'Diamond 1', 19: 'Diamond 2', 20: 'Diamond 3', 21: 'Ascendant 1', 22: 'Ascendant 2', 23: 'Ascendant 3', 24: 'Immortal 1', 25: 'Immortal 2', 26: 'Immortal 3', 27: 'Radiant'}¶
Mapping of competitiveTier values to rank title.
- REGIONS = ['ap', 'br', 'eu', 'eune', 'euw', 'jp', 'kr', 'lan', 'las', 'latam', 'na', 'oce', 'ru', 'tr']¶
List of locales supported by the client and web API.
- ROUTES = ['americas', 'asia', 'europe']¶
List of geographical routes supported by the Web API.
- SAFES = "~()*!.'"¶
String of URL-safe characters in requests to the API.
- WEB_API = 'https://{code}.api.riotgames.com/'¶
URL for the Valorant client API.
DTO¶
AbilityDTO¶
AbilityCastsDTO¶
AccountDTO¶
- class valorant.AccountDTO(obj, handle)¶
-
- matchlist() MatchlistDTO¶
Get a
MatchlistDTOof the most recent matches played by this account.- Return type
ActDTO¶
CoachDTO¶
ContentDTO¶
- class valorant.ContentDTO(obj)¶
- acts: List[valorant.objects.content.ActDTO]¶
- characters: List[valorant.objects.content.ContentItemDTO]¶
- charmLevels: List[valorant.objects.content.ContentItemDTO]¶
- charms: List[valorant.objects.content.ContentItemDTO]¶
- chromas: List[valorant.objects.content.ContentItemDTO]¶
- equips: List[valorant.objects.content.ContentItemDTO]¶
- gameModes: List[valorant.objects.content.ContentItemDTO]¶
- maps: List[valorant.objects.content.ContentItemDTO]¶
- playerCards: List[valorant.objects.content.ContentItemDTO]¶
- playerTitles: List[valorant.objects.content.ContentItemDTO]¶
- skinLevels: List[valorant.objects.content.ContentItemDTO]¶
- skins: List[valorant.objects.content.ContentItemDTO]¶
- sprayLevels: List[valorant.objects.content.ContentItemDTO]¶
- sprays: List[valorant.objects.content.ContentItemDTO]¶
ContentItemDTO¶
ContentList¶
- class valorant.ContentList(*args, **kwargs)¶
-
- find_all(value: Optional[T] = None, **attrs: Mapping[str, T]) Optional[T]¶
Semantic alias for
get_all().
- get(value: Optional[T] = None, **attrs: Mapping[str, T]) Optional[DTO]¶
Get the first element in the ContentList with traits that match all the keyword arguments passed in attrs. The arguments passed can be any value, an expression, or a callable that returns a boolean or boolean-like object.
A single argument defaults to checking for
name.Multiple arguments are checked using logical AND, not logical OR. The element must match all the arguments, not just one.
Returns
Noneif no elements in the ContentList match the given arguments.Examples:
agent = agents.get(name="Neon")
player = leaderboard.players.get(numberOfWins=lambda x: x >= 10)
See the Using Expressions and Queries page for more in-depth usage.
- Parameters
value (Optional[Any]) – Alias argument for
name=value. Ignores keyword arguments if passed.attrs (Mapping[Any, Any]) – Mapping of attribute traits to match for.
- Return type
Optional[DTO]
- get_all(value: Optional[T] = None, **attrs: Mapping[str, T]) List[DTO]¶
Same functionality as
get()but returns a list of every matching element. The list will be empty if no matching elements were found in the ContentList.- Parameters
value (Optional[Any]) – Alias argument for
name=value. Ignores keyword arguments if passed.attrs (Mapping[Any, Any]) – Mapping of attribute traits to match for.
- Return type
List[DTO]
DamageDTO¶
EconomyDTO¶
FinishingDamageDTO¶
KillDTO¶
- class valorant.KillDTO(obj)¶
-
- finishingDamage: valorant.objects.match.FinishingDamageDTO¶
- playerLocations: List[valorant.objects.player.PlayerLocationsDTO]¶
- victimLocation: valorant.objects.player.LocationDTO¶
LeaderboardDTO¶
LeaderboardIterator¶
- class valorant.LeaderboardIterator(caller: WebCaller, pages: int = 1, **params)¶
Simple iterator utility for getting multiple leaderboard pages. Each iteraction returns a
LeaderboardDTO. SeeClient.get_leaderboard()for more info.
LeaderboardPlayerDTO¶
LocationDTO¶
MatchDTO¶
- class valorant.MatchDTO(obj)¶
- coaches: List[valorant.objects.match.CoachDTO]¶
- matchInfo: valorant.objects.match.MatchInfoDTO¶
- players: List[valorant.objects.player.PlayerDTO]¶
- roundResults: List[valorant.objects.match.RoundResultDTO]¶
- teams: List[valorant.objects.match.TeamDTO]¶
- timestamp: datetime.datetime¶
MatchInfoDTO¶
MatchlistDTO¶
- class valorant.MatchlistDTO(obj, handle)¶
- history: List[valorant.objects.match.MatchlistEntryDTO]¶
MatchlistEntryDTO¶
PlatformContentDTO¶
PlatformDataDTO¶
PlayerDTO¶
PlayerLocationsDTO¶
PlayerRoundStatsDTO¶
- class valorant.PlayerRoundStatsDTO(obj)¶
- ability: valorant.objects.match.AbilityDTO¶
- damage: List[valorant.objects.match.DamageDTO]¶
- economy: valorant.objects.match.EconomyDTO¶
- kills: List[valorant.objects.match.KillDTO]¶
PlayerStatsDTO¶
RoundResultDTO¶
- class valorant.RoundResultDTO(obj)¶
-
- defuseLocation: valorant.objects.player.LocationDTO¶
- defusePlayerLocations: Optional[List[valorant.objects.player.PlayerLocationsDTO]]¶
- plantLocation: valorant.objects.player.LocationDTO¶
- plantPlayerLocations: Optional[List[valorant.objects.player.PlayerLocationsDTO]]¶
- playerStats: List[valorant.objects.player.PlayerStatsDTO]¶