npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

valorant-api-types

v0.10.1

Published

A collection of documented endpoints and return types for the unofficial Valorant API

Downloads

165

Readme

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.