> ## Documentation Index
> Fetch the complete documentation index at: https://docs.r5r.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# API & Integration

> Understanding the Host API system, identifiers, and data flow.

# Host API System

The R5R Tracker uses a secure API system to authenticate game servers and attribute stats to the correct Verified Host.

## Host API Key

Your **Host API Key** is the master credential that links your game servers to your verified account.

* **Generation**: You can generate or regenerate your key in the [Control Panel > Settings](https://r5r.dev/cp/?tab=settings).
* **Usage**: This key must be placed in your server's `platform/r5rdev_config.json` file.
* **Security**: **Never share this key.** If compromised, anyone can upload fake stats to your servers.

```json theme={null}
{
    "apikey": "YOUR_GENERATED_KEY_HERE"
}
```

## Server Identifiers

To distinguish between multiple servers running under the same host account, the system uses **Server Identifiers**.

### 1. Registering Identifiers

In the [Control Panel](https://r5r.dev/cp), go to the [**Servers**](https://r5r.dev/cp/?tab=servers) tab. Here you can define identifiers for your instances (e.g., `na-west-1`, `eu-central-pro`, `1v1-arena`).

### 2. Configuring the Server

On your game server, you must set the `identifier` config setting to match one of your registered identifiers. This allows the tracker to know exactly *which* of your servers is reporting data. This is done for you automatically in the [Config](https://r5r.dev/cp/?tab=config) tab.

## Data Endpoints

The tracker system primarily communicates with two endpoints:

### Player Stats Ingest

* **Endpoint**: `/api/stats8.php`
* **Function**: Receives real-time player statistics (kills, damage, weapon usage) at the end of rounds or matches.
* **Auth**: Requires valid `HOST_API_KEY` and Verified Host status.

### Match Logs Ingest

* **Endpoint**: `/api/tracker.php`
* **Function**: Uploads compressed match logs for archival and replay analysis.
* **Auth**: IP Whitelisted or Key Authenticated.

## Discord Webhooks

If enabled, your server can send events to a Discord Webhook.

* **Endpoint**: `/api/playercount.php`

* **Configuration**: Set `stats_discord_webhook_player_count "1"` in `playlists_r5_patch.txt`.

* **Behavior**: Sends "Player Joined", "Player Left" events to your configured webhook URL.

  <Danger>
    * `playercount` will be deprecated in a future release, as it verbose for high traffic servers via curl post. This functionality will be moved to websockets under discord hooks and available in a new suite of configurable discord based webhook features.
  </Danger>

* **Endpoint**: `/api/endmatch.php`

* **Configuration**: Set `stats_discord_webhook_matches_enabled "1"` in `playlists_r5_patch.txt`.

* **Behavior**: Sends a short match recap to a discord channel:\
  \
  <u>Example:</u>\
  **SERVER: \[NA] 1v1s**

  > [Match Ended](https://r5r.dev/lookup?MatchID=2201168879311273582) `CYPHER101a` won with: `24` kills & `6126` damage.

## Private Tracker Discord API

A private Discord command set is available for Verified Hosts at their discretion. Access is granted in the host-only channel at [discord.com/channels/1182006089177387141/1193142143070523504](https://discord.com/channels/1182006089177387141/1193142143070523504). Use it for quick lookups and moderation.

* `.names {oid|playername}`: Lists all names a player has used across all seasons (works with OID or last-known name when OID is matched).
* `.oid {playername}`: Returns OID(s) for the provided name (may return multiple on partial matches by season).
* `.isbanned {oid}`: Indicates if the player is globally banned on the R5R network.
* `.flags {oid}`: Shows counts for invalidated stats and whitelisted flags.
* `.flaginfo {oid}`: Lists all processed flags with match ID and reason.
* `.whitelists {oid}`: Lists all flags that were skipped for the player.
* `.lastgames {oid}`: Returns the last 5 match IDs for the player.
* `.find {name}`: Finds OID(s) by exact name match across all seasons.
* `.ismuted {oid}`: Shows if the player is globally text-muted on the tracker network (host opt-in required).
* `.readonly`: Lists stats registered as read-only in the CMS backend (with data types).
* `.set {oid} {read_only statname} {value}`: Helper-only. Sets a read-only stat by statname/value; value must match the stat’s data type.
* `.whois {oid}`: Returns current EA endpoint data for the account.
* `.whoisname {oid}`: Returns current EA endpoint data by current username.
* `.name {oid}`: Returns the player’s last name for the current season.
* `.played {oid|current_name|old_alias} {season_number}`: Lists seasons the player has played (or checks a specific season when provided).
