如何为Riot API创建正确的请求

发布于 2025-02-13 22:14:42 字数 1043 浏览 1 评论 0原文

因此,我一直在尝试Valoranty模块,该模块提供了一种轻松的方式来发送请求以获取个人玩家统计信息。

此代码:

import os
import valorant

KEY = 'key'
client = valorant.Client(KEY, locale="ru-RU", region="eu", route="europe")

account = client.get_user_by_name("SGT ItsRazyHero#VCTRU")
match = account.matchlist().history.find(queueId="competitive")

if match == None:
    print("No Ranked match in recent history!")
    exit(1)
else:
    match = match.get()

for team in match.teams:
    print(f"{team.teamId} Team's Ranks: ")

    players = match.players.get_all(teamId=team.teamId)

    for player in players:
        print(f"\t{player.gameName} - {player.rank}")

检查我的最新竞争比赛,并获取有关队友及其排名的信息。 所以我遇到了麻烦。

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://eu.api.riotgames.com/val/match/v1/matchlists/by-puuid/C3NUBHHFqy-JaV_losaGX0s_-q-NszM5VGYyHHV8GhFMVffm9GhknMFaCiY5GxPLdQ6L_cDYUQol9A?locale=ru-RU

而且我不知道如何解决这个问题。 如果您遵循此链接,您将获得 401未经授权错误。

So I've been trying valorantpy module that provides an easy way to send requests to get personal player statistics.

This code:

import os
import valorant

KEY = 'key'
client = valorant.Client(KEY, locale="ru-RU", region="eu", route="europe")

account = client.get_user_by_name("SGT ItsRazyHero#VCTRU")
match = account.matchlist().history.find(queueId="competitive")

if match == None:
    print("No Ranked match in recent history!")
    exit(1)
else:
    match = match.get()

for team in match.teams:
    print(f"{team.teamId} Team's Ranks: ")

    players = match.players.get_all(teamId=team.teamId)

    for player in players:
        print(f"\t{player.gameName} - {player.rank}")

Checks my latest competitive match and gets information about teammates and their ranks.
So I've got trouble.

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://eu.api.riotgames.com/val/match/v1/matchlists/by-puuid/C3NUBHHFqy-JaV_losaGX0s_-q-NszM5VGYyHHV8GhFMVffm9GhknMFaCiY5GxPLdQ6L_cDYUQol9A?locale=ru-RU

And I don't know how to solve this problem.
If you follow this link you will get 401 Unauthorized error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慈悲佛祖 2025-02-20 22:14:43

如果您使用临时开发API键,则无法使用,因为您无权获取匹配历史记录。您可以通过登录到 devrapterer.riotgames.com 并转到API页面。

解决方案:
您需要注册您的产品并获取 Production API键个人API键(根据您的要求,选择是您的)。您可以通过登录上述网站并注册您的产品来做到这一点。

If you're using a temporary Development API key, it won't work cause you are not authorized to fetch match history. You can find a list of accessible APIs that work on a Development API key by logging in to developer.riotgames.com and going to the APIS page.

Solution:
You need to register your product and get the Production API key or the Personal API key (the choice is yours, depending upon your requirements). You can do this by logging in to the above site and registering your product.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文