0.10.1 • Published 15 days ago

valorant-api-types v0.10.1

Weekly downloads
-
License
MIT
Repository
github
Last release
15 days ago

Valorant API Types

This is a collection of documented endpoints and return types for the unofficial Valorant API.

In the future, this project could include types for the websocket events and xmpp events.

Types may be incomplete or incorrect, please open an issue if you find any problems.

Installation

Install with npm install valorant-api-types if using the endpoint data or npm install valorant-api-types --save-dev if just using the types.

Usage

Using just the raw return types:

import {PresenceResponse} from 'valorant-api-types'

async function getPresenceRaw(): Promise<PresenceResponse> {
    return (await fetch('...')).json()
}

Internally, valorant-api-types uses zod to document and transform return data. If you install zod as a dev dependency, the following code is equivalent to the above code and adds no runtime overhead:

import {presenceEndpoint} from 'valorant-api-types'
import {z} from 'zod'

async function getPresenceRaw(): Promise<z.input<typeof presenceEndpoint.responses['200']>> {
    return (await fetch('...')).json()
}

The zod types can be used to parse and transform the raw data into a more usable format:

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)
}

The list of endpoints is exported and can be used to make your own docs or tools:

import {endpoints} from 'valorant-api-types'

for(const endpoint of Object.values(endpoints)) {
    console.log(`${endpoint.name} - ${endpoint.description}`)
}

Most text data can be markdown including the description and Zod type descriptions. Linking to other endpoints is done with [{method} {name}] (for example, [POST Auth Cookies]) which can be replaced with an appropriate link.

0.10.1

15 days ago

0.10.0

1 month ago

0.9.2

1 month ago

0.9.0

3 months ago

0.9.1

3 months ago

0.8.1

4 months ago

0.8.0

5 months ago

0.7.0

11 months ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago