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

fred-api-client

v0.0.1

Published

A fully-typed TypeScript client for the Federal Reserve Economic Data (FRED) API

Downloads

11

Readme

fred-api-client

npm version License: MIT

A fully-typed TypeScript client for the FRED® API (Federal Reserve Economic Data), published by the St. Louis Fed.

Covers all 36 endpoints across Categories, Releases, Series, Sources, Tags, GeoFRED Maps, and the v2 bulk API.


Features

  • ✅ Full TypeScript types for every request and response
  • ✅ All 36 FRED® API endpoints covered
  • ✅ ESM + CJS dual output
  • ✅ Zero runtime dependencies
  • ✅ Custom fetch support (bring your own, for Node 18-, Deno, Bun, etc.)
  • ✅ Configurable timeout and base URL
  • ✅ Meaningful error types (FredError) with HTTP status codes

Installation

npm install fred-api-client

Node.js ≥ 18 is required (uses native fetch). For Node < 18 provide a custom fetch via the fetch option.


Quick Start

import { FredClient } from 'fred-api-client';

const fred = new FredClient({ apiKey: 'YOUR_API_KEY' });

// Get GDP observations
const data = await fred.series.getSeriesObservations({ series_id: 'GDP' });
console.log(data.observations);

// Search for series
const results = await fred.series.searchSeries({ search_text: 'unemployment rate' });
console.log(results.seriess);

Get your free API key at: https://fred.stlouisfed.org/docs/api/api_key.html


Configuration

const fred = new FredClient({
  apiKey: 'YOUR_API_KEY',      // required
  baseUrl: 'https://api.stlouisfed.org', // optional, default shown
  fileType: 'json',            // optional, 'json' | 'xml'
  timeout: 30_000,             // optional, milliseconds
  fetch: customFetchFn,        // optional, custom fetch implementation
});

API Reference

All methods are async and return typed Promises. Parameters mirror the official FRED API docs exactly.

fred.categories

| Method | FRED Endpoint | |--------|--------------| | getCategory(params) | GET /fred/category | | getCategoryChildren(params) | GET /fred/category/children | | getCategoryRelated(params) | GET /fred/category/related | | getCategorySeries(params) | GET /fred/category/series | | getCategoryTags(params) | GET /fred/category/tags | | getCategoryRelatedTags(params) | GET /fred/category/related_tags |

fred.releases

| Method | FRED Endpoint | |--------|--------------| | getReleases(params?) | GET /fred/releases | | getAllReleaseDates(params?) | GET /fred/releases/dates | | getRelease(params) | GET /fred/release | | getReleaseDates(params) | GET /fred/release/dates | | getReleaseSeries(params) | GET /fred/release/series | | getReleaseSources(params) | GET /fred/release/sources | | getReleaseTags(params) | GET /fred/release/tags | | getReleaseRelatedTags(params) | GET /fred/release/related_tags | | getReleaseTables(params) | GET /fred/release/tables |

fred.series

| Method | FRED Endpoint | |--------|--------------| | getSeries(params) | GET /fred/series | | getSeriesCategories(params) | GET /fred/series/categories | | getSeriesObservations(params) | GET /fred/series/observations | | getSeriesRelease(params) | GET /fred/series/release | | searchSeries(params) | GET /fred/series/search | | getSeriesSearchTags(params) | GET /fred/series/search/tags | | getSeriesSearchRelatedTags(params) | GET /fred/series/search/related_tags | | getSeriesTags(params) | GET /fred/series/tags | | getSeriesUpdates(params?) | GET /fred/series/updates | | getSeriesVintageDates(params) | GET /fred/series/vintagedates |

fred.sources

| Method | FRED Endpoint | |--------|--------------| | getSources(params?) | GET /fred/sources | | getSource(params) | GET /fred/source | | getSourceReleases(params) | GET /fred/source/releases |

fred.tags

| Method | FRED Endpoint | |--------|--------------| | getTags(params?) | GET /fred/tags | | getRelatedTags(params) | GET /fred/related_tags | | getTagsSeries(params) | GET /fred/tags/series |

fred.maps (GeoFRED)

| Method | FRED Endpoint | |--------|--------------| | getShapes(params) | GET /geofred/shapes/file | | getSeriesGroup(params) | GET /geofred/series/group | | getSeriesData(params) | GET /geofred/series/data | | getRegionalData(params) | GET /geofred/regional/data |

fred.v2 (Bulk API)

| Method | FRED Endpoint | |--------|--------------| | getReleaseObservations(params) | GET /fred/v2/release/observations |


Error Handling

import { FredClient, FredError } from 'fred-api-client';

const fred = new FredClient({ apiKey: 'YOUR_API_KEY' });

try {
  const data = await fred.series.getSeries({ series_id: 'INVALID_ID' });
} catch (err) {
  if (err instanceof FredError) {
    console.error(`FRED Error [${err.code}]: ${err.message}`);
    // err.status  → HTTP status code
    // err.code    → FRED API error code
    // err.message → Human-readable message
  }
}

Examples

Fetch US GDP with percent change transformation

const gdp = await fred.series.getSeriesObservations({
  series_id: 'GDP',
  units: 'pc1',           // Percent change from year ago
  frequency: 'q',         // Quarterly
  observation_start: '2010-01-01',
});

Search for series and get their tags

const search = await fred.series.searchSeries({
  search_text: 'consumer price index',
  limit: 5,
  order_by: 'popularity',
  sort_order: 'desc',
});

for (const s of search.seriess) {
  const tags = await fred.series.getSeriesTags({ series_id: (s as { id: string }).id });
  console.log(tags.tags.map((t) => t.name));
}

Get state-level unemployment data (GeoFRED)

const regional = await fred.maps.getRegionalData({
  series_group: '882',
  region_type: 'state',
  date: '2024-01-01',
  season: 'NSA',
  units: 'Percent',
});

Use with a custom fetch (Node < 18)

import fetch from 'node-fetch';
import { FredClient } from 'fred-api-client';

const fred = new FredClient({
  apiKey: 'YOUR_API_KEY',
  fetch: fetch as unknown as typeof globalThis.fetch,
});

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Type check
npm run typecheck

# Lint
npm run lint

# Build
npm run build

License

MIT © Your Name