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

@varve/cmhc-api

v0.2.0

Published

An isomorphic TypeScript client for CMHC Housing Market Information Portal table exports.

Readme

@varve/cmhc-api

TypeScript client for CSV exports from CMHC's Housing Market Information Portal (HMIP).

This package follows the same shape as the other Varve agency SDKs: a small isomorphic fetch client, typed request objects, Zod-validated normalized results, and direct access to the raw provider surface when needed.

Install

npm install @varve/cmhc-api zod

Usage

import { CmhcClient } from '@varve/cmhc-api';

const cmhc = new CmhcClient();

const rows = await cmhc.getCmhc({
  survey: 'Rms',
  series: 'Vacancy Rate',
  dimension: 'Bedroom Type',
  breakdown: 'Historical Time Periods',
  region: {
    geographyId: '2410',
    geographyTypeId: '3',
    geoUid: '59933',
  },
  filters: {
    season: 'October',
  },
});

Configuration

const cmhc = new CmhcClient({
  baseUrl: 'https://www03.cmhc-schl.gc.ca/hmip-pimh/en/TableMapChart',
  maxRetries: 2, // accepted for compatibility; retries are handled by callers
  timeoutMs: 30_000,
});

The client performs one timeout-bound HTTP request per method call. Non-2xx responses expose status, and Retry-After is parsed as retryAfterMs when present. A narrow Node HTTP fallback is used only when native fetch cannot parse CMHC's response transport.

CMHC's export endpoint uses CMHC geography identifiers, not plain Census GeoUIDs. Pass region.geographyId and region.geographyTypeId from your own lookup layer. geoUid is retained on normalized rows when you have it.

For planner-driven NLQ flows that already know the portal table id, call the lower-level export method:

const csv = await cmhc.exportTableCsv({
  tableId: '2.2.1',
  region: { geographyId: '2410', geographyTypeId: '3' },
  filters: { season: 'October' },
});

Discovery

cmhc.listSurveys();
cmhc.listSeries('Rms');
cmhc.listDimensions({ survey: 'Rms', series: 'Vacancy Rate' });
cmhc.listBreakdowns({ survey: 'Rms', series: 'Vacancy Rate', dimension: 'Bedroom Type' });
cmhc.listFilters({
  survey: 'Rms',
  series: 'Vacancy Rate',
  dimension: 'Bedroom Type',
  breakdown: 'Historical Time Periods',
});

The bundled metadata currently covers common NLQ targets for starts, completions, under construction, vacancy, availability, rent, and rental universe tables. Pass tableCode for supported CMHC portal tables that are not yet bundled.

Verification

Current local checks:

npm run test:unit -w @varve/cmhc-api
npm run typecheck -w @varve/cmhc-api
npm run build -w @varve/cmhc-api

The initial suite has 6 unit tests covering discovery metadata, export form parameters, CSV parsing, table fetch normalization, filter validation, and HTTP error handling.

Attribution

CMHC data products have attribution requirements. Include the appropriate CMHC source notice when reproducing or adapting CMHC data.