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 🙏

© 2026 – Pkg Stats / Ryan Hefner

zwift-broadcast-api

v1.5.3

Published

Fetch data from the Zwift broadcast APIs with type information.

Readme

Zwift Broadcast API Library

Type-safe access to Zwift's broadcast APIs.

Caveat. This library does not give you access to the APIs, but if you do have access, it should make it easy to work with them, especially from a server environment. Your regular Zwift login does not work here.

For the APIs you can access with your Zwift login, take a look at zwift-api-wrapper.

Usage

Prerequisites

You should have the URL of a Zwift relay host, plus your client ID and secret. At the very least, put the last two in environment variables.

ZWIFT_RELAY_HOST=https://<...>/
ZWIFT_CLIENT_ID=<your_client_id>
ZWIFT_CLIENT_SECRET=<your_client_secret>

Installation

As usual with your preferred package manager.

npm install zwift-broadcast-api

Get the auth host (optional)

Use the relay host to obtain the URL of an auth host, if you don't have one. Should be safer, even if the response is not intended to change.

import { getAuthServer } from "zwift-broadcast-api";

const response = await getAuthServer(process.env.ZWIFT_RELAY_HOST);

// auth host URL is in response.authHost

Get the auth token from the auth host

The following call assumes the auth host has a trailing slash (/).

import { getZwiftToken } from "zwift-broadcast-api";

const response = await getZwiftToken({
  authHost: process.env.ZWIFT_AUTH_HOST,
  clientId: process.env.ZWIFT_CLIENT_ID,
  clientSecret: process.env.ZWIFT_CLIENT_SECRET,
});

// token is in response.access_token, but also take a look at
// response.expires_in to know when to refresh it

Call the broadcast APIs

You can now use the auth token and the relay host to call the various APIs.

import { getEventPlacement } from "zwift-broadcast-api";

const response = await getEventPlacement({
  eventId: 123456,
  from: 1,
  relayHost: env.ZWIFT_RELAY_HOST,
  subgroupId: 654321,
  to: 50,
  token: "<the_obtained_token>",
});

Future work

Consider refactoring to standardize variable names and types. For example, use only camelCase and use number for numeric IDs that are returned as strings.

Learnings

This is my first released package, so please pardon the inconsistencies as I learn my way around workflows. Please open pull requests or issues, or just ping me directly to my email with questions.

License

MIT