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

yfs-api

v2.3.0

Published

Fully typed TypeScript wrapper for Yahoo Fantasy Sports API with OAuth 1.0 and 2.0 support

Readme

yfs-api

Typed ESM client for the Yahoo Fantasy Sports API.

Requirements

  • Node.js 18 or newer
  • ESM (import); CommonJS is not published
  • Yahoo application credentials
npm install yfs-api

Public Reads

Public mode uses OAuth 1.0 request signing as an observed SDK compatibility path. Yahoo's current Fantasy Sports documentation requires OAuth 2.0, so do not treat public OAuth 1.0 support as a long-term Yahoo contract.

import { YahooFantasyClient } from 'yfs-api';

const client = new YahooFantasyClient({
  clientId: process.env.YAHOO_CLIENT_ID!,
  clientSecret: process.env.YAHOO_CLIENT_SECRET!,
  publicMode: true,
});

const { game } = await client.api().game('nhl').get();

User Authentication

User mode uses OAuth 2.0. Generate and retain a state value, validate it on the callback, then exchange the authorization code.

const client = new YahooFantasyClient({
  clientId: process.env.YAHOO_CLIENT_ID!,
  clientSecret: process.env.YAHOO_CLIENT_SECRET!,
  redirectUri: 'https://example.com/oauth/callback',
});

const request = client.createAuthorizationRequest();
// Store request.state in the user's server-side session and redirect to request.url.

client.validateAuthorizationState(request.state, callbackState);
await client.authenticate(authorizationCode);

Pass a TokenStorage implementation as the second constructor argument and call loadTokens() when starting a session. Access tokens are refreshed when needed and newly issued tokens are saved through that storage.

Resource Reads

Responses preserve the selected parent hierarchy. For example, a nested user request returns users -> games -> teams, not a top-level teams array.

const response = await client.api().users().games(['nhl']).teams([]).get();

for (const user of response.users) {
  for (const game of user.games ?? []) {
    console.log(game.teams ?? []);
  }
}

const league = await client
  .api()
  .league('1.l.2')
  .include('settings', 'standings', 'draftresults')
  .get();

const team = await client.api().team('1.l.2.t.3').include('standings').get();

Root plural selectors require at least one key. Filters and selectors are serialized into Yahoo's semicolon-delimited paths and can be inspected with toPath().

Roster Writes

Roster updates are the only stable write helper exported at the package root. The result is a confirmation object when Yahoo returns one, otherwise undefined.

import { RosterMoveBuilder } from 'yfs-api';

const moves = new RosterMoveBuilder()
  .week(10)
  .movePlayer('1.p.2', 'BN');

const confirmation = await client
  .api()
  .team('1.l.2.t.3')
  .roster()
  .update(moves);

Transaction mutation builders and resources are intentionally not public. Transaction DTOs describe read responses only.

Experimental Frontend Adapter

YahooFrontendApiClient and createFrontendApi target Yahoo's observed web frontend routes. They are separate from the OAuth client and not a supported Yahoo API. Reads under /fantasy/v2/ and /fantasy/v3/ are sent as-is; writes are limited to an internal allowlist (currently the roster PUT) and require a user-supplied browser session. See docs/frontend-api-adapter.md.

Raw XML

Use client.requestRawXml(path, options) when the normalized DTO is not suitable. Regular resource reads continue to parse and normalize Yahoo XML.

Public Surface

The package root exports the client, OAuth 1.0 and OAuth 2.0 clients/types, OAuth state request type, Config, TokenStorage, RequestOptions, error classes and guards, common key/scalar types, normalized DTOs, RosterMoveBuilder, RosterCoverageOptions, parseYahooXML, and the experimental frontend adapter (YahooFrontendApiClient, createFrontendApi, resolveFrontendRoute, FrontendApiError, and their types).

Development

bun install --frozen-lockfile
bun run check:package
SKIP_INTEGRATION_TESTS=true bun run test:integration

Live integration tests are manual. Destructive tests require the separate test:integration:destructive command and explicit configuration. See docs/INTEGRATION_TEST_SETUP.md.

Documentation

Release History

2.3.0 is the current stable API. Material for the 2.0.0-beta.* and 1.x lines in the changelog and archive is historical, not current guidance.

MIT licensed. See LICENSE.