Valorant API Documentation

repository·trunk·Indexed 20 days ago

https://github.com/techchrism/valorant-api-docs

A collection of documented endpoints and TypeScript return types for the unofficial Valorant API. It provides raw types and Zod-powered data transformation schemas via the valorant-api-types package (v0.10.1). The documentation covers various API categories including Contracts, Current Game, Local Chat, Party, Pre-Game, PVP Endpoints, Riot Auth, Session, Store, and Third-Party API by Officer, as well as instructions for connecting to local HTTPS and WebSocket APIs.

Tokens
97.2K
Snippets
257
Records
309
Agent score
67%

What's inside valorant-api-docs

  1. Overview of Riot Auth endpoints

    trunk
    The Riot Auth documentation provides a set of endpoints required to handle the authentication flow for Riot services. The process typically involves preparing cookies, performing the authorization request, handling multi-factor authentication (MFA) if required, and using cookies for re-authentication or retrieving entitlements and player information.
  2. Use Valorant API types and generate code

    trunk

    The project provides a TypeScript module published on npm. Developers can consume this module to:

    • Use the predefined Valorant API types in their own TypeScript projects.
    • Generate documentation from the module.
    • Generate API client code based on the defined endpoints.
  3. Manage game sessions with Session endpoints

    trunk

    The Session endpoints allow you to interact with the current game session state. There are two primary operations available:

    • Get Session Information: Retrieve details about the current active game session.
    • Re-connect Session: Re-establish a connection to the current game session.
  4. Identify Region and Shard

    trunk

    Regions and shards are used to construct remote API URLs.

    Determining Region

    • Locally: Use the RiotClientSession_FetchSessions endpoint and look for the -ares-deployment= argument, or scrape the ShooterGame log for region strings in URLs.
    • Manually: Users can provide one of the following Region IDs:
      • na (North America)
      • latam (Latin America)
      • br (Brazil)
      • eu (Europe)
      • ap (Asia Pacific)
      • kr (Korea)

    Determining Shard

    Shards are often tied to regions but can vary. Use the following mapping:

    Region IDShard(s)
    latamna
    brna
    nana OR pbe
    eueu
    apap
    krkr
  5. Understand Client Platform data

    trunk

    The client platform is represented as a Base-64 encoded JSON string containing the following fields:

    {
        "platformType": "PC",
        "platformOS": "Windows",
        "platformOSVersion": "10.0.19042.1.256.64bit",
        "platformChipset": "Unknown"
    }
    ew0KCSJwbGF0Zm9ybVR5cGUiOiAiUEMiLA0KCSJwbGF0Zm9ybU9TIjogIldpbmRvd3MiLA0KCSJwbGF0Zm9ybU9TVmVyc2lvbiI6ICIxMC4wLjE5MDQyLjEuMjU2LjY0Yml0IiwNCgkicGxhdGZvcm1DaGlwc2V0IjogIlVua25vd24iDQp9
  6. Set up the Valorant API Docs Web development environment

    trunk

    To run the Valorant API Docs Web frontend locally, install the dependencies and start the development server using npm. This project is built with Astro, TypeScript, and Tailwind CSS and generates a static site.

    npm install
    npm run dev
  7. Parse and transform data using Zod schemas

    trunk

    The package uses zod to document and transform return data. If you have zod installed as a dev dependency, you can use the endpoint schemas to parse raw JSON and transform it into a processed format. This is useful for handling data that requires transformation (e.g., converting base64-encoded strings into objects).

    • Use z.input<typeof endpoint.responses['200']> to get the type of the raw incoming data.
    • Use z.output<typeof endpoint.responses['200']> to get the type of the data after it has been processed by the schema.
    • Call .parse(returnData) on the schema to perform the transformation at runtime.
    import {presenceEndpoint} from 'valorant-api-types'
    import {z} from 'zod'
    
    // presences[0].private -> base64-encoded json string
    type PresenceResponseRaw = z.input<typeof presenceEndpoint.responses['200']>
    
    // presences[0].private -> {sessionLoopState: string, customGameName: string, ...}
    type PresenceResponseProcessed = z.output<typeof presenceEndpoint.responses['200']>
    
    async function getPresence(): Promise<PresenceResponseProcessed > {
        const returnData = await (await fetch('...')).json()
        return presenceEndpoint.responses['200'].parse(returnData)
    }
  8. Install valorant-api-types

    trunk

    Install the package using npm. Choose the installation method based on whether you need the endpoint data or only the TypeScript types:

    • For endpoint data and types: npm install valorant-api-types
    • For types only (development dependency): npm install valorant-api-types --save-dev
    npm install valorant-api-types
    # OR
    npm install valorant-api-types --save-dev
  9. Fetch local Swagger documentation

    trunk

    You can fetch JSON Swagger documentation for local endpoints to import them into tools like Swagger UI or Insomnia. This is useful for exploring and testing local API surfaces.

    Note: This documentation source is deprecated. For the latest documentation, visit https://valapidocs.techchrism.me/endpoint/local-swagger-docs.

    GET https://127.0.0.1:{lockfile port}/swagger/v3/openapi.json
    Authorization: Basic {base64 encoded "riot:{lockfile password}"}