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

wetherspoons-api

v3.0.0

Published

A simple package to get data from the JD Wetherspoons API

Readme

Wetherspoons API

A TypeScript package for accessing JD Wetherspoon's venue and menu data, including drink information with pricing and alcohol unit calculations.

npm version License: MIT Tests

Installation

npm install wetherspoons-api

Features

  • 🏪 Fetch all Wetherspoons venues
  • 📍 Get detailed venue information
  • 🍺 Access venue menus and drinks
  • 💰 Calculate price per unit (PPU) for alcoholic beverages
  • ✅ Type-safe with TypeScript and Zod validation
  • 🔄 Automatic handling of different portion sizes

Usage

This package is intended for server-side Node.js 20.19 or newer. It includes the same public client token shipped by Wetherspoons' own application, so no secret configuration is required. You can override that value if the upstream client changes it:

export WETHERSPOONS_API_TOKEN="replacement-public-client-token"

Browser clients should still call a controlled server endpoint so upstream timeouts, validation, caching, and request volume remain centrally managed.

Version 3 migration

Version 3 keeps zero-configuration token behaviour and accepts WETHERSPOONS_API_TOKEN as an optional override. Request timeoutMs now bounds the entire operation, including retries and backoff. Use attemptTimeoutMs to set the maximum duration of each individual upstream attempt.

Get All Venues

import { venues } from 'wetherspoons-api';

const allVenues = await venues();
console.log(allVenues);
// [
//   {
//     franchise: 'lloyds',
//     id: 123,
//     isClosed: false,
//     name: 'The Moon Under Water',
//     venueRef: 456
//   },
//   ...
// ]

Get Venue Details

import { venues, getVenue } from 'wetherspoons-api';

const allVenues = await venues();
const venue = allVenues[0];
const details = await getVenue(venue);

console.log(details);
// {
//   canPlaceOrder: true,
//   franchise: 'lloyds',
//   id: 123,
//   name: 'The Moon Under Water',
//   salesAreas: [{ id: 789 }],
//   venueCanOrder: true,
//   venueRef: 456
// }

Get Drinks with Price Analysis

import { venues, getDrinks } from 'wetherspoons-api';

const allVenues = await venues();
const venue = allVenues[0];
const result = await getDrinks(venue);

if (result.status === 'unavailable') {
  console.log(`Drinks unavailable: ${result.reason}`);
} else {
  console.log(result.drinks);
}
// [
//   {
//     name: 'Ruddles Best',
//     units: 2.27,
//     productId: 12345,
//     price: 2.49,
//     ppu: 1.0969,
//     currency: 'GBP'
//   },
//   ...
// ]
// Sorted by best value (lowest price per unit first)

Get Menus

import { venues, getVenue, getMenus, getMenu } from 'wetherspoons-api';

const allVenues = await venues();
const venue = allVenues[0];
const details = await getVenue(venue);

// Get all menus for a sales area
const menus = await getMenus({
  venue: details,
  salesAreaId: details.salesAreas[0].id
});

// Get detailed menu information
const drinksMenu = menus.find(m => m.name === 'Drinks');
if (drinksMenu) {
  const detailedMenu = await getMenu(drinksMenu);
  console.log(detailedMenu.data.categories);
}

API Reference

Functions

venues(): Promise<HighLevelVenue[]>

Fetches all Wetherspoons venues.

Returns: Array of venue objects with basic information.

getVenue(venue: HighLevelVenue): Promise<DetailedVenue>

Gets detailed information about a specific venue.

Parameters:

Returns: Detailed venue information including sales areas and ordering capabilities.

getMenus({ venue, salesAreaId }): Promise<HighLevelMenu[]>

Fetches all menus for a specific sales area in a venue.

Parameters:

  • venue: A detailed venue object from getVenue()
  • salesAreaId: The ID of the sales area

Returns: Array of menu objects.

getMenu(highLevelMenu: HighLevelMenu): Promise<DetailedMenu>

Gets detailed menu information including all products and categories.

Parameters:

Returns: Detailed menu with categories, item groups, and products.

getDrinks(highLevelVenue: HighLevelVenue): Promise<DrinksResult>

Fetches alcoholic products from every orderable menu in every sales area, calculates alcohol units and price per unit, then sorts by best value.

Parameters:

  • highLevelVenue: A venue object from venues()

Returns: An explicit available result containing drinks sorted by price per unit, or an unavailable result for normal venue/menu availability conditions. Upstream transport and response-validation failures reject the promise.

type DrinksResult =
  | { status: 'available'; drinks: Drink[]; partial?: boolean }
  | {
      status: 'unavailable';
      reason: 'venue-closed' | 'ordering-unavailable' | 'no-sales-area' |
        'no-orderable-menus' | 'no-usable-drinks';
      drinks: [];
    };

partial is true when drinks were recovered but at least one sales-area menu list or detailed menu could not be fetched. Treat partial results as unsuitable for complete price snapshots.

All exported request functions also accept RequestOptions:

type RequestOptions = {
  signal?: AbortSignal;       // caller cancellation; never retried
  timeoutMs?: number;         // one end-to-end operation deadline, default 15 seconds
  attemptTimeoutMs?: number;  // per-attempt timeout, default 5 seconds
  retries?: number;           // transient retry count, default 2
};

Types

HighLevelVenue

{
  franchise: string;
  id: number;
  isClosed: boolean;
  name: string;
  venueRef: number;
}

DetailedVenue

{
  canPlaceOrder: boolean;
  franchise: string;
  id: number;
  isClosed?: boolean;
  name: string;
  salesAreas: Array<{ id: number }>;
  venueCanOrder: boolean;
  venueRef: string | number;
}

Drink

{
  name: string;
  units: number;        // Alcohol units
  productId: number;
  price: number;        // Major currency units
  ppu: number;          // Price per unit
  currency: string;     // ISO 4217 code, such as GBP or EUR
}

How It Works

The package:

  1. Connects to the JD Wetherspoon API
  2. Validates all responses using Zod schemas for type safety
  3. Calculates alcohol units based on ABV and volume information
  4. Determines the best value portion size for each drink
  5. Sorts drinks by price per unit to help find the best deals

Development

# Install dependencies
npm install

# Build the package
npm run build

# Run tests
npm test

# Explicitly run the slow production integration suite
npm run test:live

# Run tests in watch mode
npm run test:watch

# Run tests with UI
npm run test:ui

# Run tests with coverage
npm run test:coverage

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

License

MIT © Joss Bird

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

Report bugs and feature requests at https://github.com/slack2450/wetherspoons-api/issues