Skip to main content

Introduction

The Agent LoL API provides programmatic access to League of Legends match data, player statistics, and AI-powered coaching insights. Built on top of the Riot Games API, it offers authenticated endpoints for retrieving account information, match history, detailed match data, and timeline analysis.

Authentication

All API endpoints require authentication via NextAuth session. The API uses the getRiotSessionOrFail helper to validate:
  • Active user session
  • Valid Riot API key
  • User PUUID (Player Universally Unique Identifier)
Unauthenticated requests will return a 401 Unauthorized response.

Base URL

/api/riot/
All endpoints are relative to this base path in the Next.js application.

Rate Limiting

The API is subject to Riot Games API rate limits:
  • Rate limits vary by endpoint and API key tier
  • Default caching is disabled (cache: 'no-store') for real-time data
  • Consider implementing client-side caching for frequently accessed data

Error Handling

All endpoints follow a consistent error response pattern:
{
  "error": "matchId is required"
}

Available Endpoints

Account Management

Get PUUID

Retrieve current user’s PUUID and Riot ID

Get Riot ID

Fetch Riot ID details by PUUID

Match Data

Match IDs

Get list of match IDs for a player

Match Details

Retrieve detailed match information with AI context

Timeline Analysis

Match Timeline

Get frame-by-frame match timeline data

AI Comparison

Compare player performance with AI coaching insights

Data Dragon

Get Version

Retrieve the latest Data Dragon version for champion assets

Data Dragon Version

Retrieves the latest Data Dragon version number from Riot’s CDN. This version is used to construct URLs for champion icons, item images, and other game assets.

Authentication

Does not require authentication. This endpoint is publicly accessible.

Response

version
string
required
The latest Data Dragon version (e.g., “14.1.1”)

Example

curl -X GET 'http://localhost:3000/api/ddragon/version'
{
  "version": "14.1.1"
}
This endpoint caches the version for 1 hour to reduce load on Riot’s Data Dragon API.

AI Features

Agent LoL includes optional AI-powered features when enabled:
ENABLE_MATCH_AGENT
boolean
default:"false"
Enable AI coaching features for match analysis
OPENAI_KEY
string
OpenAI API key for AI analysis features
When enabled, certain endpoints return additional analysis or comparison fields with AI-generated coaching insights.

Response Formats

All successful responses return JSON data. Response schemas are documented on individual endpoint pages.

Getting Started

  1. Authenticate with NextAuth
  2. Retrieve your PUUID from /api/riot/account/get-puuid
  3. Fetch match IDs from /api/riot/match/by-puuid/ids
  4. Get detailed match data from /api/riot/match/matchId
  5. Analyze timeline data with /api/riot/match/timeline/compare

Build docs developers (and LLMs) love