# v4.0.0

## Key Requirement

Due to recent botting attacks that impacted everyone in terms of global 429 errors, an API Key is now required. As this would break twitch bots (no ability to set headers), you can authenticate with the `?api_key` query param.\
But no worries, you can easily get a key without waiting time, just follow the following steps:

1. Join on the discord: <https://discord.com/invite/X3GaVkX2YN>
2. Verify
3. Go to the **#get-a-key** channel
4. Select from the dropdown list **"VALORANT (Basic Key)"**

The bot will now present you an API Key that you can use instantly.\
If you need a higher rate limit key, please select "VALORANT (Advanced Key)". This type of key needs some information from you and follows an approval workflow and requires some waiting time.

{% hint style="info" %}
Friendly reminder here: This API is not designed to be used in production apps, so custom keys are not quaranteed to be granted
{% endhint %}

## Performance & Capacity

Version 4 is written in Rust, which enables higher performance and lower latency for each request & and the overall ability to handle more requests at the same time.

The amount of backend proxies also were upgraded to 7.5x in comparison to v3, allowing higher limits and more requests to be handled.

## Rate Limit Calculation

The way of how the rate limit is calculated will be changed. Right now it's simply 1 request to API = +1 in your rate limit.\
As some of these calls require fetches from riot, some do not (cache, database or simply local generated like the crosshair endpoint) this will change.\
The biggest issue is the rate limit to riot, not the amount of requests the server can handle.\
So the new rate limiting will look like this:

```
1 Request to API = +1
1 Request to Riot in the background = +1
```

#### Example 1

* Endpoint: /valorant/v3/matches/eu/Henrik3/VALO?size=10
* 7 Matches stored on the server for this user
* Hit cache: <mark style="color:red;">false</mark>
* Required Requests to Riot:
  * 1x history
  * 3x matches (the ones not stored on server)&#x20;
* Ratelimit increase: 1 (Call to API) + 4 (Calls to Riot) = <mark style="color:green;">5</mark>

#### Example 2

* Endpoint: /valorant/v3/matches/eu/Henrik3/VALO?size=10
* 10 Matches stored on the server for this user
* Hit cache: <mark style="color:green;">true</mark>
* Required Requests to Riot:
  * 0x history
  * 0x matches (the ones not stored on server)&#x20;
* Ratelimit increase: 1 (Call to API) + 0 (Calls to Riot) = <mark style="color:green;">1</mark>

## New Headers

Every Request now contains a <mark style="color:yellow;">X-Cache-Status</mark> header, which indicates if the response data was created from the internal cache.

These values can be <mark style="color:yellow;">HIT</mark> or <mark style="color:yellow;">MISS.</mark>

If the state is <mark style="color:yellow;">HIT</mark>, there also is a <mark style="color:yellow;">X-Cache-TTL</mark> header, indicating the time in seconds the cache (or  if multiple caches used the cache TTL that will expire first) will expire and new data can be fetched.\
If the state is <mark style="color:yellow;">MISS</mark>, this header will not exist.

## Error Handling & Error Codes

* Error messages should be now more clear and reliable, no more random 500 error codes except real code issues
* Due to this, the error codes have changed and there are some few more of them, you can find them [\[here\]](/valorant/error-codes.md)

## Deprecations

The following endpoints will be deprecated

* [/valorant/v1/mmr/:affinity/:name/:tag](/valorant/api-reference/mmr.md)
* [/valorant/v1/by-puuid/mmr/:affinity/:puuid](/valorant/api-reference/mmr.md)
* [/valorant/v1/leaderboard/:affinity](/valorant/api-reference/leaderboard.md)
* [/valorant/v1/lifetime/matches/:affinity/:name/:tag](/valorant/api-reference/stored-data.md)
* [/valorant/v1/by-puuid/lifetime/matches/:affinity/:puuid](/valorant/api-reference/stored-data.md)
* [/valorant/v1/lifetime/mmr/:affinity/:name/:tag](/valorant/api-reference/stored-data.md)
* [/valorant/v1/by-puuid/lifetime/matches/:affinity/:puuid](/valorant/api-reference/stored-data.md)

These deprecations will have their full effect 3 months after release of the respective patch (in this case v4)

## Routing Issues (Telekom)

As you may have noticed, there is an issue with routing if you have a Telekom (German, Hungary, Romania) connection. This is related to the peering between Telekom and CF, routing the package via NewArk in every case, resulting in a latency increase by 9x in average in the eu.

The change that should fix this is applied for `beta.api` and `eu.api` already.

#### For example:

```
api.henrikdev.xyz/valorant/v1/esports/schedule (CF) ~450ms
eu.api.henrikdev.xyz/valorant/v1/esports/schedule (Not CF) ~50ms
```

## Endpoint: Account

### New Version

```
/valorant/v2/account/:name/:tag
/valorant/by-puuid/v2/account/:puuid
```

* Implement new, more stable way to get the puuid
* Streamlined data structure (no more unix timestamps, no formated "X minutes ago")

```json
{
    "status": 200,
    "data": {
        "puuid": "60325b89-7524-55be-be68-8ab3e7c0f2a3",
        "region": "eu",
        "account_level": 1086,
        "name": "FUT rAx",
        "tag": "VAL",
        "card": "29d6aced-4f66-e000-15eb-71b1906a113a",
        "title": "c8be8fda-46a8-9843-87bc-ecbf9672c227",
        "platforms": [
            "PC",
            "CONSOLE"
        ],
        "updated_at": "2024-06-16T18:33:11.095Z"
    }
}
```

## Endpoint: Leaderboard

### Changes

* Query params:  `name`, `tag`, `puuid`, `season`
  * Will now be fetched directly if it's the current season (and not from 30min update cycle)
  * Has a cache of 5min to reduce load

### New Version

```
/valorant/v3/leaderboard/:region/:platform
```

* Improved fetching performance
* Support for `pc` and `console`
* Streamlined data structure (no mix between camelCase and under\_score properties)
* New query params:
  * `start_index`: `number` => Between `1` & `amount Of Players (dynamic)`
  * `size`: `number` => Defaults to 1000 => Between `1` & `amount Of Players (dynamic)`

```json
{
    "status": 200,
    "results": {
        "total": 15000,
        "returned": 1,
        "before": 0,
        "after": 14999
    },
    "data": {
        "updated_at": "2024-06-17T20:54:44.563Z",
        "thresholds": [
            {
                "tier": {
                    "id": 24,
                    "name": "Immortal 1"
                },
                "start_index": 9434,
                "threshold": 0
            },
            {
                "tier": {
                    "id": 25,
                    "name": "Immortal 2"
                },
                "start_index": 4877,
                "threshold": 100
            },
            {
                "tier": {
                    "id": 26,
                    "name": "Immortal 3"
                },
                "start_index": 501,
                "threshold": 200
            },
            {
                "tier": {
                    "id": 27,
                    "name": "Radiant"
                },
                "start_index": 1,
                "threshold": 550
            }
        ],
        "players": [
            {
                "card": "bdc0c02c-441c-8ebc-ec5e-27bff0888ae0",
                "title": "d13e579c-435e-44d4-cec2-6eae5a3c5ed4",
                "is_banned": false,
                "is_anonymized": false,
                "puuid": "e244540d-08f9-5ac3-bdac-09c98483af99",
                "name": "lovers rock",
                "tag": "133",
                "leaderboard_rank": 1,
                "tier": 27,
                "rr": 1126,
                "wins": 103,
                "updated_at": "2024-06-17T20:54:42.034Z"
            }
        ]
    }
}
```

### Changes

* The MMR v2 endpoints will now not have the ability anymore to filter by season with `?season`

### New Version

```
/valorant/v3/mmr/:region/:platform/:name/:tag
/valorant/v3/by-puuid/:region/:platform/:puuid
```

* Streamline property names (like `currenttier` => `tier` or `ranking_in_tier` => `rr`
* `by_season` is now an array

```json
{
  "status": 200,
  "data": {
    "account": {
      "puuid": "54942ced-1967-5f66-8a16-1e0dae875641",
      "name": "Henrik3",
      "tag": "VALO"
    },
    "peak": {
      "season": {
        "id": "2de5423b-4aad-02ad-8d9b-c0a931958861",
        "short": "e6a3"
      },
      "ranking_schema": "ascendant",
      "tier": {
        "id": 21,
        "name": "Ascendant 1"
      }
    },
    "current": {
      "tier": {
        "id": 18,
        "name": "Diamond 1"
      },
      "rr": 38,
      "last_change": 15,
      "elo": 1538,
      "leaderboard_placement": null
    },
    "seasonal": [
      {
        "season": {
          "id": "22d10d66-4d2a-a340-6c54-408c7bd53807",
          "short": "e8a2"
        },
        "wins": 22,
        "games": 42,
        "end_tier": {
          "id": 18,
          "name": "Diamond 1"
        },
        "ranking_schema": "ascendant",
        "leaderboard_placement": null,
        "act_wins": [
          {
            "id": 18,
            "name": "Diamond 1"
          }
        ]
      }
    ]
  }
}
```

## Endpoint: Matches

### New Version

```
/valorant/v4/match/:region/:platform/:id 
/valorant/v4/matches/:region/:platform/:name/:tag
/valorant/v4/by-puuid/matches/:region/:platform/:puuid
```

* Skipped v3 for `/valorant/:version/match/:region/:id` to align version numbers
* Added `region` param to the url
  * This saves (potentially) 3 unnessecary requests to the riot servers => 3 requests less that can be used elsewhere
* Removes duplicate data fragments and unnecessary data

## Endpoint: Premier

### Changes

#### `/valorant/v1/premier/search`

* The API now only returns 50 entries if no query parameters are provided instead of the whole database
  * This was a bug in v3 and not intentional
* Added a new property to each object: `updated_at: Date`

#### `/valorant/v1/premier/:name/:tag` & `/valorant/v1/premier/:id`

* These endpoints will now not return the 500 error code anymore
* You can still only find teams that are enrolled and indexed in the ingame leaderboard
* The leaderboard is getting scanned for updated/teams every three hours


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.henrikdev.xyz/valorant/changes/v4.0.0.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
