An open API service indexing awesome lists of open source software.

https://github.com/pastorsj/node-fred

A Fred2 API wrapper
https://github.com/pastorsj/node-fred

api api-wrapper fred2 nodejs

Last synced: 5 months ago
JSON representation

A Fred2 API wrapper

Awesome Lists containing this project

README

          

# node-fred ·

[![build status](https://github.com/pastorsj/node-fred/actions/workflows/node.js.yml/badge.svg)](https://github.com/pastorsj/node-fred/actions)
[![npm version](https://img.shields.io/npm/v/node-fred.svg?style=flat)](https://www.npmjs.com/package/node-fred)
[![Coverage Status](https://coveralls.io/repos/github/pastorsj/node-fred/badge.svg?branch=master)](https://coveralls.io/github/pastorsj/node-fred?branch=master)

A Fred2 API wrapper

# The Fred API

[Official Documentation](https://research.stlouisfed.org/docs/api/fred/)

[Wrapper Documentation](https://pastorsj.github.io/node-fred-api/)

# Installation Instructions

```
npm install node-fred --save
```

# Example

## Using Promises

```javascript
import Fred from 'node-fred';

const fred = new Fred(API_KEY);

function getCategory(categoryID) {
fred.categories
.getCategory(125)
.then((res) => {
console.log('Category', res);
})
.catch((err) => {
console.error('Error', err);
});
}
getCategory(125);
```

## Using async/await

```javascript
import Fred from 'node-fred';

const fred = new Fred(API_KEY);

async function getCategory(categoryID) {
try {
const category = await fred.categories.getCategory(categoryID);
console.log('Category', res);
} catch (err) {
console.error('Error', err);
}
}
getCategory(125);
```